建议here http://en.cppreference.com/w/cpp/types/is_function按以下方式实施:
template<class Ret, class... Args>
struct is_function<Ret(Args...)const> : std::true_type {};
template<class Ret, class... Args>
struct is_function<Ret(Args...)volatile> : std::true_type {};
但这是有效的函数语法吗? Visual Studio 2013 报错:
error C2270: 'abstract declarator' : modifiers not allowed on nonmember functions
The const
or volatile
函数参数之后称为cv-qualifier-seq。
C++14 标准第 8.3.5 节第 6 段说:
带有 cv-qualifier-seq 或 ref-qualifier 的函数类型(包括
由 typedef-name (7.1.3,14.1)) 命名的类型只能显示为:
— 非静态成员函数的函数类型,
— 指向成员的指针所指的函数类型,
— 函数 typedef 声明或别名声明的顶级函数类型,
— 类型参数的默认参数中的类型 ID (14.1),或者
— 类型参数的模板参数的类型 ID (14.3.1)。
在你的例子中,Ret(Args...)const
and Ret(Args...)volatile
满足最后一种情况。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)