【发布时间】:2014-10-11 07:33:39
【问题描述】:
我正在编写一个 SFINAE 匹配类,它可以匹配指向集合类型的指针。
我们目前有 std::is_pointer,我已经写了:
// SFINAE test for const_iterator for member type
template <typename T>
class has_const_iterator{
private:
typedef char True;
typedef long False;
template <typename C> static True test(typename C::const_iterator*) ;
template <typename C> static False test(...);
public:
enum { value = sizeof(test<T>(0)) == sizeof(char) };
};
如何在 std::enable_if 中同时使用 std::is_pointer 和 has_const_iterator 或者如何编写可以匹配指向集合类型的指针的新类型特征?谢谢。
【问题讨论】:
标签: c++ templates c++11 sfinae typetraits