typedef boost::tuple<int,std::string,int> tuple; vector<tuple> v = tuple_list_of( 1, "foo", 2 )( 3, "bar", 4 ); BOOST_CHECK( v.size() == 2 ); BOOST_CHECK( boost::get<0>( v[1] ) == 3 );
C++ (Qt)template<typename T>class MyVector : public QVector<T>{public: template< class InputIt > MyVector<T>( InputIt first, InputIt last ) { this->reserve( std::distance( first, last ) ); for( InputIt it = first; it != last; ++it ) this->append( *it ); }}; int main( int argc, char *argv[] ){ typedef boost::tuple<int,std::string,int> tuple; MyVector<tuple> v = tuple_list_of( 1, "foo", 2 )( 3, "bar", 4 ); BOOST_ASSERT( v.size() == 2 ); BOOST_ASSERT( boost::get<0>( v[1] ) == 3 );}
template< class Container > operator Container() const { return this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>(); }