Код: Выделить всё
#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>
ошибка: < /p>
:67:15: error: call to 'h' is ambiguous
67 | static_assert(h() == 2); // error (why is this not resolved even after p2963?)
| ^~~~~~~~~
образно пакет параметров эквивалентны, а арифметика submers floating_point .
Я не знаю, почему именование сгиба>
Подробнее здесь: https://stackoverflow.com/questions/795 ... lang-trunk