【发布时间】:2019-11-20 21:59:58
【问题描述】:
我正在尝试用 gcc 和 clang 编译这段代码:
#include <iostream>
#include <type_traits>
template<int N>
struct Test
{
template<typename = std::enable_if_t<N == 1, bool>>
void func()
{
std::cout << "Test::func" << std::endl;
}
};
int main()
{
Test<0> t;
//t.func();
}
所以,我有一个错误:
error: no type named 'type' in 'std::__1::enable_if<false, bool>'; 'enable_if' cannot be used to
disable this declaration
template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
但是,如果我使用 vc++ 编译该代码,则不会出现错误。 那么,哪个编译器根据 c++ 标准解决了这个问题?
【问题讨论】:
标签: c++ gcc visual-c++ clang