c++ - template template parameters and forwarding references -
suppose have 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 first dummyme argument being rvalue-reference. explain me in standardese why template template parameters not getting along forwarding references , why in plain english.
p.s. i've stumbled on this , that questions not see real proofs in answers.
an answer link above , answer question assert container<t> can't counted template parameter. , see no reason why so. let's make example simpler:
template <template <typename=int> class container> void dummyme(container<>&&) {}; now have example identical following:
template <typename container> void dummyme(container&&) {}; but treated in different fashion. why? why container<>&& can't considered same thing template <typename=int> class container container&& typename container?
an answer link above , answer question assert
container<t>can't counted template parameter
what or not template parameter not subject interpretation. defined in [temp.param]:
template-parameter: type-parameter parameter-declaration type-parameter: type-parameter-key ...(opt) identier (opt) type-parameter-key identier(opt) = type-id template < template-parameter-list > type-parameter-key ...(opt) identier(opt) template < template-parameter-list > type-parameter-key identier(opt) = id-expression type-parameter-key: class typename it clear these production rules dummyme has 2 template parameters: typename t , template <typename> class container. identifiers name each of these parameters t , container. t names first parameter , container names second one. container<t> not identifier , names neither of two.
Comments
Post a Comment