下面的代码
template <class Integral>
using enable_if_integral_t = typename std::enable_if<std::is_integral<Integral>::value>::type;
template <class Integral, class Enable = void>
class DigitsNumber;
template <class Integral>
class DigitsNumber<Integral, enable_if_integral_t<Integral>>{
};
在 MSVC 2013 中生成错误:
error C3203: 'enable_if_integral_t' : unspecialized alias template can't be used as a template argument for template parameter 'Enable', expected a real type
但在 gcc 中编译良好。
此代码是否符合 C++11 标准,以及 Visual Studio 错误/未实现的功能,或者它不符合标准,而是 gcc 扩展。
有什么方法可以让这个在 VS 中工作吗?
谢谢。
最佳答案
template <class Integral>
struct MSVCWorkaround : std::enable_if<std::is_integral<Integral>::value, SomeType> {};
template <class Integral>
using enable_if_integral_t = typename MSVCWorkaround<Integral>::type;
关于c++ - Visual Studio 2013 模板别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20828846/