I just ran into a problem with MSVC (version 12 Update 5):
An explicit copy of a template function is not performed if this function has an overload that is disabled via SFINAE. However, calling this function (thus the implication creating the instance) works.
Code example:
#include <type_traits>
template <typename T>
std::enable_if_t< std::is_integral<T>::value,
void> foo( T& ) {}
template <typename T>
std::enable_if_t< std::is_pointer<T>::value,
void> foo( T& ) {}
void bar( )
{
int i;
foo( i );
}
template void foo( int& );
Compiler Error: error C2794: 'type' : is not a member of any direct or indirect base class of 'std::enable_if<false,void>'. The same code looks great with GCC (except for the lack of the main function): live on Ideone .
Is this an MSVC error? Is there any way to make these explicit template instances?
source
share