Front Page / Algorithms / Inserters / inserter |
template< typename State , typename Operation > struct inserter { typedef State state; typedef Operation operation; };
A general-purpose model of the Inserter concept.
#include <boost/mpl/inserter.hpp>
Parameter | Requirement | Description |
---|---|---|
State | Any type | A initial state. |
Operation | Binary Lambda Expression | An output operation. |
The semantics of an expression are defined only where they differ from, or are not defined in Inserter.
For any binary Lambda Expression op and arbitrary type state:
Expression | Semantics |
---|---|
inserter<op,state> | An Inserter. |
Amortized constant time.
template< typename N > struct is_odd : bool_< ( N::value % 2 ) > {}; typedef copy< range_c<int,0,10> , 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<int,1,3,5,7,9>, equal_to<_,_> > ));