Visual Studio 2013 template alias

1.2k views Asked by At

The following code

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>>{
};

Generates error in 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

But compiles fine in gcc.

Is this code conforming with the C++11 standard, and a Visual Studio bug/unimplemented feature, or it's not conforming with the standard, but a gcc extension.

Is there any way to make this work in VS?

Thank you.

1

There are 1 answers

0
Azoth On

I was able to work around this using the link that dyp provided:

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;