[英]Is there any proposal to uniformize function type qualifiers and simplify abominable function types?
在处理基于函数类型匹配的模板时, 可恶的函数类型组合可能是一个真正的痛苦(参见std::is_function )。
各种限定符,包括 const、volatile、&、&&、noexcept(加上可变参数支持)可能会导致大量的模板特化。
但是, noexcept
说明符允许使用布尔表达式noexcept(expr)
:
noexcept
等价于noexcept(true)
作为默认值所以,在未来,我们能不能想象用这个模型统一所有的限定词:
const
限定符将等同于const(true)
volatile
限定符将等同于volatile(true)
&
限定符将等同于&(true)
&&
限定符将等同于&&(true)
而且,锦上添花,使预选赛免赔额能够写出如下内容:
template <typename Fn>
struct function_traits;
template <typename R, bool CQ, bool VQ, bool LVRQ, bool RVRQ, bool NEQ, ARGS... Args>
struct function_traits<R(Args...) const(CQ) volatile(VQ) &(LVRQ) &&(RVRQ) noexcept(NEQ)>
{
static constexpr bool is_const_qualified = CQ;
static constexpr bool is_volatile_qualified = VQ;
static constexpr bool is_lvalue_ref_qualified = LVRQ;
...
};
我想听听有关此类问题的任何想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.