Quick Links: |
Metafunction to return the Nth type parameter in a parameter pack. More...
Namespaces | |
namespace | bslmf |
tuple
that need access to a specific element of a parameter pack. tuple
-like class that holds a heterogeneous collection of elements, each of which might have a different type. The metafunction, my_tuple_element<I, my_tuple<ELEMS...>>Type
would be type of the I
th element in the tuple (where I
is zero-based). my_tuple
class template. The body of the class is unimportant for this usage examples: template <class... ELEMS> class my_tuple { // ... };
bslmf::NthParameter
to implement my_tuple_element
: #include <bslmf_nthparameter.h> template <std::size_t I, class TUPLE> struct my_tuple_element; // Not defined template <std::size_t I, class... ELEMS> struct my_tuple_element<I, my_tuple<ELEMS...> > { typedef typename bslmf::NthParameter<I, ELEMS...>::Type Type; };
bsl::is_same
: #include <bslmf_issame.h> int main() { typedef my_tuple<int, short, char*> ttype; assert((bsl::is_same<int, my_tuple_element<0, ttype>::Type>::value)); assert((bsl::is_same<short, my_tuple_element<1, ttype>::Type>::value)); assert((bsl::is_same<char *, my_tuple_element<2, ttype>::Type>::value)); assert(! (bsl::is_same<short, my_tuple_element<0, ttype>::Type>::value)); }