Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2013 template alias

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.

like image 367
bolov Avatar asked Mar 23 '26 15:03

bolov


1 Answers

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;
like image 140
Azoth Avatar answered Mar 25 '26 03:03

Azoth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!