mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 12:24:26 +02:00
refactor: Repetitive inline constexpr
removed as no longer needed
Not needed anymore as stated in cplusplus/draft#4601
This commit is contained in:
@@ -50,7 +50,7 @@ import mp_units;
|
||||
|
||||
template<class T>
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
@@ -44,10 +44,10 @@ template<typename Rep = double>
|
||||
using vector = STD_LA::fixed_size_column_vector<Rep, 3>;
|
||||
|
||||
template<class Rep>
|
||||
inline constexpr bool mp_units::treat_as_floating_point<vector<Rep>> = mp_units::treat_as_floating_point<Rep>;
|
||||
constexpr bool mp_units::treat_as_floating_point<vector<Rep>> = mp_units::treat_as_floating_point<Rep>;
|
||||
|
||||
template<typename Rep>
|
||||
inline constexpr bool mp_units::is_vector<vector<Rep>> = true;
|
||||
constexpr bool mp_units::is_vector<vector<Rep>> = true;
|
||||
|
||||
template<typename Rep>
|
||||
std::ostream& operator<<(std::ostream& os, const vector<Rep>& v)
|
||||
@@ -301,7 +301,7 @@ TEST_CASE("vector quantity", "[la]")
|
||||
|
||||
template<class T>
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
TEST_CASE("vector of quantities", "[la]")
|
||||
{
|
||||
|
@@ -42,9 +42,9 @@ using namespace mp_units;
|
||||
using namespace mp_units::angular;
|
||||
using namespace mp_units::angular::unit_symbols;
|
||||
|
||||
inline constexpr struct half_revolution final : named_unit<"hrev", mag_pi * radian> {
|
||||
constexpr struct half_revolution final : named_unit<"hrev", mag_pi * radian> {
|
||||
} half_revolution;
|
||||
inline constexpr auto hrev = half_revolution;
|
||||
constexpr auto hrev = half_revolution;
|
||||
|
||||
// constexpr auto revb6 = mag_ratio<1,3> * mag_pi * rad;
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
|
||||
template<class T>
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -37,19 +37,19 @@ import std;
|
||||
|
||||
#if MP_UNITS_HOSTED
|
||||
template<typename T>
|
||||
inline constexpr bool mp_units::is_scalar<std::complex<T>> = true;
|
||||
constexpr bool mp_units::is_scalar<std::complex<T>> = true;
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace mp_units;
|
||||
|
||||
inline constexpr struct my_origin final : absolute_point_origin<isq::length> {
|
||||
constexpr struct my_origin final : absolute_point_origin<isq::length> {
|
||||
} my_origin;
|
||||
inline constexpr struct my_relative_origin final : relative_point_origin<my_origin + isq::length(42 * si::metre)> {
|
||||
constexpr struct my_relative_origin final : relative_point_origin<my_origin + isq::length(42 * si::metre)> {
|
||||
} my_relative_origin;
|
||||
|
||||
inline constexpr auto dim_speed = isq::dim_length / isq::dim_time;
|
||||
constexpr auto dim_speed = isq::dim_length / isq::dim_time;
|
||||
|
||||
// BaseDimension
|
||||
static_assert(detail::BaseDimension<struct isq::dim_length>);
|
||||
@@ -78,7 +78,7 @@ static_assert(!Dimension<int>);
|
||||
// TODO add tests
|
||||
|
||||
// QuantitySpec
|
||||
inline constexpr auto speed = isq::length / isq::time;
|
||||
constexpr auto speed = isq::length / isq::time;
|
||||
|
||||
static_assert(QuantitySpec<struct isq::length>);
|
||||
static_assert(QuantitySpec<struct isq::radius>);
|
||||
|
@@ -61,7 +61,7 @@ public:
|
||||
} // namespace
|
||||
|
||||
template<typename T>
|
||||
inline constexpr bool mp_units::is_scalar<min_impl<T>> = true;
|
||||
constexpr bool mp_units::is_scalar<min_impl<T>> = true;
|
||||
|
||||
template<typename T, typename U>
|
||||
struct std::common_type<min_impl<T>, min_impl<U>> : std::type_identity<min_impl<std::common_type_t<T, U>>> {};
|
||||
|
@@ -36,31 +36,31 @@ using namespace mp_units;
|
||||
using dimension_one_ = struct dimension_one;
|
||||
|
||||
// clang-format off
|
||||
inline constexpr struct length_ final : base_dimension<"L"> {} length;
|
||||
inline constexpr struct mass_ final : base_dimension<"M"> {} mass;
|
||||
inline constexpr struct time_ final : base_dimension<"T"> {} time;
|
||||
constexpr struct length_ final : base_dimension<"L"> {} length;
|
||||
constexpr struct mass_ final : base_dimension<"M"> {} mass;
|
||||
constexpr struct time_ final : base_dimension<"T"> {} time;
|
||||
|
||||
inline constexpr auto my_length1 = length;
|
||||
inline constexpr auto my_length2 = length;
|
||||
constexpr auto my_length1 = length;
|
||||
constexpr auto my_length2 = length;
|
||||
|
||||
QUANTITY_SPEC_(q_time, time);
|
||||
inline constexpr struct second_ final : named_unit<"s", kind_of<q_time>> {} second;
|
||||
constexpr struct second_ final : named_unit<"s", kind_of<q_time>> {} second;
|
||||
|
||||
inline constexpr auto frequency = inverse(time);
|
||||
inline constexpr auto action = inverse(time);
|
||||
inline constexpr auto area = length * length;
|
||||
inline constexpr auto volume = area * length;
|
||||
inline constexpr auto speed = length / time;
|
||||
inline constexpr auto acceleration = speed / time;
|
||||
inline constexpr auto force = mass * acceleration;
|
||||
inline constexpr auto moment_of_force = length * force;
|
||||
inline constexpr auto torque = moment_of_force;
|
||||
inline constexpr auto pressure = force / area;
|
||||
inline constexpr auto stress = pressure;
|
||||
inline constexpr auto strain = stress / stress;
|
||||
inline constexpr auto power = force * speed;
|
||||
inline constexpr auto efficiency = power / power;
|
||||
inline constexpr auto energy = force * length;
|
||||
constexpr auto frequency = inverse(time);
|
||||
constexpr auto action = inverse(time);
|
||||
constexpr auto area = length * length;
|
||||
constexpr auto volume = area * length;
|
||||
constexpr auto speed = length / time;
|
||||
constexpr auto acceleration = speed / time;
|
||||
constexpr auto force = mass * acceleration;
|
||||
constexpr auto moment_of_force = length * force;
|
||||
constexpr auto torque = moment_of_force;
|
||||
constexpr auto pressure = force / area;
|
||||
constexpr auto stress = pressure;
|
||||
constexpr auto strain = stress / stress;
|
||||
constexpr auto power = force * speed;
|
||||
constexpr auto efficiency = power / power;
|
||||
constexpr auto energy = force * length;
|
||||
// clang-format on
|
||||
|
||||
// concepts verification
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
template<class T>
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
|
||||
template<class T>
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -32,7 +32,7 @@ using namespace units;
|
||||
using namespace units::detail;
|
||||
|
||||
template<>
|
||||
inline constexpr std::optional<std::intmax_t> units::known_first_factor<9223372036854775783> = 9223372036854775783;
|
||||
constexpr std::optional<std::intmax_t> units::known_first_factor<9223372036854775783> = 9223372036854775783;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -71,11 +71,11 @@ namespace {
|
||||
// CHECK(round_trip == R);
|
||||
// }
|
||||
|
||||
inline constexpr struct mag_2_ : magnitude<2> {
|
||||
constexpr struct mag_2_ : magnitude<2> {
|
||||
} mag_2;
|
||||
// inline constexpr struct mag_2_other : magnitude<2> {
|
||||
// constexpr struct mag_2_other : magnitude<2> {
|
||||
// } mag_2_other;
|
||||
// inline constexpr struct mag_3 : magnitude<2> {
|
||||
// constexpr struct mag_3 : magnitude<2> {
|
||||
// } mag_3;
|
||||
|
||||
// concepts verification
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
template<class T>
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -50,38 +50,38 @@ using namespace std::chrono_literals;
|
||||
using sys_seconds = std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>;
|
||||
#endif
|
||||
|
||||
inline constexpr struct zeroth_length final : absolute_point_origin<isq::length> {
|
||||
constexpr struct zeroth_length final : absolute_point_origin<isq::length> {
|
||||
} zeroth_length;
|
||||
|
||||
inline constexpr struct mean_sea_level final : absolute_point_origin<isq::height> {
|
||||
constexpr struct mean_sea_level final : absolute_point_origin<isq::height> {
|
||||
} mean_sea_level;
|
||||
|
||||
inline constexpr auto my_mean_sea_level = mean_sea_level;
|
||||
constexpr auto my_mean_sea_level = mean_sea_level;
|
||||
|
||||
inline constexpr struct same_mean_sea_level final : relative_point_origin<mean_sea_level + 0 * isq::height[m]> {
|
||||
constexpr struct same_mean_sea_level final : relative_point_origin<mean_sea_level + 0 * isq::height[m]> {
|
||||
} same_mean_sea_level;
|
||||
|
||||
inline constexpr struct ground_level final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> {
|
||||
constexpr struct ground_level final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> {
|
||||
} ground_level;
|
||||
|
||||
inline constexpr auto my_ground_level = ground_level;
|
||||
constexpr auto my_ground_level = ground_level;
|
||||
|
||||
inline constexpr struct same_ground_level1 final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> {
|
||||
constexpr struct same_ground_level1 final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> {
|
||||
} same_ground_level1;
|
||||
|
||||
inline constexpr struct same_ground_level2 final : relative_point_origin<my_mean_sea_level + 42 * isq::height[m]> {
|
||||
constexpr struct same_ground_level2 final : relative_point_origin<my_mean_sea_level + 42 * isq::height[m]> {
|
||||
} same_ground_level2;
|
||||
|
||||
inline constexpr struct tower_peak final : relative_point_origin<ground_level + 42 * isq::height[m]> {
|
||||
constexpr struct tower_peak final : relative_point_origin<ground_level + 42 * isq::height[m]> {
|
||||
} tower_peak;
|
||||
|
||||
inline constexpr struct other_ground_level final : relative_point_origin<mean_sea_level + 123 * isq::height[m]> {
|
||||
constexpr struct other_ground_level final : relative_point_origin<mean_sea_level + 123 * isq::height[m]> {
|
||||
} other_ground_level;
|
||||
|
||||
inline constexpr struct other_absolute_level final : absolute_point_origin<isq::height> {
|
||||
constexpr struct other_absolute_level final : absolute_point_origin<isq::height> {
|
||||
} other_absolute_level;
|
||||
|
||||
inline constexpr struct zero final : absolute_point_origin<dimensionless> {
|
||||
constexpr struct zero final : absolute_point_origin<dimensionless> {
|
||||
} zero;
|
||||
|
||||
QUANTITY_SPEC(special_height, isq::height);
|
||||
@@ -111,18 +111,18 @@ static_assert(ground_level != other_ground_level);
|
||||
template<auto QS>
|
||||
struct absolute_po_ final : absolute_point_origin<QS> {};
|
||||
template<auto QS>
|
||||
inline constexpr absolute_po_<QS> absolute_po;
|
||||
constexpr absolute_po_<QS> absolute_po;
|
||||
|
||||
template<auto QP>
|
||||
struct relative_po_ final : relative_point_origin<QP> {};
|
||||
template<auto QP>
|
||||
inline constexpr relative_po_<QP> relative_po;
|
||||
constexpr relative_po_<QP> relative_po;
|
||||
|
||||
static_assert(relative_po<absolute_po<isq::length> + isq::height(42 * m)>.quantity_spec == isq::height);
|
||||
static_assert(relative_po<absolute_po<kind_of<isq::length>> + isq::height(42 * m)>.quantity_spec == isq::height);
|
||||
static_assert(relative_po<absolute_po<isq::height> + 42 * m>.quantity_spec == isq::height);
|
||||
|
||||
inline constexpr struct my_kelvin final : named_unit<"my_K", mag<10> * si::kelvin> {
|
||||
constexpr struct my_kelvin final : named_unit<"my_K", mag<10> * si::kelvin> {
|
||||
} my_kelvin;
|
||||
|
||||
static_assert(default_point_origin(si::kelvin) == si::absolute_zero);
|
||||
@@ -1516,7 +1516,7 @@ static_assert(ground_level - other_ground_level == -81 * m);
|
||||
static_assert(other_ground_level - tower_peak == 39 * m);
|
||||
static_assert(tower_peak - other_ground_level == -39 * m);
|
||||
|
||||
inline constexpr struct zero_m_per_s final : absolute_point_origin<kind_of<isq::speed>> {
|
||||
constexpr struct zero_m_per_s final : absolute_point_origin<kind_of<isq::speed>> {
|
||||
} zero_m_per_s;
|
||||
|
||||
// commutativity and associativity
|
||||
@@ -1604,7 +1604,7 @@ static_assert(
|
||||
is_of_type<quantity_point{10 * isq::height[m] / (2 * isq::time[s])} + (10 * isq::height[m] / (2 * isq::time[s])),
|
||||
quantity_point<(isq::height / isq::time)[m / s], zeroth_point_origin<isq::height / isq::time>, int>>);
|
||||
|
||||
inline constexpr struct zero_Hz final : absolute_point_origin<kind_of<isq::frequency>> {
|
||||
constexpr struct zero_Hz final : absolute_point_origin<kind_of<isq::frequency>> {
|
||||
} zero_Hz;
|
||||
|
||||
static_assert(((zero_Hz + 10 / (2 * isq::period_duration[s])) + 5 * isq::frequency[Hz]).quantity_from(zero_Hz) ==
|
||||
@@ -1688,7 +1688,7 @@ consteval bool invalid_subtraction(Ts... ts)
|
||||
return !requires { (... - ts); };
|
||||
}
|
||||
|
||||
inline constexpr struct zero_Bq final : absolute_point_origin<kind_of<isq::activity>> {
|
||||
constexpr struct zero_Bq final : absolute_point_origin<kind_of<isq::activity>> {
|
||||
} zero_Bq;
|
||||
|
||||
static_assert(invalid_addition(zero_Bq + 5 * isq::activity[Bq], 5 * isq::frequency[Hz]));
|
||||
|
@@ -37,22 +37,22 @@ using dimensionless_ = struct dimensionless;
|
||||
using dim_one_ = struct dimension_one;
|
||||
|
||||
// clang-format off
|
||||
inline constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
inline constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
|
||||
// quantities specification
|
||||
QUANTITY_SPEC_(length, dim_length);
|
||||
QUANTITY_SPEC_(mass, dim_mass);
|
||||
QUANTITY_SPEC_(time, dim_time);
|
||||
|
||||
inline constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
|
||||
QUANTITY_SPEC_(height, length);
|
||||
QUANTITY_SPEC_(width, length);
|
||||
QUANTITY_SPEC_(radius, width);
|
||||
QUANTITY_SPEC_(path_length, length);
|
||||
inline constexpr auto arc_length = path_length;
|
||||
constexpr auto arc_length = path_length;
|
||||
QUANTITY_SPEC_(distance, path_length);
|
||||
QUANTITY_SPEC_(position_vector, length, quantity_character::vector);
|
||||
QUANTITY_SPEC_(period_duration, time);
|
||||
|
@@ -41,7 +41,7 @@ import std;
|
||||
#endif
|
||||
|
||||
template<>
|
||||
inline constexpr bool mp_units::is_vector<int> = true;
|
||||
constexpr bool mp_units::is_vector<int> = true;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -901,7 +901,7 @@ static_assert(1 * si::si2019::speed_of_light_in_vacuum == 299'792'458 * isq::spe
|
||||
|
||||
// Different named dimensions
|
||||
template<Reference auto R1, Reference auto R2>
|
||||
inline constexpr bool invalid_comparison = !requires { 2 * R1 == 2 * R2; } && !requires { 2 * R2 == 2 * R1; };
|
||||
constexpr bool invalid_comparison = !requires { 2 * R1 == 2 * R2; } && !requires { 2 * R2 == 2 * R1; };
|
||||
static_assert(invalid_comparison<isq::activity[Bq], isq::frequency[Hz]>);
|
||||
|
||||
|
||||
|
@@ -39,9 +39,9 @@ using one_ = struct one;
|
||||
|
||||
// base dimensions
|
||||
// clang-format off
|
||||
inline constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
inline constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
|
||||
// quantities specification
|
||||
QUANTITY_SPEC_(length, dim_length);
|
||||
@@ -64,37 +64,37 @@ QUANTITY_SPEC_(power, force* speed);
|
||||
QUANTITY_SPEC_(storage_capacity, dimensionless, is_kind);
|
||||
|
||||
// base units
|
||||
inline constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
inline constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre;
|
||||
inline constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram;
|
||||
inline constexpr auto kilogram = si::kilo<gram>;
|
||||
constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre;
|
||||
constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram;
|
||||
constexpr auto kilogram = si::kilo<gram>;
|
||||
|
||||
namespace nu {
|
||||
// hypothetical natural system of units for c=1
|
||||
|
||||
inline constexpr struct second_ final : named_unit<"s"> {} second;
|
||||
inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
constexpr struct second_ final : named_unit<"s"> {} second;
|
||||
constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
|
||||
inline constexpr struct time : system_reference<time_{}, second> {} time;
|
||||
inline constexpr struct length : system_reference<length_{}, second> {} length;
|
||||
inline constexpr struct speed : system_reference<speed_{}, second / second> {} speed;
|
||||
constexpr struct time : system_reference<time_{}, second> {} time;
|
||||
constexpr struct length : system_reference<length_{}, second> {} length;
|
||||
constexpr struct speed : system_reference<speed_{}, second / second> {} speed;
|
||||
|
||||
}
|
||||
|
||||
// derived named units
|
||||
inline constexpr struct radian_ final : named_unit<"rad", metre / metre, kind_of<angular_measure>> {} radian;
|
||||
inline constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre), kind_of<solid_angular_measure>> {} steradian;
|
||||
inline constexpr struct hertz_ final : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz;
|
||||
inline constexpr struct becquerel_ final : named_unit<"Bq", inverse(second), kind_of<activity>> {} becquerel;
|
||||
inline constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
inline constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
|
||||
inline constexpr struct watt_ final : named_unit<"W", joule / second> {} watt;
|
||||
constexpr struct radian_ final : named_unit<"rad", metre / metre, kind_of<angular_measure>> {} radian;
|
||||
constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre), kind_of<solid_angular_measure>> {} steradian;
|
||||
constexpr struct hertz_ final : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz;
|
||||
constexpr struct becquerel_ final : named_unit<"Bq", inverse(second), kind_of<activity>> {} becquerel;
|
||||
constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
|
||||
constexpr struct watt_ final : named_unit<"W", joule / second> {} watt;
|
||||
|
||||
inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
inline constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour;
|
||||
inline constexpr auto kilometre = si::kilo<metre>;
|
||||
constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour;
|
||||
constexpr auto kilometre = si::kilo<metre>;
|
||||
|
||||
inline constexpr struct bit_ final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit;
|
||||
constexpr struct bit_ final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit;
|
||||
// clang-format on
|
||||
|
||||
|
||||
|
@@ -31,19 +31,19 @@ import std;
|
||||
#endif
|
||||
|
||||
template<auto V, typename T>
|
||||
inline constexpr bool is_of_type = std::is_same_v<MP_UNITS_REMOVE_CONST(decltype(V)), T>;
|
||||
constexpr bool is_of_type = std::is_same_v<MP_UNITS_REMOVE_CONST(decltype(V)), T>;
|
||||
|
||||
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||
#if MP_UNITS_API_NO_CRTP
|
||||
|
||||
#define QUANTITY_SPEC_(name, ...) \
|
||||
inline constexpr struct name##_ final : quantity_spec<__VA_ARGS__> { \
|
||||
#define QUANTITY_SPEC_(name, ...) \
|
||||
constexpr struct name##_ final : quantity_spec<__VA_ARGS__> { \
|
||||
} name
|
||||
|
||||
#else
|
||||
|
||||
#define QUANTITY_SPEC_(name, ...) \
|
||||
inline constexpr struct name##_ final : quantity_spec<name##_, __VA_ARGS__> { \
|
||||
#define QUANTITY_SPEC_(name, ...) \
|
||||
constexpr struct name##_ final : quantity_spec<name##_, __VA_ARGS__> { \
|
||||
} name
|
||||
|
||||
#endif
|
||||
|
@@ -40,10 +40,10 @@ using percent_ = struct percent;
|
||||
|
||||
// base dimensions
|
||||
// clang-format off
|
||||
inline constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
inline constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
inline constexpr struct dim_thermodynamic_temperature_ final : base_dimension<symbol_text{u8"Θ", "O"}> {} dim_thermodynamic_temperature;
|
||||
constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
constexpr struct dim_thermodynamic_temperature_ final : base_dimension<symbol_text{u8"Θ", "O"}> {} dim_thermodynamic_temperature;
|
||||
|
||||
// quantities specification
|
||||
QUANTITY_SPEC_(length, dim_length);
|
||||
@@ -52,39 +52,39 @@ QUANTITY_SPEC_(time, dim_time);
|
||||
QUANTITY_SPEC_(thermodynamic_temperature, dim_thermodynamic_temperature);
|
||||
|
||||
// base units
|
||||
inline constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
inline constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre;
|
||||
inline constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram;
|
||||
inline constexpr auto kilogram = si::kilo<gram>;
|
||||
inline constexpr struct kelvin_ final : named_unit<"K", kind_of<thermodynamic_temperature>> {} kelvin;
|
||||
constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre;
|
||||
constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram;
|
||||
constexpr auto kilogram = si::kilo<gram>;
|
||||
constexpr struct kelvin_ final : named_unit<"K", kind_of<thermodynamic_temperature>> {} kelvin;
|
||||
|
||||
// hypothetical natural units for c=1
|
||||
inline constexpr struct nu_second_ final : named_unit<"s"> {} nu_second;
|
||||
constexpr struct nu_second_ final : named_unit<"s"> {} nu_second;
|
||||
|
||||
// derived named units
|
||||
inline constexpr struct radian_ final : named_unit<"rad", metre / metre> {} radian;
|
||||
inline constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre)> {} steradian;
|
||||
inline constexpr struct hertz_ final : named_unit<"Hz", inverse(second)> {} hertz;
|
||||
inline constexpr struct becquerel_ final : named_unit<"Bq", inverse(second)> {} becquerel;
|
||||
inline constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
inline constexpr struct pascal_ final : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
inline constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
|
||||
inline constexpr struct watt_ final : named_unit<"W", joule / second> {} watt;
|
||||
inline constexpr struct degree_Celsius_ final : named_unit<symbol_text{u8"℃", "`C"}, kelvin> {} degree_Celsius;
|
||||
constexpr struct radian_ final : named_unit<"rad", metre / metre> {} radian;
|
||||
constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre)> {} steradian;
|
||||
constexpr struct hertz_ final : named_unit<"Hz", inverse(second)> {} hertz;
|
||||
constexpr struct becquerel_ final : named_unit<"Bq", inverse(second)> {} becquerel;
|
||||
constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
constexpr struct pascal_ final : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
|
||||
constexpr struct watt_ final : named_unit<"W", joule / second> {} watt;
|
||||
constexpr struct degree_Celsius_ final : named_unit<symbol_text{u8"℃", "`C"}, kelvin> {} degree_Celsius;
|
||||
|
||||
inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
inline constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour;
|
||||
inline constexpr struct degree_ final : named_unit<symbol_text{u8"°", "deg"}, mag_pi / mag<180> * radian> {} degree;
|
||||
constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour;
|
||||
constexpr struct degree_ final : named_unit<symbol_text{u8"°", "deg"}, mag_pi / mag<180> * radian> {} degree;
|
||||
|
||||
inline constexpr struct yard_ final : named_unit<"yd", mag_ratio<9'144, 10'000> * metre> {} yard;
|
||||
inline constexpr struct mile_ final : named_unit<"mi", mag<1760> * yard> {} mile;
|
||||
constexpr struct yard_ final : named_unit<"yd", mag_ratio<9'144, 10'000> * metre> {} yard;
|
||||
constexpr struct mile_ final : named_unit<"mi", mag<1760> * yard> {} mile;
|
||||
|
||||
inline constexpr auto kilometre = si::kilo<metre>;
|
||||
inline constexpr auto kilojoule = si::kilo<joule>;
|
||||
constexpr auto kilometre = si::kilo<metre>;
|
||||
constexpr auto kilojoule = si::kilo<joule>;
|
||||
|
||||
// physical constant units
|
||||
inline constexpr struct standard_gravity_ final : named_unit<symbol_text{u8"g₀", "g_0"}, mag_ratio<980'665, 100'000> * metre / square(second)> {} standard_gravity;
|
||||
inline constexpr struct speed_of_light_in_vacuum_ final : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
|
||||
constexpr struct standard_gravity_ final : named_unit<symbol_text{u8"g₀", "g_0"}, mag_ratio<980'665, 100'000> * metre / square(second)> {} standard_gravity;
|
||||
constexpr struct speed_of_light_in_vacuum_ final : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
Reference in New Issue
Block a user