Custom is_same implementation added

This commit is contained in:
Mateusz Pusz
2020-06-29 20:30:59 +02:00
parent 7eccef78a9
commit 9f94a73bba
14 changed files with 168 additions and 157 deletions
+3 -3
View File
@@ -85,7 +85,7 @@ and `si::metre` is a :term:`base unit` of this base dimension. We can
obtain those back easily with::
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
@@ -169,8 +169,8 @@ Obtaining a Unit of the Dimension
In order to obtain the base/coherent unit of any dimension type a
`dimension_unit` helper was introduced::
static_assert(std::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_length>, si::metre>);
static_assert(is_same_v<dimension_unit<si::dim_speed>, si::metre_per_second>);
.. rubric:: Citations:
+6 -6
View File
@@ -27,8 +27,8 @@ will determine its type. The same applies to the resulting unit. For example:
using namespace units::physical::si;
constexpr auto result = 144q_km / 2q_h;
static_assert(std::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)::dimension, dim_speed>);
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
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;
constexpr auto result = 144q_km / 2q_h;
static_assert(std::is_same_v<decltype(result)::dimension,
unknown_dimension<exp<dim_length, 1>, exp<dim_time, -1>>>);
static_assert(std::is_same_v<decltype(result)::unit,
scaled_unit<ratio<1, 36, 1>, unknown_coherent_unit>>);
static_assert(is_same_v<decltype(result)::dimension,
unknown_dimension<exp<dim_length, 1>, exp<dim_time, -1>>>);
static_assert(is_same_v<decltype(result)::unit,
scaled_unit<ratio(1, 36, 1), unknown_coherent_unit>>);
Operations On Unknown Dimensions And Their Units