更新时间:2023-11-10 19:48:22
你正在做的是禁止的部分§14.5.4/ 9说,
Actually what you're doing is forbidden by section §14.5.4/9 which says,
部分专用非类型参数除非参数表达式是简单标识符,否则表达式不应涉及部分专门化的模板参数。
诀窍可能是使用类型用于第二个模板参数, -type 值,如下所示:
The trick could be using a type for second template parameter as well, encapsulating the non-type value, as described below:
template<bool b> struct booltype {};
template<typename T, typename B = booltype<true> >
struct Resolve
{
static const bool value = false;
};
template<typename T>
struct Resolve<T, booltype<T::my_value> >
{
static const bool value = true;
};
现在编译罚款。