I am going through the custom implementation for tuples , which is described in C++ template second edition.
I need a help to understand how the pushFront actually work. What are the steps that compiler does in order to put the new element in the start of the tuple
template <typename... Elements>
class Typelist
{
};
template <typename... Elements, typename NewElement>
class PushFrontT<Typelist<Elements...>, NewElement> {
public:
using Type = Typelist<NewElement, Elements...>;
};
template <typename List, typename NewElement>
using PushFront = typename PushFrontT<List, NewElement>::Type;
template <typename... Types, typename V>
PushFront<Tuple<Types...>, V>
pushFront(Tuple<Types...> const& tuple, V const& value)
{
return PushFront<Tuple<Types...>, V>(value, tuple);
}
In the above piece of code, how actually , does the last line work?
"PushFront<Tuple<Types...>, V>(value, tuple);"
How from PushFront<Tuple<Types...>, V> , we get a tuple in which pass as head the value and as tail the existing tuple?