【发布时间】:2015-08-29 12:14:39
【问题描述】:
给定一个任意模板类/结构,就像:
template <typename T>
struct A {};
我想执行<type_traits> 时尚检查(我们将其命名为_A)以确定任意类型是否是A的特化强与否,就像:
#include <type_traits>
template <typename T>
struct is_A: std::integral_constant<bool, /* perform the check here */ > {};
constexpr bool test0 = is_A< A<int> >::value // true
constexpr bool test1 = is_A< A<float> >::value // true
constexpr bool test2 = is_A< int >::value // false
constexpr bool test2 = is_A< float >::value // false
怎么可能?
提前致谢
【问题讨论】:
标签: c++ templates c++11 template-specialization