#include <string>
template
<
typename CharType,
template<class, class, class> class StringType = std::basic_string
<CharType, std::char_traits<CharType>, std::allocator<CharType>>
>
void f(CharType, StringType)
{}
int main()
{
char c;
std::string str;
f(c, str);
//
// error : default template argument for
// a template template parameter must be a class template
//
}
为什么不能template template parameter
被默认?为什么不能默认模板模板参数?
如果你读了错误消息,它说, “模板模板参数必须是***类模板***”。 * std :: basic_string *本身就是一个类模板。 'std :: basic_string,std :: allocator >'*不是*模板,它是从'std :: basic_string'模板派生的具体类。 –