forked from mpusz/mp-units
[msvc][fix] msvc complains about requires expression (no common type found) replace with concept has_common_type
This commit is contained in:
@@ -30,11 +30,22 @@
|
||||
|
||||
namespace mp_units::detail {
|
||||
|
||||
template <typename AlwaysVoid, typename... Ts>
|
||||
struct has_common_type_impl : std::false_type {};
|
||||
|
||||
template <typename... Ts>
|
||||
struct has_common_type_impl<std::void_t<std::common_type_t<Ts...>>, Ts...> : std::true_type {};
|
||||
|
||||
template <typename... Ts>
|
||||
using has_common_type = typename has_common_type_impl<void, Ts...>::type;
|
||||
|
||||
template <typename... Ts> constexpr bool has_common_type_v = has_common_type_impl<void, Ts...>::value;
|
||||
|
||||
template<typename T, typename Other>
|
||||
struct get_common_type : std::common_type<T, Other> {};
|
||||
|
||||
template<typename T, typename Other>
|
||||
using maybe_common_type = MP_UNITS_TYPENAME std::conditional_t<requires { typename std::common_type_t<T, Other>; },
|
||||
using maybe_common_type = MP_UNITS_TYPENAME std::conditional_t<has_common_type_v<T, Other>,
|
||||
get_common_type<T, Other>, std::type_identity<T>>::type;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user