3

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.

dyp
  • 38,334
  • 13
  • 112
  • 177
bolov
  • 72,283
  • 15
  • 145
  • 224
  • Might be related to these two bugs: [1) C++ 11 Alias Template Issue](http://connect.microsoft.com/VisualStudio/feedback/details/800231/c-11-alias-template-issue); [2) Alias template issue involving non-type template parameter and two levels of template aliasing](http://connect.microsoft.com/VisualStudio/feedback/details/808130/alias-template-issue-involving-non-type-template-parameter-and-two-levels-of-template-aliasing) You could submit the example to [Microsoft Connect](http://connect.microsoft.com/VisualStudio) – dyp Dec 29 '13 at 21:24

1 Answers1

1

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;
Community
  • 1
  • 1
Azoth
  • 1,652
  • 16
  • 24