小编ali*_*ali的帖子

使用bool类型的强枚举(C++ 11)模板bool参数失败,为什么?

enum class test : bool { yes=true, no=false };

template< bool ok >
class A {
};

int main(){
A<test::yes> a;
}
Run Code Online (Sandbox Code Playgroud)

为什么编译失败?(g ++ 4.7)由于C++ 11枚举是强类型的,所以我们应该能够将bool枚举用作模板类型的bool参数吗?

c++ enums c++11

2
推荐指数
1
解决办法
3986
查看次数

标签 统计

c++ ×1

c++11 ×1

enums ×1