有没有统一函数类型限定符和简化可恶的函数类型的建议?

Is there any proposal to uniformize function type qualifiers and simplify abominable function types?

abominable function types combinatory can be a real pain when dealing with template based on function type matching (see std::is_function).

包括 const、volatile、&、&&、noexcept(加上可变参数支持)在内的其他限定符可能会导致大量模板特化。

但是,noexcept 说明符允许使用布尔表达式 noexcept(expr):

所以,在未来,我们可以想象用这个模型来统一所有限定符:

而且,锦上添花,使预选赛可扣除,以便能够写出类似的东西:

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;
    ...
};

我想听听关于此类问题的任何想法。

我之前在 std-proposals 邮件列表上提出了类似的建议。查看线程 here and here

从这次讨论中得出的结论是,向该语言添加这样的功能将需要大量工作。不仅需要在语言中添加规则以推导限定符的布尔参数,而且还会有许多其他问题,例如实例化和评估限定符的点。这种规模的提案也可能会引入许多其他必须敲定的问题。

Gašper Ažman 似乎相信某种形式的 "computed deduction" 将是更可行的问题替代解决方案。如果您有兴趣帮助完成这项工作,那么我建议您联系他。