Forward an element of a tuple
Consider the following code:
template <unsigned int Index, class Tuple, class Type = /* Something1 */>
Type forward(Tuple&& tuple)
{
return /* Something2 */;
}
I would like to find what is the correct syntax of /* Something1 */ and /*
Something2 */ in order to forward the element specified by Index of the
input tuple. I know that other conceptions/syntax would be available, but
in order to understand correctly how things work in such a context
(consider this as an academic exercice), I would like an answer that
satisfy the following conditions:
no overload for different cases: there will be only one function forward
no change except /* Something1 */ and /* Something2 */ (and maybe on the
return type if it should be Type&& instead of Type)
metaprogramming crazyness, decltype and std::declval are accepted
For example, if tuple = std::tuple<char, int, double>, forward<2>(tuple),
should forward the third element (the double).
No comments:
Post a Comment