4#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UNITS_UNITS_CONVERSION_TRAITS_HPP_
5#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UNITS_UNITS_CONVERSION_TRAITS_HPP_
7#include "arene/base/constraints/constraints.hpp"
8#include "arene/base/stdlib_choice/enable_if.hpp"
9#include "arene/base/stdlib_choice/is_same.hpp"
10#include "arene/base/stdlib_choice/ratio.hpp"
11#include "arene/base/type_list/apply_all.hpp"
12#include "arene/base/units/base_kind_set.hpp"
13#include "arene/base/units/combine_kinds.hpp"
14#include "arene/base/units/explicit_base_set.hpp"
15#include "arene/base/units/is_base_quantity_kind.hpp"
16#include "arene/base/units/is_explicit.hpp"
17#include "arene/base/units/is_implicit.hpp"
18#include "arene/base/units/is_quantity_kind.hpp"
22namespace units_conversion_traits_detail {
26template <
typename Kind,
typename = constraints<>>
27extern constexpr bool is_explicit_with_implicit_parent_v =
false;
31template <
typename Kind>
32extern constexpr bool is_explicit_with_implicit_parent_v<
35 std::enable_if_t<units_detail::is_explicit_v<Kind>>,
36 std::enable_if_t<units_detail::is_implicit_v<
typename Kind::parent_quantity_kind_type>>>> =
true;
40template <
typename Type,
typename = constraints<>>
41extern constexpr bool has_scale_factor_v =
false;
45template <
typename Type>
46extern constexpr bool has_scale_factor_v<Type, constraints<
typename Type::scale_factor>> =
true;
53template <
typename From,
typename To,
typename = constraints<>>
54class units_conversion_traits_impl {
60 static constexpr bool compatible{
false};
68template <
typename From>
69class units_conversion_traits_impl<From, From, constraints<std::enable_if_t<!is_quantity_kind_v<From>>>> {
74 static constexpr bool compatible{
true};
78 using scale_factor = std::ratio<1, 1>;
83template <
typename Kind,
typename = constraints<>>
84struct destination_base_set {
90 static constexpr auto value = units_detail::explicit_base_set<Kind>;
98template <
typename Kind>
99struct destination_base_set<Kind, constraints<std::enable_if_t<is_explicit_with_implicit_parent_v<Kind>>>> {
105 static constexpr auto value = units_detail::explicit_base_set<
typename Kind::parent_quantity_kind_type>;
120template <
typename From,
typename To>
121class units_conversion_traits_impl<
125 std::enable_if_t<is_quantity_kind_v<From>>,
126 std::enable_if_t<is_quantity_kind_v<To>>,
127 std::enable_if_t<!has_scale_factor_v<From>>,
128 std::enable_if_t<!has_scale_factor_v<To>>>> {
136 static constexpr auto value = units_detail::explicit_base_set<From>;
143 using lifted_source_set =
144 type_lists::apply_all_t<units_detail::as_list_of_kinds_with_exponents_t<source_set>, combine_kinds_t>;
146 using lifted_dest_set = type_lists::
147 apply_all_t<units_detail::as_list_of_kinds_with_exponents_t<destination_base_set<To>>, combine_kinds_t>;
161 static constexpr bool
162 compatible{std::is_same<lifted_source_set, lifted_dest_set>::value || is_base_quantity_kind_of_v<lifted_dest_set, lifted_source_set>};
167 using scale_factor = std::ratio<1, 1>;
180template <
typename From,
typename To>
Traits class with information about if and how a physical unit of type From can be converted to a phy...
Definition units_conversion_traits.hpp:181
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10