2018-09-29 18:08:02 -07:00
|
|
|
// The MIT License (MIT)
|
|
|
|
|
//
|
|
|
|
|
// Copyright (c) 2018 Mateusz Pusz
|
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
// copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
// SOFTWARE.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
#include <units/bits/expression_template.h>
|
|
|
|
|
#include <units/bits/external/fixed_string.h>
|
|
|
|
|
#include <units/bits/external/type_name.h>
|
2022-08-01 11:59:00 +02:00
|
|
|
#include <units/bits/external/type_traits.h>
|
2022-09-08 19:11:45 +02:00
|
|
|
#include <units/magnitude.h>
|
|
|
|
|
#include <units/symbol_text.h>
|
|
|
|
|
|
|
|
|
|
// #include <units/bits/derived_symbol_text.h>
|
2021-03-30 13:21:05 +02:00
|
|
|
|
|
|
|
|
// IWYU pragma: begin_exports
|
2022-09-08 19:11:45 +02:00
|
|
|
// #include <units/bits/absolute_magnitude.h>
|
|
|
|
|
// #include <units/ratio.h>
|
2021-03-30 13:21:05 +02:00
|
|
|
// IWYU pragma: end_exports
|
2018-09-29 18:08:02 -07:00
|
|
|
|
2019-09-18 21:55:16 -06:00
|
|
|
namespace units {
|
2018-09-29 18:08:02 -07:00
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// namespace detail {
|
2022-05-11 11:59:33 +02:00
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// template<typename>
|
|
|
|
|
// inline constexpr bool can_be_prefixed = false;
|
2022-05-11 11:59:33 +02:00
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// } // namespace detail
|
2022-05-11 11:59:33 +02:00
|
|
|
|
2019-12-07 16:30:40 +01:00
|
|
|
/**
|
|
|
|
|
* @brief A common point for a hierarchy of units
|
|
|
|
|
*
|
|
|
|
|
* A unit is an entity defined and adopted by convention, with which any other quantity of
|
|
|
|
|
* the same kind can be compared to express the ratio of the second quantity to the first
|
|
|
|
|
* one as a number.
|
2022-03-17 23:59:48 +01:00
|
|
|
*
|
2019-12-07 16:30:40 +01:00
|
|
|
* All units of the same dimension can be convereted between each other. To allow this all of
|
|
|
|
|
* them are expressed as different ratios of the same one proprietary chosen reference unit
|
|
|
|
|
* (i.e. all length units are expressed in terms of meter, all mass units are expressed in
|
|
|
|
|
* terms of gram, ...)
|
|
|
|
|
*
|
2022-04-09 17:55:44 +00:00
|
|
|
* @tparam M a Magnitude representing the (relative) size of this unit
|
2020-06-27 19:15:46 +02:00
|
|
|
* @tparam U a unit to use as a reference for this dimension
|
2022-08-03 11:29:20 +02:00
|
|
|
*
|
|
|
|
|
* @note U cannot be constrained with Unit as for some specializations (i.e. named_unit)
|
|
|
|
|
* it gets the incomplete child's type with the CRTP idiom.
|
2019-12-07 16:30:40 +01:00
|
|
|
*/
|
2022-04-09 17:55:44 +00:00
|
|
|
template<Magnitude auto M, typename U>
|
2022-09-08 19:11:45 +02:00
|
|
|
struct scaled_unit {
|
2022-05-14 11:22:09 +02:00
|
|
|
static constexpr UNITS_MSVC_WORKAROUND(Magnitude) auto mag = M;
|
2019-12-14 21:16:15 +01:00
|
|
|
using reference = U;
|
2019-12-01 19:47:58 +01:00
|
|
|
};
|
2018-09-29 18:08:02 -07:00
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// TODO: Remove when P1985 accepted
|
|
|
|
|
namespace detail {
|
2019-12-09 17:19:58 +01:00
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
template<Magnitude auto M, typename U>
|
|
|
|
|
void to_base_scaled_unit(const volatile scaled_unit<M, U>*);
|
|
|
|
|
|
2022-10-06 23:43:01 +01:00
|
|
|
template<typename T>
|
|
|
|
|
inline constexpr bool is_specialization_of_scaled_unit = false;
|
|
|
|
|
|
|
|
|
|
template<Magnitude auto M, typename U>
|
|
|
|
|
inline constexpr bool is_specialization_of_scaled_unit<scaled_unit<M, U>> = true;
|
|
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
} // namespace detail
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief A concept matching all unit types in the library
|
|
|
|
|
*
|
|
|
|
|
* Satisfied by all unit types derived from an specialization of :class:`scaled_unit`.
|
|
|
|
|
*/
|
|
|
|
|
template<typename T>
|
|
|
|
|
concept Unit = requires(T* t) { detail::to_base_scaled_unit(t); };
|
|
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
|
|
|
|
|
|
template<typename>
|
|
|
|
|
inline constexpr bool is_named = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
concept NamedUnit = Unit<T> && detail::is_named<T>;
|
|
|
|
|
|
|
|
|
|
template<Unit auto U1, Unit auto U2>
|
|
|
|
|
struct same_unit_reference : is_same<typename decltype(U1)::reference, typename decltype(U2)::reference> {};
|
|
|
|
|
|
2022-10-06 23:43:01 +01:00
|
|
|
namespace detail {
|
|
|
|
|
|
|
|
|
|
template<Unit U1, Unit U2>
|
|
|
|
|
struct unit_less : std::bool_constant<type_name<U1>() < type_name<U2>()> {};
|
|
|
|
|
|
|
|
|
|
template<typename T1, typename T2>
|
|
|
|
|
using type_list_of_unit_less = expr_less<T1, T2, unit_less>;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Unpacks the list of potentially derived dimensions to a list containing only base dimensions
|
|
|
|
|
*
|
|
|
|
|
* @tparam Es Exponents of potentially derived dimensions
|
|
|
|
|
*/
|
|
|
|
|
// template<typename NumList, typename DenList>
|
|
|
|
|
// struct unit_extract;
|
|
|
|
|
|
|
|
|
|
// template<>
|
|
|
|
|
// struct unit_extract<type_list<>, type_list<>> {
|
|
|
|
|
// using num = type_list<>;
|
|
|
|
|
// using den = type_list<>;
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// template<typename T, typename... NRest, typename... Dens>
|
|
|
|
|
// requires BaseUnit<T> || BaseUnit<typename T::factor>
|
|
|
|
|
// struct unit_extract<type_list<T, NRest...>, type_list<Dens...>> {
|
|
|
|
|
// using impl = unit_extract<type_list<NRest...>, type_list<Dens...>>;
|
|
|
|
|
// using num = type_list_push_front<typename impl::num, T>;
|
|
|
|
|
// using den = TYPENAME impl::den;
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// template<typename T, typename... DRest>
|
|
|
|
|
// requires BaseUnit<T> || BaseUnit<typename T::factor>
|
|
|
|
|
// struct unit_extract<type_list<>, type_list<T, DRest...>> {
|
|
|
|
|
// using impl = unit_extract<type_list<>, type_list<DRest...>>;
|
|
|
|
|
// using num = TYPENAME impl::num;
|
|
|
|
|
// using den = type_list_push_front<typename impl::den, T>;
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// template<DerivedUnit T, typename... NRest, typename... Dens>
|
|
|
|
|
// struct unit_extract<type_list<T, NRest...>, type_list<Dens...>> :
|
|
|
|
|
// unit_extract<type_list_push_back<typename T::normalized_num, NRest...>,
|
|
|
|
|
// type_list_push_back<typename T::normalized_den, Dens...>> {};
|
|
|
|
|
|
|
|
|
|
// template<DerivedUnit T, int... Ints, typename... NRest, typename... Dens>
|
|
|
|
|
// struct unit_extract<type_list<power<T, Ints...>, NRest...>, type_list<Dens...>> :
|
|
|
|
|
// unit_extract<type_list_push_back<typename expr_power<typename T::normalized_num, power<T, Ints...>::num,
|
|
|
|
|
// power<T, Ints...>::den>::type,
|
|
|
|
|
// NRest...>,
|
|
|
|
|
// type_list_push_back<typename expr_power<typename T::normalized_den, power<T, Ints...>::num,
|
|
|
|
|
// power<T, Ints...>::den>::type,
|
|
|
|
|
// Dens...>> {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// template<DerivedUnit T, typename... DRest>
|
|
|
|
|
// struct unit_extract<type_list<>, type_list<T, DRest...>> :
|
|
|
|
|
// unit_extract<typename T::normalized_den, type_list_push_back<typename T::normalized_num, DRest...>> {};
|
|
|
|
|
|
|
|
|
|
// template<DerivedUnit T, int... Ints, typename... DRest>
|
|
|
|
|
// struct unit_extract<type_list<>, type_list<power<T, Ints...>, DRest...>> :
|
|
|
|
|
// unit_extract<typename expr_power<typename T::normalized_den, power<T, Ints...>::num, power<T,
|
|
|
|
|
// Ints...>::den>::type,
|
|
|
|
|
// type_list_push_back<typename expr_power<typename T::normalized_num, power<T, Ints...>::num,
|
|
|
|
|
// power<T, Ints...>::den>::type,
|
|
|
|
|
// DRest...>> {};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Converts user provided derived dimension specification into a valid units::normalized_dimension definition
|
|
|
|
|
*
|
|
|
|
|
* User provided definition of a derived dimension may contain the same base dimension repeated more than once on the
|
|
|
|
|
* list possibly hidden in other derived units provided by the user. The process here should:
|
|
|
|
|
* 1. Extract derived dimensions into exponents of base dimensions.
|
|
|
|
|
* 2. Sort the exponents so the same dimensions are placed next to each other.
|
|
|
|
|
* 3. Consolidate contiguous range of exponents of the same base dimensions to a one (or possibly zero) exponent for
|
|
|
|
|
* this base dimension.
|
|
|
|
|
*/
|
|
|
|
|
template<typename OneTypeBase, typename... Us>
|
|
|
|
|
struct normalized_unit : detail::expr_fractions<OneTypeBase, Us...> {
|
|
|
|
|
// private:
|
|
|
|
|
// using base = detail::expr_fractions<OneTypeBase, Us...>;
|
|
|
|
|
// using extracted = unit_extract<typename base::num, typename base::den>;
|
|
|
|
|
// using num_list = expr_consolidate<type_list_sort<typename extracted::num, type_list_of_unit_less>>;
|
|
|
|
|
// using den_list = expr_consolidate<type_list_sort<typename extracted::den, type_list_of_unit_less>>;
|
|
|
|
|
// using simple = expr_simplify<num_list, den_list, type_list_of_unit_less>;
|
|
|
|
|
// public:
|
|
|
|
|
// using normalized_num = TYPENAME simple::num;
|
|
|
|
|
// using normalized_den = TYPENAME simple::den;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// TODO add checking for `per` and power elements as well
|
|
|
|
|
template<typename T>
|
|
|
|
|
concept UnitSpec = Unit<T> || is_specialization_of<T, per> || detail::is_specialization_of_power<T>;
|
|
|
|
|
|
2022-10-06 23:43:01 +01:00
|
|
|
// User should not instantiate this type!!!
|
|
|
|
|
// It should not be exported from the module
|
2022-09-08 19:11:45 +02:00
|
|
|
template<UnitSpec... Us>
|
2022-10-06 23:43:01 +01:00
|
|
|
struct derived_unit : detail::normalized_unit<derived_unit<>, Us...>, scaled_unit<mag<1>, derived_unit<Us...>> {
|
|
|
|
|
static constexpr bool is_base = false;
|
|
|
|
|
};
|
2022-09-08 19:11:45 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Unit one
|
|
|
|
|
*
|
|
|
|
|
* Unit of a dimensionless quantity.
|
|
|
|
|
*/
|
|
|
|
|
inline constexpr struct one : derived_unit<> {
|
|
|
|
|
} one;
|
2019-04-11 13:36:06 +01:00
|
|
|
|
2019-12-01 19:47:58 +01:00
|
|
|
/**
|
|
|
|
|
* @brief A named unit
|
|
|
|
|
*
|
|
|
|
|
* Defines a named (in most cases coherent) unit that is then passed to a dimension definition.
|
2022-05-11 11:59:33 +02:00
|
|
|
* A named unit may be composed with a prefix to create a prefixed_unit.
|
2019-12-01 19:47:58 +01:00
|
|
|
*
|
|
|
|
|
* @tparam Symbol a short text representation of the unit
|
|
|
|
|
*/
|
2022-09-08 19:11:45 +02:00
|
|
|
template<basic_symbol_text Symbol, auto...>
|
|
|
|
|
struct named_unit;
|
|
|
|
|
|
|
|
|
|
template<basic_symbol_text Symbol>
|
2022-09-15 15:13:46 -06:00
|
|
|
struct named_unit<Symbol> : scaled_unit<mag<1>, named_unit<Symbol>> {
|
2019-12-01 19:47:58 +01:00
|
|
|
static constexpr auto symbol = Symbol;
|
2022-10-06 23:43:01 +01:00
|
|
|
static constexpr bool is_base = true;
|
2019-12-01 19:47:58 +01:00
|
|
|
};
|
2019-04-11 13:36:06 +01:00
|
|
|
|
2022-10-06 23:43:01 +01:00
|
|
|
template<basic_symbol_text Symbol, Unit auto U>
|
2022-09-08 19:11:45 +02:00
|
|
|
struct named_unit<Symbol, U> : decltype(U) {
|
|
|
|
|
static constexpr auto symbol = Symbol;
|
2022-10-06 23:43:01 +01:00
|
|
|
static constexpr bool is_base = decltype(U)::is_base;
|
2019-12-01 19:47:58 +01:00
|
|
|
};
|
2019-04-11 13:36:06 +01:00
|
|
|
|
2019-12-01 19:47:58 +01:00
|
|
|
/**
|
|
|
|
|
* @brief A prefixed unit
|
|
|
|
|
*
|
|
|
|
|
* Defines a new unit that is a scaled version of another unit by the provided prefix. It is
|
|
|
|
|
* only possible to create such a unit if the given prefix type matches the one defined in a
|
|
|
|
|
* reference unit.
|
|
|
|
|
*
|
|
|
|
|
* @tparam Child inherited class type used by the downcasting facility (CRTP Idiom)
|
|
|
|
|
* @tparam P prefix to be appied to the reference unit
|
|
|
|
|
* @tparam U reference unit
|
|
|
|
|
*/
|
2022-09-08 19:11:45 +02:00
|
|
|
template<basic_symbol_text Symbol, Magnitude auto M, NamedUnit auto U>
|
2022-10-06 23:43:01 +01:00
|
|
|
// requires detail::can_be_prefixed<U>
|
|
|
|
|
struct prefixed_unit : scaled_unit<M* decltype(U)::mag, typename decltype(U)::reference> {
|
|
|
|
|
// static constexpr auto symbol = symbol + decltype(U)::symbol;
|
|
|
|
|
static constexpr bool is_base = decltype(U)::is_base;
|
|
|
|
|
};
|
2019-11-10 16:55:16 +00:00
|
|
|
|
2022-05-11 11:40:19 +02:00
|
|
|
/**
|
|
|
|
|
* @brief A coherent unit of a derived quantity
|
|
|
|
|
*
|
|
|
|
|
* Defines a new coherent unit of a derived quantity. It should be passed as a coherent unit
|
|
|
|
|
* in the dimension's definition for such a quantity.
|
|
|
|
|
*
|
|
|
|
|
* @tparam Child inherited class type used by the downcasting facility (CRTP Idiom)
|
|
|
|
|
*/
|
2022-09-08 19:11:45 +02:00
|
|
|
// template<typename Child>
|
|
|
|
|
// struct derived_unit : downcast_dispatch<Child, scaled_unit<mag<1>(), Child>> {};
|
2020-05-08 10:50:34 +02:00
|
|
|
|
2022-05-11 11:49:14 +02:00
|
|
|
namespace detail {
|
|
|
|
|
|
2022-10-06 23:43:01 +01:00
|
|
|
template<basic_symbol_text Symbol, auto... Args>
|
|
|
|
|
void is_named_impl(const volatile named_unit<Symbol, Args...>*);
|
2022-05-11 11:49:14 +02:00
|
|
|
|
2022-10-06 23:43:01 +01:00
|
|
|
template<basic_symbol_text Symbol, Magnitude auto M, NamedUnit auto U>
|
|
|
|
|
void is_named_impl(const volatile prefixed_unit<Symbol, M, U>*);
|
2022-05-11 11:49:14 +02:00
|
|
|
|
|
|
|
|
template<Unit U>
|
|
|
|
|
inline constexpr bool is_named<U> = requires(U * u) { is_named_impl(u); };
|
|
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// template<typename Child, basic_symbol_text Symbol>
|
|
|
|
|
// void can_be_prefixed_impl(const volatile named_unit<Child, Symbol>*);
|
2022-05-11 11:59:33 +02:00
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// template<typename Child, basic_symbol_text Symbol, Magnitude auto M, typename U>
|
|
|
|
|
// void can_be_prefixed_impl(const volatile named_scaled_unit<Child, Symbol, M, U>*);
|
2022-05-11 11:59:33 +02:00
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// template<typename U, basic_symbol_text Symbol>
|
|
|
|
|
// void can_be_prefixed_impl(const volatile alias_unit<U, Symbol>*);
|
2022-05-11 11:59:33 +02:00
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// template<Unit U>
|
|
|
|
|
// inline constexpr bool can_be_prefixed<U> = requires(U * u) { can_be_prefixed_impl(u); };
|
2022-05-11 11:59:33 +02:00
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// template<Magnitude auto M, typename U>
|
|
|
|
|
// inline constexpr bool can_be_prefixed<scaled_unit<M, U>> = can_be_prefixed<typename U::reference>;
|
|
|
|
|
|
2022-05-11 11:49:14 +02:00
|
|
|
} // namespace detail
|
2020-05-08 10:50:34 +02:00
|
|
|
|
2022-10-06 23:43:01 +01:00
|
|
|
template<Magnitude M, Unit U>
|
|
|
|
|
[[nodiscard]] consteval Unit auto operator*(M mag, U)
|
|
|
|
|
{
|
|
|
|
|
return scaled_unit<mag, U>{};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<Magnitude M1, Magnitude auto M2, typename U>
|
|
|
|
|
[[nodiscard]] consteval Unit auto operator*(M1 mag, scaled_unit<M2, U>)
|
|
|
|
|
{
|
|
|
|
|
return scaled_unit<mag * M2, U>{};
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
template<Unit U1, Unit U2>
|
2022-09-15 14:52:54 -06:00
|
|
|
[[nodiscard]] consteval Unit auto operator*(U1, U2)
|
2022-09-08 19:11:45 +02:00
|
|
|
{
|
|
|
|
|
return detail::expr_multiply<U1, U2, struct one, detail::type_list_of_unit_less, derived_unit>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<Unit U1, Unit U2>
|
2022-09-15 14:52:54 -06:00
|
|
|
[[nodiscard]] consteval Unit auto operator/(U1, U2)
|
2022-09-08 19:11:45 +02:00
|
|
|
{
|
|
|
|
|
return detail::expr_divide<U1, U2, struct one, detail::type_list_of_unit_less, derived_unit>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<Unit U>
|
2022-09-15 14:52:54 -06:00
|
|
|
[[nodiscard]] consteval Unit auto operator/(int value, U)
|
2022-09-08 19:11:45 +02:00
|
|
|
{
|
|
|
|
|
gsl_Assert(value == 1);
|
|
|
|
|
return detail::expr_invert<U, struct one, derived_unit>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<Unit U1, Unit U2>
|
2022-09-15 14:52:54 -06:00
|
|
|
[[nodiscard]] consteval bool operator==(U1, U2)
|
2022-09-08 19:11:45 +02:00
|
|
|
{
|
2022-10-06 23:43:01 +01:00
|
|
|
return is_same_v<U1, U2>;
|
2022-09-08 19:11:45 +02:00
|
|
|
}
|
|
|
|
|
|
2022-10-06 23:43:01 +01:00
|
|
|
template<Unit U1, Unit U2>
|
|
|
|
|
[[nodiscard]] consteval bool equivalent(U1, U2)
|
|
|
|
|
{
|
|
|
|
|
return true; // TODO implement this
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-09-08 19:11:45 +02:00
|
|
|
// template<BaseDimension D1, BaseDimension D2>
|
|
|
|
|
// constexpr bool operator==(D1, D2)
|
|
|
|
|
// {
|
|
|
|
|
// return D1::symbol == D2::symbol;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// template<BaseDimension D1, Dimension D2>
|
|
|
|
|
// requires(type_list_size<typename D2::normalized_den> == 0) && (type_list_size<typename D2::normalized_num> == 1) &&
|
|
|
|
|
// BaseDimension<type_list_front<typename D2::normalized_num>>
|
|
|
|
|
// constexpr bool operator==(D1, D2)
|
|
|
|
|
// {
|
|
|
|
|
// return D1::symbol == type_list_front<typename D2::normalized_num>::symbol;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// template<Dimension D1, BaseDimension D2>
|
|
|
|
|
// requires(type_list_size<typename D1::normalized_den> == 0) && (type_list_size<typename D1::normalized_num> == 1) &&
|
|
|
|
|
// BaseDimension<type_list_front<typename D1::normalized_num>>
|
|
|
|
|
// constexpr bool operator==(D1, D2)
|
|
|
|
|
// {
|
|
|
|
|
// return type_list_front<typename D1::normalized_num>::symbol == D2::symbol;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// template<DerivedDimension D1, DerivedDimension D2>
|
|
|
|
|
// constexpr bool operator==(D1, D2)
|
|
|
|
|
// {
|
|
|
|
|
// return std::is_same_v<typename D1::normalized_num, typename D2::normalized_num> &&
|
|
|
|
|
// std::is_same_v<typename D1::normalized_den, typename D2::normalized_den>;
|
|
|
|
|
// }
|
|
|
|
|
|
2022-10-06 23:43:01 +01:00
|
|
|
template<Unit U>
|
|
|
|
|
struct square_ : decltype(U{} * U{}) {};
|
|
|
|
|
|
|
|
|
|
template<Unit auto U>
|
|
|
|
|
inline constexpr square_<std::remove_const_t<decltype(U)>> square;
|
|
|
|
|
|
|
|
|
|
template<Unit U>
|
|
|
|
|
struct cubic_ : decltype(U{} * U{} * U{}) {};
|
|
|
|
|
|
|
|
|
|
template<Unit auto U>
|
|
|
|
|
inline constexpr cubic_<std::remove_const_t<decltype(U)>> cubic;
|
|
|
|
|
|
2019-09-18 21:55:16 -06:00
|
|
|
} // namespace units
|