2
我想做一个静态断言,检查类型A是否可以添加到类型B.是否有任何方法来检查模板类型A是否可添加到模板类型B编译时间? A和B真的可以做任何事情。静态断言是否可以添加操作
我想做一个静态断言,检查类型A是否可以添加到类型B.是否有任何方法来检查模板类型A是否可添加到模板类型B编译时间? A和B真的可以做任何事情。静态断言是否可以添加操作
随着is_detected,你可以这样做:
template <typename LHS, typename RHS>
using sum_t = decltype(std::declval<LHS>() + std::declval<RHS>());
template <typename LHS, typename RHS>
using has_sum = is_detected<sum_t, LHS, RHS>;
有趣的是,没有'is_detected_v'。尽管如此,还是可以做 'template
这取决于究竟你的意思_addable_。 –