#include #include #include #include #include using namespace std; using namespace boost::assign; template< class U > U return_pop( vector< U >& vec ) { U value = vec.back(); vec.pop_back(); return value; } template< class U > boost::function< U (void) > create_block( vector< U >& vec ) { return boost::bind( return_pop< U >, vec ); } int main() { vector< int > vec1; vec1 += 1, 2, 3, 4; boost::function< int (void) > f = create_block< int >( vec1 ); cout << f() << "," << f() << endl; return 0; }