Suppose we have the following code:
template<typename T>
class C
{};
template <typename T, template <typename> class Container>
void dummyMe(Container<T>&&)
{};
int main(int argc, char* argv[])
{
C<int> c;
dummyMe(c);
return 0;
}
Which doesn't compile due to the first dummyMe
argument being an rvalue-reference. Could someone explain me in Standardese why the template template parameters are not getting along with the forwarding references and why is it so in plain English.
P.S. I've stumbled on this and that questions but I do not see any real proofs in the answers.
An answer from the link above and the answer to this question assert that Container<T>
can't be counted as a template parameter. And I see no reason why it is so. Let's make the example even simpler:
template <template <typename=int> class Container>
void dummyMe(Container<>&&)
{};
Now we have an example almost identical to the following:
template <typename Container>
void dummyMe(Container&&)
{};
But which is treated in a completely different fashion. Why? Why is Container<>&&
can't be considered as the same thing to template <typename=int> class Container
as Container&&
to typename Container
?