Members

Contents

First element (first)

The first element an ntuple<> contains can be directly accessed as its first member. The type of this member can be obtained with the tuples first_type typedef member.

ntuple< int, double > tuple( 1, 1.2 );
ntuple< int, double >::first_type first( 1 );

CHECK( tuple.first == 1 && tuple.first == first );

std::cout << tuple << ".first = " << tuple.first << std::endl;

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

(1,1.2).first = 1

Remainder Tuple (remainder())

The remainder tuple (all elements except the first) can be accessed with the remainder() member function. The type of this tuple can be obtained from the tuples remainder_type typedef member.

ntuple< int, double, char > tuple( 1, 1.2, 'a' );
ntuple< int, double, char > ::remainder_type remainder( 1.2, 'a' );

CHECK( tuple.remainder() == remainder && remainder == ntuple_( 1.2, 'a' ) );

std::cout << tuple << ".remainder() = " << tuple.remainder() << std::endl;

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

(1,1.2,a).remainder() = (1.2,a)

No of elements (size())

The number of elements that a ntuple<> contains can be obtained from it size() static member function.

typedef ntuple< int, int > int2_t;

CHECK( int2_t::size() == 2 );

int2_t tuple( 1, 2 );

CHECK( tuple.size() == 2 );

std::cout << tuple << ".size() = " << tuple.size() << std::endl;

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

(1,2).size() = 2

ntuple<> also has a static member static_size as it is an intergral constant value, this can be used at compile time,

typedef ntuple< int, int > int2_t;

CHECK( int2_t::static_size == 2 );

int2_t tuple( 1, 2 );

char const *dest;
ntuple< int, int, char const *> three( 1, 2, "xxx" );
three >> tuple.skip< int2_t::static_size >() >> dest;

CHECK( dest == three.at<2>() );

std::cout << dest << std::endl;

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

xxx

See Also

ntuple<>'s skip<>() member is documented in Extracting Elements.

ntuple<>'s cat<> and cat_tuple<> member types are documented in Tuples with more than 8 elements.

Meta-type members are here.