.. Algorithms/Inserters//inserter |+inserter+| ================ .. _`inserter_`: Synopsis -------- .. parsed-literal:: template< typename State , typename Operation > struct inserter { typedef State state; typedef Operation operation; }; Description ----------- A general-purpose model of the |Inserter| concept. Header ------ .. parsed-literal:: #include Model of -------- |Inserter| Parameters ---------- +---------------+-------------------------------+-----------------------------------+ | Parameter | Requirement | Description | +===============+===============================+===================================+ | ``State`` | Any type | A initial state. | +---------------+-------------------------------+-----------------------------------+ | ``Operation`` | Binary |Lambda Expression| | An output operation. | +---------------+-------------------------------+-----------------------------------+ Expression semantics -------------------- |Semantics disclaimer...| |Inserter|. For any binary |Lambda Expression| ``op`` and arbitrary type ``state``: +---------------------------+-------------------------------------------+ | Expression | Semantics | +===========================+===========================================+ | ``inserter`` | An |Inserter|. | +---------------------------+-------------------------------------------+ Complexity ---------- Amortized constant time. Example ------- .. parsed-literal:: template< typename N > struct is_odd : bool_< ( N::value % 2 ) > {}; typedef copy< range_c , inserter< // a filtering 'push_back' inserter vector<> , if_< is_odd<_2>, push_back<_1,_2>, _1 > > >::type odds; BOOST_MPL_ASSERT(( equal< odds, vector_c, equal_to<_,_> > )); See also -------- |Algorithms|, |Inserter|, |Reversible Algorithm|, |front_inserter|, |back_inserter| .. |+inserter+| replace:: inserter .. |inserter| replace:: |``inserter``|__ .. |``inserter``| replace:: :refentry:`inserter` __ `inserter_`_