Warum wurde dieser C ++ - Code in Clang Trunk abgelehnt?
Posted: 10 Apr 2025, 01:11
Code: Select all
#include
template
concept floating_point = std::is_floating_point_v;
template
concept integral = std::is_integral_v;
template
concept arithmetic = floating_point || integral;
// ------------------------------------
template
constexpr int f() {
return 1;
}
template
constexpr int f() {
return 2;
}
// ------------------------------------
template
requires(arithmetic && ...)
constexpr int g() {
return 1;
}
template
requires(floating_point && ...)
constexpr int g() {
return 2;
}
// ------------------------------------
template
concept all_arithmetic = (arithmetic && ...);
template
concept all_floating_point = (floating_point && ...);
template
requires all_arithmetic
constexpr int h() {
return 1;
}
template
requires all_floating_point
constexpr int h() {
return 2;
}
// ------------------------------------
static_assert(f() == 1); // ok
static_assert(f() == 2); // ok
static_assert(g() == 1); // ok
static_assert(g() == 2); // ok
static_assert(h() == 1); // ok
static_assert(h() == 2); // error (why is this not resolved even after p2963?)
int main() {}
< /code>
Fehler: < /p>
:67:15: error: call to 'h' is ambiguous
67 | static_assert(h() == 2); // error (why is this not resolved even after p2963?)
| ^~~~~~~~~
Wenn ich aktuelle Entwurf und p2963r3 richtig gelesen habe Pack sind äquivalent und arithmetische Subsumes floating_point .>