§14.10.3N4553的约束[temp.constr.order] 的部分排序指定由概念和逻辑运算符组成的约束表达式应该部分排序并用于选择在超载的情况下最好的可行功能。但这是否也适用于使用逻辑运算符的折叠表达式的约束表达式?
例如,gcc是否正确以给出不明确的重载错误here或代码是否有效,打印“c”?
template <class T> concept bool A = std::is_move_constructible<T>::value;
template <class T> concept bool B = std::is_copy_constructible<T>::value;
template <class T> concept bool C = A<T> && B<T>;
template <class... _tx>
requires (A<_tx> && ...)
void g(_tx... tx) {
std::cout << "a\n";
}
template <class... _tx>
requires (C<_tx> && ...)
void g(_tx... tx) {
std::cout << "c\n";
}
f(3, 2.0)
答案 0 :(得分:3)
目前,在约束([temp.constr.order])的部分排序过程中,不会处理折叠表达式。
这可以通过指定原子约束P && ...
包含Q || ...
和Q && ...
iff P
包含Q
来解决。在这种情况下,很明显第一次过载的约束被第二次过载所包含,但反之亦然,这使得后者更受约束。
这将通过概念问题#28来解决。