версия 1: < /p>
Код: Выделить всё
template
concept arithmetic = requires {
std::is_arithmetic_v;
};
< /code>
версия 2: < /p>
template
concept arithmetic = 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>
'Добавить': не найдена соответствующая перегруженная функция < /p>
< /blockquote>
Согласно стандарту C ++, простое требование в предложении только для этого. /> Почему здесь терпит неудачу, основанный на требуемых? Как я могу согласовать определение концепции с предполагаемым поведением книги?
Подробнее здесь: https://stackoverflow.com/questions/796 ... c-v-fail-t
Мобильная версия