So I'm trying to figure out how this works: C++11: I can go from multiple args to tuple, but can I go from tuple to multiple args?
The piece of black magic I do not understand is this code fragment:
f(std::get<N>(std::forward<Tuple>(t))...)
it's the expression inside f
that I don't understand.
I understand that the expression somehow unpacks/expands what's inside t
into a list of arguments. But could someone care to explain how this is done? When I look at the definition of std::get
(http://en.cppreference.com/w/cpp/utility/tuple/get), I don't see how N
fits in...? As far as I can tell, N is a sequence of integers.
Based on what I can observe, I'm assuming that expressions in the form E<X>...
where X
is the sequence of types X1
. X2
, ... Xn
, the expression will be expanded as E<X1>, E<X2> ... E<Xn>
. Is this how it works?
Edit: In this case N is not a sequence of types, but integers. But I'm guessing this language construct applies to both types and values.
See Question&Answers more detail:os