小编yva*_*ros的帖子

SFINAE专门针对CRTP结构的特征

我试图专门化一些特征(例如在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)

c++ crtp sfinae template-specialization c++11

2
推荐指数
1
解决办法
272
查看次数

标签 统计

c++ ×1

c++11 ×1

crtp ×1

sfinae ×1

template-specialization ×1