mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 18:37:15 +02:00
Custom is_same implementation added
This commit is contained in:
@ -85,7 +85,7 @@ and `si::metre` is a :term:`base unit` of this base dimension. We can
|
|||||||
obtain those back easily with::
|
obtain those back easily with::
|
||||||
|
|
||||||
static_assert(si::dim_length::symbol == "L");
|
static_assert(si::dim_length::symbol == "L");
|
||||||
static_assert(std::is_same_v<si::dim_length::base_unit, si::metre>);
|
static_assert(is_same_v<si::dim_length::base_unit, si::metre>);
|
||||||
|
|
||||||
|
|
||||||
Derived Dimensions
|
Derived Dimensions
|
||||||
@ -169,8 +169,8 @@ Obtaining a Unit of the Dimension
|
|||||||
In order to obtain the base/coherent unit of any dimension type a
|
In order to obtain the base/coherent unit of any dimension type a
|
||||||
`dimension_unit` helper was introduced::
|
`dimension_unit` helper was introduced::
|
||||||
|
|
||||||
static_assert(std::is_same_v<dimension_unit<si::dim_length>, si::metre>);
|
static_assert(is_same_v<dimension_unit<si::dim_length>, si::metre>);
|
||||||
static_assert(std::is_same_v<dimension_unit<si::dim_speed>, si::metre_per_second>);
|
static_assert(is_same_v<dimension_unit<si::dim_speed>, si::metre_per_second>);
|
||||||
|
|
||||||
|
|
||||||
.. rubric:: Citations:
|
.. rubric:: Citations:
|
||||||
|
@ -27,8 +27,8 @@ will determine its type. The same applies to the resulting unit. For example:
|
|||||||
using namespace units::physical::si;
|
using namespace units::physical::si;
|
||||||
|
|
||||||
constexpr auto result = 144q_km / 2q_h;
|
constexpr auto result = 144q_km / 2q_h;
|
||||||
static_assert(std::is_same_v<decltype(result)::dimension, dim_speed>);
|
static_assert(is_same_v<decltype(result)::dimension, dim_speed>);
|
||||||
static_assert(std::is_same_v<decltype(result)::unit, kilometre_per_hour>);
|
static_assert(is_same_v<decltype(result)::unit, kilometre_per_hour>);
|
||||||
|
|
||||||
However, if the resulting dimension is not predefined by the user the library framework
|
However, if the resulting dimension is not predefined by the user the library framework
|
||||||
will create an instance of an `unknown_dimension`. The coherent unit of such an unknown
|
will create an instance of an `unknown_dimension`. The coherent unit of such an unknown
|
||||||
@ -45,10 +45,10 @@ we forget to include a header file with the resulting dimension definition:
|
|||||||
using namespace units::physical::si;
|
using namespace units::physical::si;
|
||||||
|
|
||||||
constexpr auto result = 144q_km / 2q_h;
|
constexpr auto result = 144q_km / 2q_h;
|
||||||
static_assert(std::is_same_v<decltype(result)::dimension,
|
static_assert(is_same_v<decltype(result)::dimension,
|
||||||
unknown_dimension<exp<dim_length, 1>, exp<dim_time, -1>>>);
|
unknown_dimension<exp<dim_length, 1>, exp<dim_time, -1>>>);
|
||||||
static_assert(std::is_same_v<decltype(result)::unit,
|
static_assert(is_same_v<decltype(result)::unit,
|
||||||
scaled_unit<ratio<1, 36, 1>, unknown_coherent_unit>>);
|
scaled_unit<ratio(1, 36, 1), unknown_coherent_unit>>);
|
||||||
|
|
||||||
|
|
||||||
Operations On Unknown Dimensions And Their Units
|
Operations On Unknown Dimensions And Their Units
|
||||||
|
@ -30,15 +30,15 @@ namespace units {
|
|||||||
// equivalent_dim
|
// equivalent_dim
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
template<BaseDimension D1, BaseDimension D2>
|
||||||
|
using equivalent_base_dim = std::conjunction<std::bool_constant<D1::symbol == D2::symbol>,
|
||||||
|
same_unit_reference<typename D1::base_unit, typename D2::base_unit>>;
|
||||||
|
|
||||||
template<Dimension D1, Dimension D2>
|
template<Dimension D1, Dimension D2>
|
||||||
struct equivalent_dim_impl : std::false_type {};
|
struct equivalent_dim_impl : std::false_type {};
|
||||||
|
|
||||||
template<BaseDimension D1, BaseDimension D2>
|
template<BaseDimension D1, BaseDimension D2>
|
||||||
struct equivalent_base_dim : std::conjunction<std::bool_constant<D1::symbol == D2::symbol>,
|
struct equivalent_dim_impl<D1, D2> : std::disjunction<is_same<D1, D2>, equivalent_base_dim<D1, D2>> {};
|
||||||
same_unit_reference<typename D1::base_unit, typename D2::base_unit>> {};
|
|
||||||
|
|
||||||
template<BaseDimension D1, BaseDimension D2>
|
|
||||||
struct equivalent_dim_impl<D1, D2> : std::disjunction<std::is_same<D1, D2>, equivalent_base_dim<D1, D2>> {};
|
|
||||||
|
|
||||||
template<Exponent E1, Exponent E2>
|
template<Exponent E1, Exponent E2>
|
||||||
struct equivalent_exp : std::false_type {};
|
struct equivalent_exp : std::false_type {};
|
||||||
@ -54,7 +54,7 @@ template<typename... Es1, typename... Es2>
|
|||||||
struct equivalent_derived_dim<derived_dimension_base<Es1...>, derived_dimension_base<Es2...>> : std::conjunction<equivalent_exp<Es1, Es2>...> {};
|
struct equivalent_derived_dim<derived_dimension_base<Es1...>, derived_dimension_base<Es2...>> : std::conjunction<equivalent_exp<Es1, Es2>...> {};
|
||||||
|
|
||||||
template<DerivedDimension D1, DerivedDimension D2>
|
template<DerivedDimension D1, DerivedDimension D2>
|
||||||
struct equivalent_dim_impl<D1, D2> : std::disjunction<std::is_same<D1, D2>, equivalent_derived_dim<downcast_base_t<D1>, downcast_base_t<D2>>> {};
|
struct equivalent_dim_impl<D1, D2> : std::disjunction<is_same<D1, D2>, equivalent_derived_dim<downcast_base_t<D1>, downcast_base_t<D2>>> {};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
10
src/include/units/bits/external/type_traits.h
vendored
10
src/include/units/bits/external/type_traits.h
vendored
@ -46,6 +46,16 @@ struct conditional_impl<true> {
|
|||||||
template<bool B, typename T, typename F>
|
template<bool B, typename T, typename F>
|
||||||
using conditional = detail::conditional_impl<B>::template type<T, F>;
|
using conditional = detail::conditional_impl<B>::template type<T, F>;
|
||||||
|
|
||||||
|
// is_same
|
||||||
|
template<class T, class U>
|
||||||
|
inline constexpr bool is_same_v = false;
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline constexpr bool is_same_v<T, T> = true;
|
||||||
|
|
||||||
|
template<class T, class U>
|
||||||
|
using is_same = std::bool_constant<is_same_v<T, U>>;
|
||||||
|
|
||||||
// is_instantiation_of
|
// is_instantiation_of
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
@ -74,11 +74,11 @@ constexpr auto prefix_or_ratio_text()
|
|||||||
return basic_fixed_string("");
|
return basic_fixed_string("");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if constexpr (!std::is_same_v<PrefixFamily, no_prefix>) {
|
if constexpr (!is_same_v<PrefixFamily, no_prefix>) {
|
||||||
// try to form a prefix
|
// try to form a prefix
|
||||||
using prefix = downcast<detail::prefix_base<PrefixFamily, R>>;
|
using prefix = downcast<detail::prefix_base<PrefixFamily, R>>;
|
||||||
|
|
||||||
if constexpr(!std::is_same_v<prefix, prefix_base<PrefixFamily, R>>) {
|
if constexpr(!is_same_v<prefix, prefix_base<PrefixFamily, R>>) {
|
||||||
// print as a prefixed unit
|
// print as a prefixed unit
|
||||||
return prefix::symbol;
|
return prefix::symbol;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ template<Dimension D, auto R>
|
|||||||
using downcast_unit = downcast<scaled_unit<R, typename dimension_unit<D>::reference>>;
|
using downcast_unit = downcast<scaled_unit<R, typename dimension_unit<D>::reference>>;
|
||||||
|
|
||||||
template<Unit U1, Unit U2>
|
template<Unit U1, Unit U2>
|
||||||
struct same_unit_reference : std::is_same<typename U1::reference, typename U2::reference> {};
|
struct same_unit_reference : is_same<typename U1::reference, typename U2::reference> {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief An unnamed unit
|
* @brief An unnamed unit
|
||||||
|
@ -49,11 +49,11 @@ using amplitude_spectral_density = quantity<dim_amplitude_spectral_density, U, R
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static_assert(std::is_same_v<dimension_sqrt<dim_power_spectral_density>, dim_amplitude_spectral_density>);
|
static_assert(is_same_v<dimension_sqrt<dim_power_spectral_density>, dim_amplitude_spectral_density>);
|
||||||
static_assert(std::is_same_v<dimension_pow<dim_amplitude_spectral_density, 2>, dim_power_spectral_density>);
|
static_assert(is_same_v<dimension_pow<dim_amplitude_spectral_density, 2>, dim_power_spectral_density>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<decltype(pow<2>(amplitude_spectral_density<volt_per_sqrt_hertz>(4))), decltype(power_spectral_density<sq_volt_per_hertz>(16))>);
|
static_assert(is_same_v<decltype(pow<2>(amplitude_spectral_density<volt_per_sqrt_hertz>(4))), decltype(power_spectral_density<sq_volt_per_hertz>(16))>);
|
||||||
static_assert(std::is_same_v<decltype(sqrt(power_spectral_density<sq_volt_per_hertz>(16))), decltype(amplitude_spectral_density<volt_per_sqrt_hertz>(4))>);
|
static_assert(is_same_v<decltype(sqrt(power_spectral_density<sq_volt_per_hertz>(16))), decltype(amplitude_spectral_density<volt_per_sqrt_hertz>(4))>);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +63,6 @@ struct kilogram_per_second : unit<kilogram_per_second> {};
|
|||||||
struct dim_mass_rate : derived_dimension<dim_mass_rate, kilogram_per_second, units::exp<dim_mass, 1>, units::exp<dim_time, -1>> {};
|
struct dim_mass_rate : derived_dimension<dim_mass_rate, kilogram_per_second, units::exp<dim_mass, 1>, units::exp<dim_time, -1>> {};
|
||||||
struct kilogram_per_hour : deduced_unit<kilogram_per_hour, dim_mass_rate, kilogram, hour> {};
|
struct kilogram_per_hour : deduced_unit<kilogram_per_hour, dim_mass_rate, kilogram, hour> {};
|
||||||
constexpr auto a = 1q_kg / 1q_h;
|
constexpr auto a = 1q_kg / 1q_h;
|
||||||
static_assert(std::is_same_v<decltype(a)::unit, kilogram_per_hour>);
|
static_assert(is_same_v<decltype(a)::unit, kilogram_per_hour>);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ struct d3 : base_dimension<"d3", u3> {};
|
|||||||
|
|
||||||
// exp_invert
|
// exp_invert
|
||||||
|
|
||||||
static_assert(std::is_same_v<exp_invert<units::exp<d0, 2>>, units::exp<d0, -2>>);
|
static_assert(is_same_v<exp_invert<units::exp<d0, 2>>, units::exp<d0, -2>>);
|
||||||
static_assert(std::is_same_v<exp_invert<units::exp<d1, -2>>, units::exp<d1, 2>>);
|
static_assert(is_same_v<exp_invert<units::exp<d1, -2>>, units::exp<d1, 2>>);
|
||||||
|
|
||||||
// dim_unpack
|
// dim_unpack
|
||||||
|
|
||||||
@ -53,67 +53,67 @@ using dim_unpack = detail::dim_unpack<Ts...>::type;
|
|||||||
template<Exponent... Es>
|
template<Exponent... Es>
|
||||||
using derived_dim = detail::derived_dimension_base<Es...>;
|
using derived_dim = detail::derived_dimension_base<Es...>;
|
||||||
|
|
||||||
static_assert(std::is_same_v<dim_unpack<>, exp_list<>>);
|
static_assert(is_same_v<dim_unpack<>, exp_list<>>);
|
||||||
static_assert(std::is_same_v<dim_unpack<units::exp<d0, 1>>, exp_list<units::exp<d0, 1>>>);
|
static_assert(is_same_v<dim_unpack<units::exp<d0, 1>>, exp_list<units::exp<d0, 1>>>);
|
||||||
static_assert(std::is_same_v<dim_unpack<units::exp<d0, 1>, units::exp<d1, 2>>, exp_list<units::exp<d0, 1>, units::exp<d1, 2>>>);
|
static_assert(is_same_v<dim_unpack<units::exp<d0, 1>, units::exp<d1, 2>>, exp_list<units::exp<d0, 1>, units::exp<d1, 2>>>);
|
||||||
using dim1 = derived_dim<units::exp<d0, 1>>;
|
using dim1 = derived_dim<units::exp<d0, 1>>;
|
||||||
using dim2 = derived_dim<units::exp<d0, 1>, units::exp<d1, 2>>;
|
using dim2 = derived_dim<units::exp<d0, 1>, units::exp<d1, 2>>;
|
||||||
static_assert(std::is_same_v<dim_unpack<units::exp<dim1, 2>, units::exp<d0, 1>>, exp_list<units::exp<d0, 2>, units::exp<d0, 1>>>);
|
static_assert(is_same_v<dim_unpack<units::exp<dim1, 2>, units::exp<d0, 1>>, exp_list<units::exp<d0, 2>, units::exp<d0, 1>>>);
|
||||||
static_assert(std::is_same_v<dim_unpack<units::exp<dim2, -2>, units::exp<d0, 1>, units::exp<d1, 2>>,
|
static_assert(is_same_v<dim_unpack<units::exp<dim2, -2>, units::exp<d0, 1>, units::exp<d1, 2>>,
|
||||||
exp_list<units::exp<d0, -2>, units::exp<d1, -4>, units::exp<d0, 1>, units::exp<d1, 2>>>);
|
exp_list<units::exp<d0, -2>, units::exp<d1, -4>, units::exp<d0, 1>, units::exp<d1, 2>>>);
|
||||||
|
|
||||||
// dim_invert
|
// dim_invert
|
||||||
static_assert(std::is_same_v<dim_invert<derived_dim<units::exp<d0, -1>>>, d0>);
|
static_assert(is_same_v<dim_invert<derived_dim<units::exp<d0, -1>>>, d0>);
|
||||||
static_assert(std::is_same_v<dim_invert<derived_dim<units::exp<d0, -2>>>, unknown_dimension<units::exp<d0, 2>>>);
|
static_assert(is_same_v<dim_invert<derived_dim<units::exp<d0, -2>>>, unknown_dimension<units::exp<d0, 2>>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<dim_invert<derived_dim<units::exp<d0, 2>, units::exp<d1, -1>>>, unknown_dimension<units::exp<d0, -2>, units::exp<d1, 1>>>);
|
is_same_v<dim_invert<derived_dim<units::exp<d0, 2>, units::exp<d1, -1>>>, unknown_dimension<units::exp<d0, -2>, units::exp<d1, 1>>>);
|
||||||
|
|
||||||
// make_dimension
|
// make_dimension
|
||||||
|
|
||||||
template<typename... Ts>
|
template<typename... Ts>
|
||||||
using make_dimension = detail::make_dimension<Ts...>;
|
using make_dimension = detail::make_dimension<Ts...>;
|
||||||
|
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d0, 1>>, derived_dim<units::exp<d0, 1>>>);
|
static_assert(is_same_v<make_dimension<units::exp<d0, 1>>, derived_dim<units::exp<d0, 1>>>);
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d0, 1>, units::exp<d1, 1>>, derived_dim<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
static_assert(is_same_v<make_dimension<units::exp<d0, 1>, units::exp<d1, 1>>, derived_dim<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d1, 1>, units::exp<d0, 1>>, derived_dim<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
static_assert(is_same_v<make_dimension<units::exp<d1, 1>, units::exp<d0, 1>>, derived_dim<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d1, 1>, units::exp<d1, 1>>, derived_dim<units::exp<d1, 2>>>);
|
static_assert(is_same_v<make_dimension<units::exp<d1, 1>, units::exp<d1, 1>>, derived_dim<units::exp<d1, 2>>>);
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d1, 1>, units::exp<d1, 1, 2>>, derived_dim<units::exp<d1, 3, 2>>>);
|
static_assert(is_same_v<make_dimension<units::exp<d1, 1>, units::exp<d1, 1, 2>>, derived_dim<units::exp<d1, 3, 2>>>);
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d1, 1, 2>, units::exp<d1, 1, 2>>, derived_dim<units::exp<d1, 1>>>);
|
static_assert(is_same_v<make_dimension<units::exp<d1, 1, 2>, units::exp<d1, 1, 2>>, derived_dim<units::exp<d1, 1>>>);
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d1, 2>, units::exp<d1, 1, 2>>, derived_dim<units::exp<d1, 5, 2>>>);
|
static_assert(is_same_v<make_dimension<units::exp<d1, 2>, units::exp<d1, 1, 2>>, derived_dim<units::exp<d1, 5, 2>>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d0, 1>, units::exp<d1, 1>>,
|
static_assert(is_same_v<make_dimension<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d0, 1>, units::exp<d1, 1>>,
|
||||||
derived_dim<units::exp<d0, 2>, units::exp<d1, 2>>>);
|
derived_dim<units::exp<d0, 2>, units::exp<d1, 2>>>);
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d0, -1>, units::exp<d1, -1>, units::exp<d0, -1>, units::exp<d1, -1>>,
|
static_assert(is_same_v<make_dimension<units::exp<d0, -1>, units::exp<d1, -1>, units::exp<d0, -1>, units::exp<d1, -1>>,
|
||||||
derived_dim<units::exp<d0, -2>, units::exp<d1, -2>>>);
|
derived_dim<units::exp<d0, -2>, units::exp<d1, -2>>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d1, -1>>, derived_dim<units::exp<d0, 1>>>);
|
static_assert(is_same_v<make_dimension<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d1, -1>>, derived_dim<units::exp<d0, 1>>>);
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d0, 1>, units::exp<d0, -1>, units::exp<d1, 1>>, derived_dim<units::exp<d1, 1>>>);
|
static_assert(is_same_v<make_dimension<units::exp<d0, 1>, units::exp<d0, -1>, units::exp<d1, 1>>, derived_dim<units::exp<d1, 1>>>);
|
||||||
static_assert(std::is_same_v<make_dimension<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d0, -1>>, derived_dim<units::exp<d1, 1>>>);
|
static_assert(is_same_v<make_dimension<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d0, -1>>, derived_dim<units::exp<d1, 1>>>);
|
||||||
|
|
||||||
// dimension_multiply
|
// dimension_multiply
|
||||||
|
|
||||||
static_assert(std::is_same_v<dimension_multiply<derived_dim<units::exp<d0, 1>>, derived_dim<units::exp<d1, 1>>>,
|
static_assert(is_same_v<dimension_multiply<derived_dim<units::exp<d0, 1>>, derived_dim<units::exp<d1, 1>>>,
|
||||||
unknown_dimension<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
unknown_dimension<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<dimension_multiply<derived_dim<units::exp<d0, 1>>, d1>, unknown_dimension<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
is_same_v<dimension_multiply<derived_dim<units::exp<d0, 1>>, d1>, unknown_dimension<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<dimension_multiply<d0, derived_dim<units::exp<d1, 1>>>, unknown_dimension<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
is_same_v<dimension_multiply<d0, derived_dim<units::exp<d1, 1>>>, unknown_dimension<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
||||||
static_assert(std::is_same_v<dimension_multiply<d0, d1>, unknown_dimension<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
static_assert(is_same_v<dimension_multiply<d0, d1>, unknown_dimension<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
||||||
static_assert(std::is_same_v<
|
static_assert(is_same_v<
|
||||||
dimension_multiply<derived_dim<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d2, 1>>, derived_dim<units::exp<d3, 1>>>,
|
dimension_multiply<derived_dim<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d2, 1>>, derived_dim<units::exp<d3, 1>>>,
|
||||||
unknown_dimension<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d2, 1>, units::exp<d3, 1>>>);
|
unknown_dimension<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d2, 1>, units::exp<d3, 1>>>);
|
||||||
static_assert(std::is_same_v<
|
static_assert(is_same_v<
|
||||||
dimension_multiply<derived_dim<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d2, 1>>, derived_dim<units::exp<d1, 1>>>,
|
dimension_multiply<derived_dim<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d2, 1>>, derived_dim<units::exp<d1, 1>>>,
|
||||||
unknown_dimension<units::exp<d0, 1>, units::exp<d1, 2>, units::exp<d2, 1>>>);
|
unknown_dimension<units::exp<d0, 1>, units::exp<d1, 2>, units::exp<d2, 1>>>);
|
||||||
static_assert(std::is_same_v<
|
static_assert(is_same_v<
|
||||||
dimension_multiply<derived_dim<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d2, 1>>, derived_dim<units::exp<d1, -1>>>,
|
dimension_multiply<derived_dim<units::exp<d0, 1>, units::exp<d1, 1>, units::exp<d2, 1>>, derived_dim<units::exp<d1, -1>>>,
|
||||||
unknown_dimension<units::exp<d0, 1>, units::exp<d2, 1>>>);
|
unknown_dimension<units::exp<d0, 1>, units::exp<d2, 1>>>);
|
||||||
static_assert(std::is_same_v<dimension_multiply<derived_dim<units::exp<d0, 2>>, derived_dim<units::exp<d0, -1>>>, d0>);
|
static_assert(is_same_v<dimension_multiply<derived_dim<units::exp<d0, 2>>, derived_dim<units::exp<d0, -1>>>, d0>);
|
||||||
|
|
||||||
// dimension_divide
|
// dimension_divide
|
||||||
|
|
||||||
static_assert(std::is_same_v<dimension_divide<derived_dim<units::exp<d0, 1>>, derived_dim<units::exp<d1, 1>>>,
|
static_assert(is_same_v<dimension_divide<derived_dim<units::exp<d0, 1>>, derived_dim<units::exp<d1, 1>>>,
|
||||||
unknown_dimension<units::exp<d0, 1>, units::exp<d1, -1>>>);
|
unknown_dimension<units::exp<d0, 1>, units::exp<d1, -1>>>);
|
||||||
static_assert(std::is_same_v<dimension_divide<derived_dim<units::exp<d0, 2>>, unknown_dimension<units::exp<d0, 1>>>, d0>);
|
static_assert(is_same_v<dimension_divide<derived_dim<units::exp<d0, 2>>, unknown_dimension<units::exp<d0, 1>>>, d0>);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -27,17 +27,18 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using namespace units;
|
||||||
using namespace units::physical::si::literals;
|
using namespace units::physical::si::literals;
|
||||||
using namespace units::physical::international::literals;
|
using namespace units::physical::international::literals;
|
||||||
|
|
||||||
static_assert(std::is_same_v<decltype(pow<0>(2q_m)), std::int64_t>);
|
static_assert(is_same_v<decltype(pow<0>(2q_m)), std::int64_t>);
|
||||||
static_assert(std::is_same_v<decltype(pow<1>(2q_m)), decltype(2q_m)>);
|
static_assert(is_same_v<decltype(pow<1>(2q_m)), decltype(2q_m)>);
|
||||||
static_assert(std::is_same_v<decltype(pow<2>(2q_m)), decltype(4q_m2)>);
|
static_assert(is_same_v<decltype(pow<2>(2q_m)), decltype(4q_m2)>);
|
||||||
static_assert(std::is_same_v<decltype(pow<2>(2q_km)), decltype(4q_km2)>);
|
static_assert(is_same_v<decltype(pow<2>(2q_km)), decltype(4q_km2)>);
|
||||||
static_assert(std::is_same_v<decltype(pow<2>(2q_ft)), decltype(4q_ft2)>);
|
static_assert(is_same_v<decltype(pow<2>(2q_ft)), decltype(4q_ft2)>);
|
||||||
static_assert(std::is_same_v<decltype(sqrt(4q_m2)), decltype(2q_m)>);
|
static_assert(is_same_v<decltype(sqrt(4q_m2)), decltype(2q_m)>);
|
||||||
static_assert(std::is_same_v<decltype(sqrt(4q_km2)), decltype(2q_km)>);
|
static_assert(is_same_v<decltype(sqrt(4q_km2)), decltype(2q_km)>);
|
||||||
static_assert(std::is_same_v<decltype(sqrt(4q_ft2)), decltype(2q_ft)>);
|
static_assert(is_same_v<decltype(sqrt(4q_ft2)), decltype(2q_ft)>);
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -51,10 +51,10 @@ static_assert(invalid_types<physical::si::dim_length>);
|
|||||||
|
|
||||||
// member types
|
// member types
|
||||||
|
|
||||||
static_assert(std::is_same_v<quantity_point<dim_length, metre, int>::rep, int>);
|
static_assert(is_same_v<quantity_point<dim_length, metre, int>::rep, int>);
|
||||||
static_assert(std::is_same_v<quantity_point<dim_length, metre, double>::rep, double>);
|
static_assert(is_same_v<quantity_point<dim_length, metre, double>::rep, double>);
|
||||||
static_assert(std::is_same_v<quantity_point<dim_length, metre, int>::unit, metre>);
|
static_assert(is_same_v<quantity_point<dim_length, metre, int>::unit, metre>);
|
||||||
static_assert(std::is_same_v<quantity_point<dim_length, kilometre, int>::unit, kilometre>);
|
static_assert(is_same_v<quantity_point<dim_length, kilometre, int>::unit, kilometre>);
|
||||||
|
|
||||||
// constructors
|
// constructors
|
||||||
|
|
||||||
@ -119,23 +119,23 @@ static_assert((quantity_point(2q_m) -= 1q_m).relative().count() == 1);
|
|||||||
|
|
||||||
// non-member arithmetic operators
|
// non-member arithmetic operators
|
||||||
|
|
||||||
static_assert(std::is_same_v<decltype(quantity_point<dim_length, metre, int>() + length<metre, double>()),
|
static_assert(is_same_v<decltype(quantity_point<dim_length, metre, int>() + length<metre, double>()),
|
||||||
quantity_point<dim_length, metre, double>>);
|
quantity_point<dim_length, metre, double>>);
|
||||||
static_assert(std::is_same_v<decltype(length<metre, int>() + quantity_point<dim_length, metre, double>()),
|
static_assert(is_same_v<decltype(length<metre, int>() + quantity_point<dim_length, metre, double>()),
|
||||||
quantity_point<dim_length, metre, double>>);
|
quantity_point<dim_length, metre, double>>);
|
||||||
static_assert(std::is_same_v<decltype(quantity_point<dim_length, kilometre, int>() + length<metre, double>()),
|
static_assert(is_same_v<decltype(quantity_point<dim_length, kilometre, int>() + length<metre, double>()),
|
||||||
quantity_point<dim_length, metre, double>>);
|
quantity_point<dim_length, metre, double>>);
|
||||||
static_assert(std::is_same_v<decltype(length<kilometre, int>() + quantity_point<dim_length, metre, double>()),
|
static_assert(is_same_v<decltype(length<kilometre, int>() + quantity_point<dim_length, metre, double>()),
|
||||||
quantity_point<dim_length, metre, double>>);
|
quantity_point<dim_length, metre, double>>);
|
||||||
static_assert(std::is_same_v<decltype(quantity_point<dim_length, metre, double>() - length<metre, int>()),
|
static_assert(is_same_v<decltype(quantity_point<dim_length, metre, double>() - length<metre, int>()),
|
||||||
quantity_point<dim_length, metre, double>>);
|
quantity_point<dim_length, metre, double>>);
|
||||||
static_assert(std::is_same_v<decltype(quantity_point<dim_length, kilometre, double>() - length<metre, int>()),
|
static_assert(is_same_v<decltype(quantity_point<dim_length, kilometre, double>() - length<metre, int>()),
|
||||||
quantity_point<dim_length, metre, double>>);
|
quantity_point<dim_length, metre, double>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<decltype(quantity_point<dim_length, metre, double>() - quantity_point<dim_length, metre, int>()),
|
is_same_v<decltype(quantity_point<dim_length, metre, double>() - quantity_point<dim_length, metre, int>()),
|
||||||
length<metre, double>>);
|
length<metre, double>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<decltype(quantity_point<dim_length, kilometre, double>() - quantity_point<dim_length, metre, int>()),
|
is_same_v<decltype(quantity_point<dim_length, kilometre, double>() - quantity_point<dim_length, metre, int>()),
|
||||||
length<metre, double>>);
|
length<metre, double>>);
|
||||||
|
|
||||||
static_assert((1q_m + km).relative().count() == 1001);
|
static_assert((1q_m + km).relative().count() == 1001);
|
||||||
@ -187,13 +187,13 @@ static_assert(QuantityPoint<quantity_point<dim_length, millimetre, int>>);
|
|||||||
|
|
||||||
// common_quantity_point
|
// common_quantity_point
|
||||||
|
|
||||||
static_assert(std::is_same_v<
|
static_assert(is_same_v<
|
||||||
common_quantity_point<quantity_point<dim_length, metre, int>, quantity_point<dim_length, kilometre, int>>,
|
common_quantity_point<quantity_point<dim_length, metre, int>, quantity_point<dim_length, kilometre, int>>,
|
||||||
quantity_point<dim_length, metre, int>>);
|
quantity_point<dim_length, metre, int>>);
|
||||||
static_assert(std::is_same_v<common_quantity_point<quantity_point<dim_length, kilometre, long long>,
|
static_assert(is_same_v<common_quantity_point<quantity_point<dim_length, kilometre, long long>,
|
||||||
quantity_point<dim_length, metre, int>>,
|
quantity_point<dim_length, metre, int>>,
|
||||||
quantity_point<dim_length, metre, long long>>);
|
quantity_point<dim_length, metre, long long>>);
|
||||||
static_assert(std::is_same_v<common_quantity_point<quantity_point<dim_length, kilometre, long long>,
|
static_assert(is_same_v<common_quantity_point<quantity_point<dim_length, kilometre, long long>,
|
||||||
quantity_point<dim_length, millimetre, double>>,
|
quantity_point<dim_length, millimetre, double>>,
|
||||||
quantity_point<dim_length, millimetre, double>>);
|
quantity_point<dim_length, millimetre, double>>);
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ static_assert(std::equality_comparable_with<decltype(quantity_point(1q_m)), decl
|
|||||||
// quantity_cast
|
// quantity_cast
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<decltype(quantity_point_cast<scaled_unit<ratio(1), metre>>(quantity_point(2q_km)))::unit, metre>);
|
is_same_v<decltype(quantity_point_cast<scaled_unit<ratio(1), metre>>(quantity_point(2q_km)))::unit, metre>);
|
||||||
|
|
||||||
static_assert(quantity_point_cast<quantity_point<dim_length, metre, int>>(quantity_point(2q_km)).relative().count() ==
|
static_assert(quantity_point_cast<quantity_point<dim_length, metre, int>>(quantity_point(2q_km)).relative().count() ==
|
||||||
2000);
|
2000);
|
||||||
|
@ -43,10 +43,10 @@ using namespace units::physical::si;
|
|||||||
|
|
||||||
// member types
|
// member types
|
||||||
|
|
||||||
static_assert(std::is_same_v<length<metre, int>::rep, int>);
|
static_assert(is_same_v<length<metre, int>::rep, int>);
|
||||||
static_assert(std::is_same_v<length<metre, double>::rep, double>);
|
static_assert(is_same_v<length<metre, double>::rep, double>);
|
||||||
static_assert(std::is_same_v<length<metre, int>::unit, metre>);
|
static_assert(is_same_v<length<metre, int>::unit, metre>);
|
||||||
static_assert(std::is_same_v<length<kilometre, int>::unit, kilometre>);
|
static_assert(is_same_v<length<kilometre, int>::unit, kilometre>);
|
||||||
|
|
||||||
// constructors
|
// constructors
|
||||||
|
|
||||||
@ -126,37 +126,37 @@ static_assert((7q_m %= 2q_m).count() == 1);
|
|||||||
|
|
||||||
// non-member arithmetic operators
|
// non-member arithmetic operators
|
||||||
|
|
||||||
static_assert(std::is_same_v<decltype(length<metre, int>() + length<metre, double>()), length<metre, double>>);
|
static_assert(is_same_v<decltype(length<metre, int>() + length<metre, double>()), length<metre, double>>);
|
||||||
static_assert(std::is_same_v<decltype(length<metre, int>() + length<metre, double>()), length<metre, double>>);
|
static_assert(is_same_v<decltype(length<metre, int>() + length<metre, double>()), length<metre, double>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<decltype(length<kilometre, int>() + length<metre, double>()), length<metre, double>>);
|
is_same_v<decltype(length<kilometre, int>() + length<metre, double>()), length<metre, double>>);
|
||||||
static_assert(std::is_same_v<decltype(length<metre, double>() - length<metre, int>()), length<metre, double>>);
|
static_assert(is_same_v<decltype(length<metre, double>() - length<metre, int>()), length<metre, double>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<decltype(length<kilometre, double>() - length<metre, int>()), length<metre, double>>);
|
is_same_v<decltype(length<kilometre, double>() - length<metre, int>()), length<metre, double>>);
|
||||||
static_assert(std::is_same_v<decltype(length<metre, int>() * 1.0), length<metre, double>>);
|
static_assert(is_same_v<decltype(length<metre, int>() * 1.0), length<metre, double>>);
|
||||||
static_assert(std::is_same_v<decltype(1.0 * length<metre, int>()), length<metre, double>>);
|
static_assert(is_same_v<decltype(1.0 * length<metre, int>()), length<metre, double>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<decltype(speed<metre_per_second, int>() * physical::si::time<second, int>()), length<metre, int>>);
|
is_same_v<decltype(speed<metre_per_second, int>() * physical::si::time<second, int>()), length<metre, int>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<decltype(speed<metre_per_second, int>() * physical::si::time<hour, int>()), length<scaled_unit<ratio(36, 1, 2), metre>, int>>);
|
is_same_v<decltype(speed<metre_per_second, int>() * physical::si::time<hour, int>()), length<scaled_unit<ratio(36, 1, 2), metre>, int>>);
|
||||||
static_assert(std::is_same_v<decltype(length<metre>() * physical::si::time<minute>()),
|
static_assert(is_same_v<decltype(length<metre>() * physical::si::time<minute>()),
|
||||||
quantity<unknown_dimension<units::exp<dim_length, 1>, units::exp<dim_time, 1>>, scaled_unit<ratio(6, 1, 1), unknown_coherent_unit>>>);
|
quantity<unknown_dimension<units::exp<dim_length, 1>, units::exp<dim_time, 1>>, scaled_unit<ratio(6, 1, 1), unknown_coherent_unit>>>);
|
||||||
static_assert(std::is_same_v<decltype(1 / physical::si::time<second, int>()), frequency<hertz, int>>);
|
static_assert(is_same_v<decltype(1 / physical::si::time<second, int>()), frequency<hertz, int>>);
|
||||||
static_assert(std::is_same_v<decltype(1 / physical::si::time<minute, int>()), frequency<scaled_unit<ratio(1, 6, -1), hertz>, int>>);
|
static_assert(is_same_v<decltype(1 / physical::si::time<minute, int>()), frequency<scaled_unit<ratio(1, 6, -1), hertz>, int>>);
|
||||||
static_assert(std::is_same_v<decltype(1 / frequency<hertz, int>()), physical::si::time<second, int>>);
|
static_assert(is_same_v<decltype(1 / frequency<hertz, int>()), physical::si::time<second, int>>);
|
||||||
static_assert(std::is_same_v<decltype(1 / length<kilometre>()),
|
static_assert(is_same_v<decltype(1 / length<kilometre>()),
|
||||||
quantity<unknown_dimension<units::exp<dim_length, -1>>, scaled_unit<ratio(1, 1, -3), unknown_coherent_unit>>>);
|
quantity<unknown_dimension<units::exp<dim_length, -1>>, scaled_unit<ratio(1, 1, -3), unknown_coherent_unit>>>);
|
||||||
static_assert(std::is_same_v<decltype(length<metre, int>() / 1.0), length<metre, double>>);
|
static_assert(is_same_v<decltype(length<metre, int>() / 1.0), length<metre, double>>);
|
||||||
static_assert(std::is_same_v<decltype(length<metre, int>() / length<metre, double>()), double>);
|
static_assert(is_same_v<decltype(length<metre, int>() / length<metre, double>()), double>);
|
||||||
static_assert(std::is_same_v<decltype(length<kilometre, int>() / length<metre, double>()), double>);
|
static_assert(is_same_v<decltype(length<kilometre, int>() / length<metre, double>()), double>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<decltype(length<metre, int>() / physical::si::time<second, int>()), speed<metre_per_second, int>>);
|
is_same_v<decltype(length<metre, int>() / physical::si::time<second, int>()), speed<metre_per_second, int>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<decltype(length<metre>() / physical::si::time<minute>()), speed<scaled_unit<ratio(1, 6, -1), metre_per_second>>>);
|
is_same_v<decltype(length<metre>() / physical::si::time<minute>()), speed<scaled_unit<ratio(1, 6, -1), metre_per_second>>>);
|
||||||
static_assert(std::is_same_v<decltype(physical::si::time<minute>() / length<metre>()),
|
static_assert(is_same_v<decltype(physical::si::time<minute>() / length<metre>()),
|
||||||
quantity<unknown_dimension<units::exp<dim_length, -1>, units::exp<dim_time, 1>>, scaled_unit<ratio(6 ,1 , 1), unknown_coherent_unit>>>);
|
quantity<unknown_dimension<units::exp<dim_length, -1>, units::exp<dim_time, 1>>, scaled_unit<ratio(6 ,1 , 1), unknown_coherent_unit>>>);
|
||||||
static_assert(std::is_same_v<decltype(length<metre, int>() % short(1)), length<metre, int>>);
|
static_assert(is_same_v<decltype(length<metre, int>() % short(1)), length<metre, int>>);
|
||||||
static_assert(std::is_same_v<decltype(length<metre, int>() % length<metre, short>(1)), length<metre, int>>);
|
static_assert(is_same_v<decltype(length<metre, int>() % length<metre, short>(1)), length<metre, int>>);
|
||||||
|
|
||||||
static_assert((1q_m + km).count() == 1001);
|
static_assert((1q_m + km).count() == 1001);
|
||||||
static_assert((1q_m + 1q_km).count() == 1001);
|
static_assert((1q_m + 1q_km).count() == 1001);
|
||||||
@ -217,10 +217,10 @@ static_assert(Quantity<length<millimetre, int>>);
|
|||||||
|
|
||||||
// common_quantity
|
// common_quantity
|
||||||
|
|
||||||
static_assert(std::is_same_v<common_quantity<length<metre, int>, length<kilometre, int>>, length<metre, int>>);
|
static_assert(is_same_v<common_quantity<length<metre, int>, length<kilometre, int>>, length<metre, int>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<common_quantity<length<kilometre, long long>, length<metre, int>>, length<metre, long long>>);
|
is_same_v<common_quantity<length<kilometre, long long>, length<metre, int>>, length<metre, long long>>);
|
||||||
static_assert(std::is_same_v<common_quantity<length<kilometre, long long>, length<millimetre, double>>,
|
static_assert(is_same_v<common_quantity<length<kilometre, long long>, length<millimetre, double>>,
|
||||||
length<millimetre, double>>);
|
length<millimetre, double>>);
|
||||||
|
|
||||||
// common_type
|
// common_type
|
||||||
@ -234,7 +234,7 @@ static_assert(std::equality_comparable_with<decltype(1q_m), decltype(1q_ft_us)>)
|
|||||||
|
|
||||||
// quantity_cast
|
// quantity_cast
|
||||||
|
|
||||||
static_assert(std::is_same_v<decltype(quantity_cast<scaled_unit<ratio(1), metre>>(2q_km))::unit, metre>);
|
static_assert(is_same_v<decltype(quantity_cast<scaled_unit<ratio(1), metre>>(2q_km))::unit, metre>);
|
||||||
|
|
||||||
static_assert(quantity_cast<length<metre, int>>(2q_km).count() == 2000);
|
static_assert(quantity_cast<length<metre, int>>(2q_km).count() == 2000);
|
||||||
static_assert(quantity_cast<length<kilometre, int>>(2000q_m).count() == 2);
|
static_assert(quantity_cast<length<kilometre, int>>(2000q_m).count() == 2);
|
||||||
@ -263,6 +263,6 @@ static_assert(1q_km / 1q_s == 1000q_m_per_s);
|
|||||||
static_assert(2q_km_per_h * 2q_h == 4q_km);
|
static_assert(2q_km_per_h * 2q_h == 4q_km);
|
||||||
static_assert(2q_km / 2q_km_per_h == 1q_h);
|
static_assert(2q_km / 2q_km_per_h == 1q_h);
|
||||||
|
|
||||||
static_assert(std::is_same_v<decltype(pow<2>(2q_m)), decltype(4q_m2)>);
|
static_assert(is_same_v<decltype(pow<2>(2q_m)), decltype(4q_m2)>);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -237,7 +237,7 @@ static_assert(kilogray::symbol == "kGy");
|
|||||||
|
|
||||||
// speed
|
// speed
|
||||||
|
|
||||||
static_assert(std::is_same_v<decltype(1q_km / 1q_s), speed<scaled_unit<ratio(1, 1, 3), metre_per_second>, std::int64_t>>);
|
static_assert(is_same_v<decltype(1q_km / 1q_s), speed<scaled_unit<ratio(1, 1, 3), metre_per_second>, std::int64_t>>);
|
||||||
|
|
||||||
static_assert(10q_m / 5q_s == 2q_m_per_s);
|
static_assert(10q_m / 5q_s == 2q_m_per_s);
|
||||||
static_assert(10 / 5q_s * 1q_m == 2q_m_per_s);
|
static_assert(10 / 5q_s * 1q_m == 2q_m_per_s);
|
||||||
|
@ -34,63 +34,63 @@ struct type_list;
|
|||||||
|
|
||||||
// type_list_push_front
|
// type_list_push_front
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_push_front<type_list<>, int>, type_list<int>>);
|
static_assert(is_same_v<type_list_push_front<type_list<>, int>, type_list<int>>);
|
||||||
static_assert(std::is_same_v<type_list_push_front<type_list<>, int, long, double>, type_list<int, long, double>>);
|
static_assert(is_same_v<type_list_push_front<type_list<>, int, long, double>, type_list<int, long, double>>);
|
||||||
static_assert(std::is_same_v<type_list_push_front<type_list<double>, int, long>, type_list<int, long, double>>);
|
static_assert(is_same_v<type_list_push_front<type_list<double>, int, long>, type_list<int, long, double>>);
|
||||||
|
|
||||||
// type_list_push_back
|
// type_list_push_back
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_push_back<type_list<>, int>, type_list<int>>);
|
static_assert(is_same_v<type_list_push_back<type_list<>, int>, type_list<int>>);
|
||||||
static_assert(std::is_same_v<type_list_push_back<type_list<>, int, long, double>, type_list<int, long, double>>);
|
static_assert(is_same_v<type_list_push_back<type_list<>, int, long, double>, type_list<int, long, double>>);
|
||||||
static_assert(std::is_same_v<type_list_push_back<type_list<double>, int, long>, type_list<double, int, long>>);
|
static_assert(is_same_v<type_list_push_back<type_list<double>, int, long>, type_list<double, int, long>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_join<type_list<>>, type_list<>>);
|
static_assert(is_same_v<type_list_join<type_list<>>, type_list<>>);
|
||||||
static_assert(std::is_same_v<type_list_join<type_list<>, type_list<>>, type_list<>>);
|
static_assert(is_same_v<type_list_join<type_list<>, type_list<>>, type_list<>>);
|
||||||
static_assert(std::is_same_v<type_list_join<type_list<>, type_list<>, type_list<>>, type_list<>>);
|
static_assert(is_same_v<type_list_join<type_list<>, type_list<>, type_list<>>, type_list<>>);
|
||||||
static_assert(std::is_same_v<type_list_join<type_list<int>, type_list<>, type_list<>>, type_list<int>>);
|
static_assert(is_same_v<type_list_join<type_list<int>, type_list<>, type_list<>>, type_list<int>>);
|
||||||
static_assert(std::is_same_v<type_list_join<type_list<>, type_list<int>, type_list<>>, type_list<int>>);
|
static_assert(is_same_v<type_list_join<type_list<>, type_list<int>, type_list<>>, type_list<int>>);
|
||||||
static_assert(std::is_same_v<type_list_join<type_list<>, type_list<>, type_list<int>>, type_list<int>>);
|
static_assert(is_same_v<type_list_join<type_list<>, type_list<>, type_list<int>>, type_list<int>>);
|
||||||
static_assert(std::is_same_v<type_list_join<type_list<int>, type_list<float>, type_list<bool>>, type_list<int, float, bool>>);
|
static_assert(is_same_v<type_list_join<type_list<int>, type_list<float>, type_list<bool>>, type_list<int, float, bool>>);
|
||||||
static_assert(std::is_same_v<type_list_join<type_list<int, short>, type_list<float, double>, type_list<bool>>, type_list<int, short, float, double, bool>>);
|
static_assert(is_same_v<type_list_join<type_list<int, short>, type_list<float, double>, type_list<bool>>, type_list<int, short, float, double, bool>>);
|
||||||
|
|
||||||
// type_list_split
|
// type_list_split
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int>, 0>::first_list, type_list<>>);
|
static_assert(is_same_v<type_list_split<type_list<int>, 0>::first_list, type_list<>>);
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int>, 0>::second_list, type_list<int>>);
|
static_assert(is_same_v<type_list_split<type_list<int>, 0>::second_list, type_list<int>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int>, 1>::first_list, type_list<int>>);
|
static_assert(is_same_v<type_list_split<type_list<int>, 1>::first_list, type_list<int>>);
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int>, 1>::second_list, type_list<>>);
|
static_assert(is_same_v<type_list_split<type_list<int>, 1>::second_list, type_list<>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int, long>, 0>::first_list, type_list<>>);
|
static_assert(is_same_v<type_list_split<type_list<int, long>, 0>::first_list, type_list<>>);
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int, long>, 0>::second_list, type_list<int, long>>);
|
static_assert(is_same_v<type_list_split<type_list<int, long>, 0>::second_list, type_list<int, long>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int, long>, 1>::first_list, type_list<int>>);
|
static_assert(is_same_v<type_list_split<type_list<int, long>, 1>::first_list, type_list<int>>);
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int, long>, 1>::second_list, type_list<long>>);
|
static_assert(is_same_v<type_list_split<type_list<int, long>, 1>::second_list, type_list<long>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int, long>, 2>::first_list, type_list<int, long>>);
|
static_assert(is_same_v<type_list_split<type_list<int, long>, 2>::first_list, type_list<int, long>>);
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int, long>, 2>::second_list, type_list<>>);
|
static_assert(is_same_v<type_list_split<type_list<int, long>, 2>::second_list, type_list<>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int, long, double>, 1>::first_list, type_list<int>>);
|
static_assert(is_same_v<type_list_split<type_list<int, long, double>, 1>::first_list, type_list<int>>);
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int, long, double>, 1>::second_list, type_list<long, double>>);
|
static_assert(is_same_v<type_list_split<type_list<int, long, double>, 1>::second_list, type_list<long, double>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int, long, double>, 2>::first_list, type_list<int, long>>);
|
static_assert(is_same_v<type_list_split<type_list<int, long, double>, 2>::first_list, type_list<int, long>>);
|
||||||
static_assert(std::is_same_v<type_list_split<type_list<int, long, double>, 2>::second_list, type_list<double>>);
|
static_assert(is_same_v<type_list_split<type_list<int, long, double>, 2>::second_list, type_list<double>>);
|
||||||
|
|
||||||
// type_list_split_half
|
// type_list_split_half
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_split_half<type_list<int>>::first_list, type_list<int>>);
|
static_assert(is_same_v<type_list_split_half<type_list<int>>::first_list, type_list<int>>);
|
||||||
static_assert(std::is_same_v<type_list_split_half<type_list<int>>::second_list, type_list<>>);
|
static_assert(is_same_v<type_list_split_half<type_list<int>>::second_list, type_list<>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_split_half<type_list<int, long>>::first_list, type_list<int>>);
|
static_assert(is_same_v<type_list_split_half<type_list<int, long>>::first_list, type_list<int>>);
|
||||||
static_assert(std::is_same_v<type_list_split_half<type_list<int, long>>::second_list, type_list<long>>);
|
static_assert(is_same_v<type_list_split_half<type_list<int, long>>::second_list, type_list<long>>);
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_split_half<type_list<int, long, double>>::first_list, type_list<int, long>>);
|
static_assert(is_same_v<type_list_split_half<type_list<int, long, double>>::first_list, type_list<int, long>>);
|
||||||
static_assert(std::is_same_v<type_list_split_half<type_list<int, long, double>>::second_list, type_list<double>>);
|
static_assert(is_same_v<type_list_split_half<type_list<int, long, double>>::second_list, type_list<double>>);
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<type_list_split_half<type_list<int, long, double, float>>::first_list, type_list<int, long>>);
|
is_same_v<type_list_split_half<type_list<int, long, double, float>>::first_list, type_list<int, long>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<type_list_split_half<type_list<int, long, double, float>>::second_list, type_list<double, float>>);
|
is_same_v<type_list_split_half<type_list<int, long, double, float>>::second_list, type_list<double, float>>);
|
||||||
|
|
||||||
// type_list_merge_sorted
|
// type_list_merge_sorted
|
||||||
struct u0 : named_unit<u0, "u0", no_prefix> {};
|
struct u0 : named_unit<u0, "u0", no_prefix> {};
|
||||||
@ -98,9 +98,9 @@ struct d0 : base_dimension<"d0", u0> {};
|
|||||||
struct u1 : named_unit<u1, "u1", no_prefix> {};
|
struct u1 : named_unit<u1, "u1", no_prefix> {};
|
||||||
struct d1 : base_dimension<"d1", u1> {};
|
struct d1 : base_dimension<"d1", u1> {};
|
||||||
|
|
||||||
static_assert(std::is_same_v<type_list_merge_sorted<type_list<units::exp<d0, 1>>, type_list<units::exp<d1, 1>>, exp_less>,
|
static_assert(is_same_v<type_list_merge_sorted<type_list<units::exp<d0, 1>>, type_list<units::exp<d1, 1>>, exp_less>,
|
||||||
type_list<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
type_list<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
||||||
static_assert(std::is_same_v<type_list_merge_sorted<type_list<units::exp<d1, 1>>, type_list<units::exp<d0, 1>>, exp_less>,
|
static_assert(is_same_v<type_list_merge_sorted<type_list<units::exp<d1, 1>>, type_list<units::exp<d0, 1>>, exp_less>,
|
||||||
type_list<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
type_list<units::exp<d0, 1>, units::exp<d1, 1>>>);
|
||||||
|
|
||||||
// type_list_sort
|
// type_list_sort
|
||||||
@ -108,10 +108,10 @@ static_assert(std::is_same_v<type_list_merge_sorted<type_list<units::exp<d1, 1>>
|
|||||||
template<TypeList List>
|
template<TypeList List>
|
||||||
using exp_sort = type_list_sort<List, exp_less>;
|
using exp_sort = type_list_sort<List, exp_less>;
|
||||||
|
|
||||||
static_assert(std::is_same_v<exp_sort<exp_list<units::exp<d0, 1>>>, exp_list<units::exp<d0, 1>>>);
|
static_assert(is_same_v<exp_sort<exp_list<units::exp<d0, 1>>>, exp_list<units::exp<d0, 1>>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<exp_sort<exp_list<units::exp<d0, 1>, units::exp<d1, -1>>>, exp_list<units::exp<d0, 1>, units::exp<d1, -1>>>);
|
is_same_v<exp_sort<exp_list<units::exp<d0, 1>, units::exp<d1, -1>>>, exp_list<units::exp<d0, 1>, units::exp<d1, -1>>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same_v<exp_sort<exp_list<units::exp<d1, 1>, units::exp<d0, -1>>>, exp_list<units::exp<d0, -1>, units::exp<d1, 1>>>);
|
is_same_v<exp_sort<exp_list<units::exp<d1, 1>, units::exp<d0, -1>>>, exp_list<units::exp<d0, -1>, units::exp<d1, 1>>>);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -46,11 +46,11 @@ struct metre_per_second : unit<metre_per_second> {};
|
|||||||
struct dim_speed : derived_dimension<dim_speed, metre_per_second, units::exp<dim_length, 1>, units::exp<dim_time, -1>> {};
|
struct dim_speed : derived_dimension<dim_speed, metre_per_second, units::exp<dim_length, 1>, units::exp<dim_time, -1>> {};
|
||||||
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||||
|
|
||||||
static_assert(std::is_same_v<downcast<scaled_unit<ratio(1), metre>>, metre>);
|
static_assert(is_same_v<downcast<scaled_unit<ratio(1), metre>>, metre>);
|
||||||
static_assert(std::is_same_v<downcast<scaled_unit<ratio(1, 1, -2), metre>>, centimetre>);
|
static_assert(is_same_v<downcast<scaled_unit<ratio(1, 1, -2), metre>>, centimetre>);
|
||||||
static_assert(std::is_same_v<downcast<scaled_unit<ratio(yard::ratio.num, yard::ratio.den, yard::ratio.exp), metre>>, yard>);
|
static_assert(is_same_v<downcast<scaled_unit<ratio(yard::ratio.num, yard::ratio.den, yard::ratio.exp), metre>>, yard>);
|
||||||
static_assert(std::is_same_v<downcast<scaled_unit<yard::ratio * ratio(1, 3), metre>>, foot>);
|
static_assert(is_same_v<downcast<scaled_unit<yard::ratio * ratio(1, 3), metre>>, foot>);
|
||||||
static_assert(std::is_same_v<downcast<scaled_unit<kilometre::ratio / hour::ratio, metre_per_second>>, kilometre_per_hour>);
|
static_assert(is_same_v<downcast<scaled_unit<kilometre::ratio / hour::ratio, metre_per_second>>, kilometre_per_hour>);
|
||||||
|
|
||||||
static_assert(centimetre::symbol == "cm");
|
static_assert(centimetre::symbol == "cm");
|
||||||
static_assert(kilometre::symbol == "km");
|
static_assert(kilometre::symbol == "km");
|
||||||
|
Reference in New Issue
Block a user