Код: Выделить всё
template
using result = std::conditional_t;
В качестве примера, в следующем коде std::make_unsigned_t требует, чтобы T было целым, поэтому компилятор сообщает, что T не является целым.
Код: Выделить всё
template
using make_unsigned_if_integral_t =
std::conditional_t;
// this works
static_assert(std::is_same_v);
// compiler complains on this
using expect_float = make_unsigned_if_integral_t;
Код: Выделить всё
// no constraints on T here, so custom_make_unsigned::type is valid (but never actually used)
template struct custom_make_unsigned {
template struct impl {
using type = U;
};
template struct impl {
using type = std::make_unsigned_t;
};
using type = typename impl::type;
};
template
using custom_make_unsigned_if_integral_t =
std::conditional_t;
static_assert(std::is_same_v);
Подробнее здесь: https://stackoverflow.com/questions/786 ... be-defined