
"Eric Zijlstra" <ezijlstra@programmer.net> wrote in message news:d4un8k$tvr$1@sea.gmane.org... |I was looking for a convinient way to have variabele arguments for functions | and avoiding the memory allocations and copying that come with std | containers. I didn't find such a container so I hacked one together myself. | // usage example: | | void print(StackArg<const int> s) // outputs 345 | { | StackArg<const int>::iterator i= s.begin(), e=end(); | while(i!=e) cout << *i++; | } | | void test() | { | print( StackArg<const int>() + 3 + 4 +5 ); | } boost.assign features a new function that does just this: template< class Range > void print( const Range& s) // outputs 345 { typename Range::iterator i= s.begin(), e=end(); while(i!=e) cout << *i++; } void test() { print( boost::assign::cref_list_of<3>( 3 )( 4 )( 5 ) ); } there is also ref_list_of<N>() if you need to pass non-const references. The implementation uses an array of pointers and is as fast as possible IMO. -Thorsten