версия 1: < /p>
Код: Выделить всё
template
concept arithmetic = requires {
std::is_arithmetic_v;
};
< /code>
версия 2: < /p>
template
concept arithmetic = requires { std::is_arithmetic_v; };
< /code>
Однако первая версия: < /p>
#include
#include
#include
template
concept arithmetic = requires
{
std::is_arithmetic_v;
};
template
requires arithmetic
T add(T const a, T const b) { return a + b; }
int main() {
add("a", "b");
}
Но следующая версия
#include
#include
#include
template
concept arithmetic = std::is_arithmetic_v;
template
requires arithmetic
T add(T const a, T const b) { return a + b; }
int main() {
add("a", "b");
}
< /code>
Те же компиляторы с одинаковыми флагами компиляции говорили мне: «Добавить»: не найдена совпадающая перегруженная функция < /p>
Согласно стандарту C ++, простое требование в предложении требует только для проверки. Как я могу согласовать определение концепции с предполагаемым поведением книги?
Подробнее здесь: https://stackoverflow.com/questions/796 ... c-v-fail-t
Мобильная версия