Pot*_*ter 10 c++ templates language-lawyer
GCC,Clang,ICC和MSVC都拒绝此代码,但我没有在C++标准的最新工作草案中找到任何违反规则.
规则是否已经在标准中,还是在缺陷报告中?
#include <type_traits>
template< typename t >
struct s {
std::conditional_t< std::is_integral< t >::value, t, void() > mem;
};
s< int > a;
s< void * > b;
Run Code Online (Sandbox Code Playgroud)
由于14.3.1/3,代码无效:
如果声明通过依赖于template-parameter的类型获取函数类型,并且这导致不使用函数声明符的语法形式的声明具有函数类型,则该程序是格式错误的.
此处声明的类型取决于模板参数t
,因此不能是函数类型.
归档时间: |
|
查看次数: |
85 次 |
最近记录: |