mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 20:34:26 +02:00
build: got rid of old gcc hacks
This commit is contained in:
22
src/core/include/mp-units/bits/external/hacks.h
vendored
22
src/core/include/mp-units/bits/external/hacks.h
vendored
@@ -96,31 +96,11 @@
|
||||
#if MP_UNITS_COMP_MSVC
|
||||
|
||||
#define MP_UNITS_CONSTRAINED_AUTO_WORKAROUND(X)
|
||||
|
||||
#else
|
||||
|
||||
#define MP_UNITS_CONSTRAINED_AUTO_WORKAROUND(X) X
|
||||
|
||||
#endif
|
||||
|
||||
#if MP_UNITS_COMP_MSVC || (MP_UNITS_COMP_GCC && MP_UNITS_COMP_GCC < 11)
|
||||
|
||||
#define MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(X)
|
||||
|
||||
#else
|
||||
|
||||
#define MP_UNITS_CONSTRAINED_AUTO_WORKAROUND(X) X
|
||||
#define MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(X) X
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
namespace std {
|
||||
|
||||
#if MP_UNITS_COMP_GCC
|
||||
|
||||
template<class T>
|
||||
concept default_constructible = constructible_from<T>;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace std
|
||||
|
@@ -587,14 +587,12 @@ static_assert((tower_peak + 2. * km).in(km).quantity_from_origin_.numerical_valu
|
||||
static_assert((tower_peak + 2. * km).in(m).quantity_from_origin_.numerical_value_ == 2000.);
|
||||
static_assert((tower_peak + 2000. * m).in(km).quantity_from_origin_.numerical_value_ == 2.);
|
||||
|
||||
#if MP_UNITS_COMP_GCC != 10 || MP_UNITS_COMP_GCC_MINOR > 2
|
||||
template<template<auto, auto, typename> typename QP>
|
||||
concept invalid_unit_conversion = requires {
|
||||
requires !requires { QP<isq::height[m], mean_sea_level, int>(2000 * m).in(km); }; // truncating conversion
|
||||
requires !requires { QP<isq::height[m], mean_sea_level, int>(2 * m).in(s); }; // invalid unit
|
||||
};
|
||||
static_assert(invalid_unit_conversion<quantity_point>);
|
||||
#endif
|
||||
|
||||
|
||||
/////////
|
||||
|
@@ -45,7 +45,6 @@ static_assert(sizeof(quantity<isq::length[m]>) == sizeof(double));
|
||||
static_assert(sizeof(quantity<si::metre, short>) == sizeof(short));
|
||||
static_assert(sizeof(quantity<isq::length[m], short>) == sizeof(short));
|
||||
|
||||
#if MP_UNITS_COMP_GCC != 10 || MP_UNITS_COMP_GCC_MINOR > 2
|
||||
template<template<auto, typename> typename Q>
|
||||
concept invalid_types = requires {
|
||||
requires !requires { typename Q<isq::dim_length, double>; }; // dimension instead of reference
|
||||
@@ -55,7 +54,6 @@ concept invalid_types = requires {
|
||||
requires !requires { typename Q<isq::position_vector[si::metre], double>; }; // vector representation expected
|
||||
};
|
||||
static_assert(invalid_types<quantity>);
|
||||
#endif
|
||||
|
||||
static_assert(std::is_trivially_default_constructible_v<quantity<isq::length[m]>>);
|
||||
static_assert(std::is_trivially_copy_constructible_v<quantity<isq::length[m]>>);
|
||||
@@ -208,14 +206,12 @@ static_assert(quantity<isq::length[m]>(2000. * m).in(km).numerical_value_ == 2.)
|
||||
static_assert(quantity<isq::length[km], int>(2 * km).in(km).numerical_value_ == 2);
|
||||
static_assert(quantity<isq::length[km], int>(2 * km).in(m).numerical_value_ == 2000);
|
||||
|
||||
#if MP_UNITS_COMP_GCC != 10 || MP_UNITS_COMP_GCC_MINOR > 2
|
||||
template<template<auto, typename> typename Q>
|
||||
concept invalid_unit_conversion = requires {
|
||||
requires !requires { Q<isq::length[m], int>(2000 * m).in(km); }; // truncating conversion
|
||||
requires !requires { Q<isq::length[m], int>(2 * m).in(s); }; // invalid unit
|
||||
};
|
||||
static_assert(invalid_unit_conversion<quantity>);
|
||||
#endif
|
||||
|
||||
static_assert(quantity<isq::length[km]>(2. * km).numerical_value_in(km) == 2.);
|
||||
static_assert(quantity<isq::length[km]>(2. * km).numerical_value_in(m) == 2000.);
|
||||
@@ -223,14 +219,12 @@ static_assert(quantity<isq::length[m]>(2000. * m).numerical_value_in(km) == 2.);
|
||||
static_assert(quantity<isq::length[km], int>(2 * km).numerical_value_in(km) == 2);
|
||||
static_assert(quantity<isq::length[km], int>(2 * km).numerical_value_in(m) == 2000);
|
||||
|
||||
#if MP_UNITS_COMP_GCC != 10 || MP_UNITS_COMP_GCC_MINOR > 2
|
||||
template<template<auto, typename> typename Q>
|
||||
concept invalid_getter_with_unit_conversion = requires {
|
||||
requires !requires { Q<isq::length[m], int>(2000 * m).numerical_value_in(km); }; // truncating conversion
|
||||
requires !requires { Q<isq::length[m], int>(2 * m).numerical_value_in(s); }; // invalid unit
|
||||
};
|
||||
static_assert(invalid_getter_with_unit_conversion<quantity>);
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user