我试图专门化一些特征(例如在cppunit中的std :: is_arithmetic或assertion_traits)用于模板类(CRTP),它可以保存模板参数类型的值(类似于BOOST_STRONG_TYPEDEF)
我尝试使用SFINAE限制我的专业化
示例代码适用于gcc6和upper,但不能使用Visual c + +编译(2015或2017)
error C2753: 'is_ar<T>': partial specialization cannot match argument list for primary template
Run Code Online (Sandbox Code Playgroud)
或clang6
error: class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list
Run Code Online (Sandbox Code Playgroud)
示例代码:
template<class T, typename B>
struct Base
{
using typed_type = T ;
using base_type = B ;
base_type x;
};
template <typename T>
struct MyType
{
using base_type = T;
base_type x;
};
struct CRTPInt …Run Code Online (Sandbox Code Playgroud)