I have some difficulties with perfect shipment.
Here is my current level of understanding: Template + rvalue reference + std :: forward glue and special magic mode are activated when the rules for deducting templates do not have the same meaning as usual, but are created for perfect transfer. Example:
template <typename T> void outer(T&& t) { inner(std::forward<T>(t));
But what happens if T is actually a template? For example, how can I improve the formatting of std :: tuple? If I use T && as an aboce, I lose all information about the type of objects contained in the tuple.
However, the following code may not work:
template <typename... Args> void outer(std::tuple<Args...>&& t) { inner(std::forward<std::tuple<Args...>>(t)); use_args_types_for_something_else<Args...>();
The last gcc snapshot says:
error: cannot bind 'std::tuple<int, double, float> lvalue to std::tuple<int, double, float>&&
So, we are still in the general case without templates, where the lvalue cannot communicate with the rvalue reference. "Perfect forward mode" is not activated
So, I tried to hide and pass my tuple as a template template:
template < typename... Args template <typename...> class T > void outer(T<Args...>&& t) { inner(std::forward<T<Args...>>(t)); use_args_type_for_something_else<Args...>(); }
But I still get the same error.