diff --git a/include/boost/assign/list_inserter.hpp b/include/boost/assign/list_inserter.hpp index 71a6124..b84be99 100755 --- a/include/boost/assign/list_inserter.hpp +++ b/include/boost/assign/list_inserter.hpp @@ -38,9 +38,6 @@ namespace assign_detail std::size_t sz; T val; - repeater( const repeater& r ) : sz( r.sz ), val( r.val ) - { } - repeater( std::size_t sz, T r ) : sz( sz ), val( r ) { } }; @@ -51,9 +48,6 @@ namespace assign_detail std::size_t sz; Fun val; - fun_repeater( const fun_repeater& r ) : sz( r.sz ), val( r.val ) - { } - fun_repeater( std::size_t sz, Fun r ) : sz( sz ), val( r ) { } }; @@ -63,9 +57,6 @@ namespace assign_detail { C& c_; public: - call_push_back( const call_push_back& r ) : c_( r.c_ ) - { } - call_push_back( C& c ) : c_( c ) { } @@ -81,9 +72,6 @@ namespace assign_detail { C& c_; public: - call_push_front( const call_push_front& r ) : c_( r.c_ ) - { } - call_push_front( C& c ) : c_( c ) { } @@ -99,9 +87,6 @@ namespace assign_detail { C& c_; public: - call_push( const call_push& r ) : c_( r.c_ ) - { } - call_push( C& c ) : c_( c ) { } @@ -117,9 +102,6 @@ namespace assign_detail { C& c_; public: - call_insert( const call_insert& r ) : c_( r.c_ ) - { } - call_insert( C& c ) : c_( c ) { } @@ -130,6 +112,28 @@ namespace assign_detail } }; + template< class C > + class call_add_edge + { + C& c_; + public: + call_add_edge( C& c ) : c_(c) + { } + + template< class T > + void operator()( T l, T r ) + { + add_edge( l, r, c_ ); + } + + template< class T, class EP > + void operator()( T l, T r, const EP& ep ) + { + add_edge( l, r, ep, c_ ); + } + + }; + struct forward_n_arguments {}; } // namespace 'assign_detail' @@ -363,6 +367,13 @@ namespace assign return make_list_inserter( assign_detail::call_push( c ), p ); } + + template< class C > + inline list_inserter< assign_detail::call_add_edge > + add_edge( C& c ) + { + return make_list_inserter( assign_detail::call_add_edge( c ) ); + } } // namespace 'assign' } // namespace 'boost' diff --git a/include/boost/assign/list_of.hpp b/include/boost/assign/list_of.hpp index 7b38ca9..c135b58 100755 --- a/include/boost/assign/list_of.hpp +++ b/include/boost/assign/list_of.hpp @@ -143,13 +143,6 @@ namespace assign_detail #include BOOST_PP_LOCAL_ITERATE() - template< class U > - generic_list& operator,( U u ) - { - this->push_back( u ); - return *this; - } - template< class U > generic_list& repeat( std::size_t sz, U u ) { @@ -315,6 +308,13 @@ namespace assign return assign_detail::generic_list< std::pair >()( k, t ); } + template< class F, class S > + inline assign_detail::generic_list< std::pair > + pair_list_of( F f, S s ) + { + return assign_detail::generic_list< std::pair >()( f, s ); + } + } // namespace 'assign' } // namespace 'boost' diff --git a/test/TODO b/test/TODO index 2920129..37e3046 100755 --- a/test/TODO +++ b/test/TODO @@ -12,3 +12,21 @@ 6: find conversion problem in g++ with nested list_of(). 7. add repeat etc to header overview. + +8. Consider optimising generic_list to store only references + to the object in the list. Even if compound objects are + stored, then maybe tuples of opetional can be stored + and construction deferred until the conversion to a + container is needed. A special iterator could construct + the objects on demand + +9. The decay problem should be solved once and for all by something like + + template< class T > + generic_list< decay_array::type > list_of( const T& ); + + or decay_traits::type + +10. Consider adding list_of and iterable_list_of to complement each other. + However, for tight code, list_of<7> works pretty well and provides + random_access iterators. recursive_list_of(2)(6); diff --git a/test/array.cpp b/test/array.cpp index 1178f5d..bc4d338 100755 --- a/test/array.cpp +++ b/test/array.cpp @@ -35,25 +35,25 @@ void check_array() #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - Array a = (list_of(1),2,3,4,5,6).to_array(a); + Array a = list_of(1)(2)(3)(4)(5)(6).to_array(a); #else - Array a = (list_of(1),2,3,4,5,6); + Array a = list_of(1)(2)(3)(4)(5)(6); #endif BOOST_CHECK_EQUAL( a[0], 1 ); BOOST_CHECK_EQUAL( a[5], 6 ); // last element is implicitly 0 #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - Array a2 = (list_of(1),2,3,4,5).to_array(a2); + Array a2 = list_of(1)(2)(3)(4)(5).to_array(a2); #else - Array a2 = (list_of(1),2,3,4,5); + Array a2 = list_of(1)(2)(3)(4)(5); #endif BOOST_CHECK_EQUAL( a2[5], 0 ); // two last elements are implicitly #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - a2 = (list_of(1),2,3,4).to_array(a2); + a2 = list_of(1))(2)(3)(4).to_array(a2); #else - a2 = (list_of(1),2,3,4); + a2 = list_of(1)(2)(3)(4); #endif BOOST_CHECK_EQUAL( a2[4], 0 ); BOOST_CHECK_EQUAL( a2[5], 0 ); diff --git a/test/list_of.cpp b/test/list_of.cpp index 4fbe523..763c1d3 100755 --- a/test/list_of.cpp +++ b/test/list_of.cpp @@ -65,7 +65,7 @@ void test_sequence_list_of_int() #if BOOST_WORKAROUND(BOOST_MSVC, <=1300) const C c = ba::list_of(1)(2)(3)(4).to_container( c ); - const C c2 = (ba::list_of(1),2,3,4).to_container( c2 ); + const C c2 = ba::list_of(1)(2)(3)(4).to_container( c2 ); BOOST_CHECK_EQUAL( c.size(), 4u ); BOOST_CHECK_EQUAL( c2.size(), 4u ); C c3 = ba::list_of(1).repeat( 1, 2 )(3).to_container( c3 ); @@ -77,7 +77,7 @@ void test_sequence_list_of_int() #else const C c = ba::list_of(1)(2)(3)(4); - const C c2 = (ba::list_of(1),2,3,4); + const C c2 = ba::list_of(1)(2)(3)(4); BOOST_CHECK_EQUAL( c.size(), 4u ); BOOST_CHECK_EQUAL( c2.size(), 4u ); C c3 = ba::list_of(1).repeat( 1, 2 )(3);