Why the template with default template arguments can't be used as template with less template argument in Template Template Parameters

Viewed 826

myTemplateTemplate expects the second template parameter is a template with one argument. myDefaultTemplate is a template with two arguments, and the second argument has default type int.

In VS2008, I get the compile error:the template parameter list for class template 'myDefaultTemplate' does not match the template parameter list for template parameter 'TT'

So,why the myDefaultTemplate can't be used as the template with just one argument? Are there any negative impact if C++ compiler supports it?

template
<typename T1, typename T2 = int>
class
myDefaultTemplate{
      T1 a;
      T2 b;
};

template
<typename T1, template<typename T2> class TT>
class
myTemplateTemplate{
      T1 a;
      TT<T1> b;
};

int main(int argc, char* argv[]){
      myTemplateTemplate<int, myDefaultTemplate> bar; //error here:      
      return 0;
}
1 Answers
Related