Skip to content

Commit

Permalink
build: got rid of old gcc hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Sep 26, 2023
1 parent 25fee70 commit 94bd2a2
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 29 deletions.
22 changes: 1 addition & 21 deletions src/core/include/mp-units/bits/external/hacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions test/unit_test/static/quantity_point_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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


/////////
Expand Down
6 changes: 0 additions & 6 deletions test/unit_test/static/quantity_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]>>);
Expand Down Expand Up @@ -208,29 +206,25 @@ 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.);
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


///////////////////////////////////////
Expand Down

0 comments on commit 94bd2a2

Please sign in to comment.