模板类型的 C++ 模板特化

Ken*_*han 5 c++ templates traits

我希望通过使用 BOOST_STATIC_ASSERT 来帮助我的一些模板代码的用户,让他们知道他们使用了不兼容的类型,其编译错误消息比当前使用不兼容类型生成的怪物更简单。

这个例子有点太复杂了,无法在这里重现,但希望这能抓住我想要的本质:

我的问题是如何格式化最后一行“模板模板”?

template <typename P1, int P2, typename P3> 
class InterestingType

{
}

template<typename T>
struct is_interesting_type{
 static const bool value = false;
};

template<template<typename,int,typename> typename InterestingType> //No idea how to format this..
struct is_interesting_type{
 static const bool value = true;
};
Run Code Online (Sandbox Code Playgroud)

Par*_*eep 3

将代码更改为

template <typename P1, int P2, typename P3> 
struct is_interesting_type<InterestingType<P1, P2, P3> >{
 static const bool value = true;
};
Run Code Online (Sandbox Code Playgroud)