версия 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>
'Добавить': не найдено соответствующая функция перегруженного Значение.
Почему требуется подход к Подробнее здесь: https://stackoverflow.com/questions/796 ... c-v-fail-t
Мобильная версия