#include <concepts>
#include <type_traits>
template <std::signed_integral T>
std::make_unsigned_t<T> unsign(T x) {
return x;
}
int main() {
unsign(42);
unsign(42.);
}
Почему 2 вызов не компилируется из-за ошибки в std::make_unsigned_t<T>
, а не из-за несоответствия типа концепту? Как исправить?
error: implicit instantiation of undefined template 'std::__make_unsigned_selector<double, false, false>' { typedef typename __make_unsigned_selector<_Tp>::__type type; };
instantiation of template class 'std::make_unsigned<double>' requested here using make_unsigned_t = typename make_unsigned<_Tp>::type;
candidate: 'template<class T> requires signed_integral<T> std::make_unsigned_t<T> foo(T)'
/constraints not satisfied
/т.п.std::make_unsigned_t<T>
на простоT
, то будет ожидаемая ошибка