Skip to content

Commit 79f42e8

Browse files
committed
refactor: small detail namespace cleanup for units
1 parent 623930c commit 79f42e8

File tree

1 file changed

+15
-11
lines changed
  • src/core/include/mp-units/framework

1 file changed

+15
-11
lines changed

src/core/include/mp-units/framework/unit.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,23 @@ struct get_canonical_unit_result {
120120
inline static constexpr auto value = get_canonical_unit_impl(U{}, U{});
121121
};
122122

123-
template<Unit Lhs, Unit Rhs>
124-
struct unit_less : std::bool_constant<type_name<Lhs>() < type_name<Rhs>()> {};
123+
} // namespace detail
125124

126-
template<typename T1, typename T2>
127-
using type_list_of_unit_less = expr_less<T1, T2, unit_less>;
125+
// TODO this should really be in the `details` namespace but is used in `chrono.h` (a part of mp_units.systems)
126+
// Even though it is not exported, it is visible to the other module via ADL
127+
[[nodiscard]] consteval auto get_canonical_unit(Unit auto u)
128+
{
129+
return detail::get_canonical_unit_result<decltype(u)>::value;
130+
}
131+
132+
namespace detail {
128133

129134
template<typename From, typename To>
130135
concept PotentiallyConvertibleTo = Unit<From> && Unit<To> &&
131136
((AssociatedUnit<From> && AssociatedUnit<To> &&
132137
implicitly_convertible(get_quantity_spec(From{}), get_quantity_spec(To{}))) ||
133138
(!AssociatedUnit<From> && !AssociatedUnit<To>));
134139

135-
} // namespace detail
136-
137-
// TODO this should really be in the `details` namespace but is used in `chrono.h` (a part of mp_units.systems)
138-
// Even though it is not exported, it is visible to the other module via ADL
139-
[[nodiscard]] consteval auto get_canonical_unit(Unit auto u)
140-
{
141-
return detail::get_canonical_unit_result<decltype(u)>::value;
142140
}
143141

144142
// convertible
@@ -159,6 +157,12 @@ struct derived_unit;
159157

160158
namespace detail {
161159

160+
template<Unit Lhs, Unit Rhs>
161+
struct unit_less : std::bool_constant<type_name<Lhs>() < type_name<Rhs>()> {};
162+
163+
template<typename T1, typename T2>
164+
using type_list_of_unit_less = expr_less<T1, T2, unit_less>;
165+
162166
struct unit_interface {
163167
/**
164168
* Multiplication by `1` returns the same unit, otherwise `scaled_unit` is being returned.

0 commit comments

Comments
 (0)