MSVC chokes on template metaprograms

I'm getting an error in Visual Studio but not GCC or Clang. I have already tried my best to reduce the complexity of the code, but it is quite complicated because of how I backed myself into a corner (and I wrote this a long time ago).

GCC succeeds: http://coliru.stacked-crooked.com/a/6003825ba90f9d97
clang succeeds: http://coliru.stacked-crooked.com/a/c4e6e1b740a011fc
MSVC 2015 fails with an unhelpful and confusing error:
main.cpp(284): error C2893: Failed to specialize function template 'std::enable_if<==(std::is_void<R>::value,std::conditional<std::is_void<R>::value,std::common_type<R>,hSDK::Extension::Enforce32bit<R,void>>::type::type(__thiscall ExtT::* )(Enforce32bit<Args...,void>::type)>::type hSDK::Extension::ExtMF<Action>::verify(R (__thiscall ExtT::* )(Args...))'
main.cpp(284): note: With the following template arguments:
main.cpp(284): note: 'ExtT=TestExtension'
main.cpp(284): note: 'R=void'
main.cpp(284): note: 'Args={}'
c:\tools_root\cl\inc\utility(145): note: see reference to function template instantiation 'hSDK::Extension::ExtMF<Action>::ExtMF<TestExtension,void,>(R (__thiscall TestExtension::* )(void))' being compiled
        with
        [
            R=void
        ]
c:\tools_root\cl\inc\utility(145): note: see reference to function template instantiation 'hSDK::Extension::ExtMF<Action>::ExtMF<TestExtension,void,>(R (__thiscall TestExtension::* )(void))' being compiled
        with
        [
            R=void
        ]
main.cpp(374): note: see reference to function template instantiation 'std::pair<const _Kty,_Ty>::pair<int,void(__thiscall TestExtension::* )(void),void>(_Other1 &&,_Other2 &&) noexcept(false)' being compiled
        with
        [
            _Kty=hSDK::Extension::ACE_ID_t,
            _Ty=hSDK::Extension::ActionMF,
            _Other1=int,
            _Other2=void (__thiscall TestExtension::* )(void)
        ]
main.cpp(374): note: see reference to function template instantiation 'std::pair<const _Kty,_Ty>::pair<int,void(__thiscall TestExtension::* )(void),void>(_Other1 &&,_Other2 &&) noexcept(false)' being compiled
        with
        [
            _Kty=hSDK::Extension::ACE_ID_t,
            _Ty=hSDK::Extension::ActionMF,
            _Other1=int,
            _Other2=void (__thiscall TestExtension::* )(void)
        ]
At this point I don't know if my code is invalid or if MSVC has a bug. Can anyone take a look and see if you understand why MSVC doesn't like the code? I think it has something to do with the function on line 303.
Last edited on
It's probably a bug in the standard library. MS doesn't have a very good track record in that regard.

What's this supposed to do, anyway?
It's supposed to connect real C++ member functions to an ancient C library where you have to ask for individual parameters by calling functions. The template metaprograms make sure the C++ member function only takes supported parameter types and at runtime it pulls the parameters and calls the function when needed. Most of that is stripped out though.

I'm going to look into submitting this to their issue tracker.
Topic archived. No new replies allowed.