Is this valid template construct in C++ templates?
template < template <typename T2> class T>
void foo() {
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. It is valid.
You can call this function with any class template which takes exactly one template parameter. For example,
Note that you don’t have to provide the template argument for
Aclass template, which means, the following would result in compilation error:Also, in your code
T2is optional, and in fact, you cannot use it in the function, so better remove it to make the definition simpler:Demo : http://ideone.com/8jlI5