BDE 4.14.0 Production release
|
Metafunction to return the Nth type parameter in a parameter pack
bslmf::NthParameter<t_N, PARAM_0, t_PARAMS...>
This component contains a metafunction that treats a parameter pack of types as compile-time array of types, returning the Nth type (counting from zero). It is useful for implementing types like tuple
that need access to a specific element of a parameter pack.
We wish to implement a 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).
First, we define our my_tuple
class template. The body of the class is unimportant for this usage examples:
Then, we use bslmf::NthParameter
to implement my_tuple_element
:
Finally, we test this implementation using bsl::is_same
: