- 论坛徽章:
- 0
|
下面几行代码,编译不过:
- #include<functional>
- #include<iostream>
- #include<type_traits>
- using namespace std;
- class M{
- public:
- int foo(){cout<<"1\n";}
- };
- template<typename enable_if<is_pod<M>::type>>
- void g(){}
- int main(){return 0;}
复制代码 gcc编译提示:
type/value mismatch at argument 1 in template parameter list for 'template<bool <anonymous>, class _Tp> struct std::enable_if'
expected a constant of type 'bool', got 'std::integral_constant<bool, false>::type {aka std::integral_constant<bool, false>}'
这是什么错误呢?
我希望的是,M是POD的时候,对于g的调用才是有效的,否则应该报错。
现在M是POD,没问题,为什么还报错呢?
|
|