相关疑难解决方法(0)

在早期检测习语实现中使用void template参数

n4502中,作者描述了封装void_t技巧的检测习语的早期实现.这是它的定义以及用于定义特征的用法is_assignable(实际上它是is_copy_assignable)

template<class...>
using void_t = void;

// primary template handles all types not supporting the operation:
template< class, template<class> class, class = void_t< > >
struct
detect : std::false_type { };
// specialization recognizes/validates only types supporting the archetype:
template< class T, template<class> class Op >
struct
detect< T, Op, void_t<Op<T>> > : std::true_type { };

// archetypal expression for assignment operation:
template< class T >
using
assign_t = decltype( std::declval<T&>() = …
Run Code Online (Sandbox Code Playgroud)

c++ language-lawyer template-meta-programming c++17

7
推荐指数
1
解决办法
325
查看次数