[clang-format]
This commit is contained in:
1 parent
b5c9dca61f
commit
0b0d3345e5
17 files changed
+161
-119
No files matched your search
@@ -189,7 +189,7 @@ constexpr void handle_dynamic_spec(int& value, fmt_arg_ref<typename Context::cha
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4702)
|
||||
#endif
|
||||
@@ -202,12 +202,12 @@ struct width_checker {
|
||||
if (value < 0) MP_UNITS_THROW(MP_UNITS_STD_FMT::format_error("negative width"));
|
||||
return static_cast<unsigned long long>(value);
|
||||
}
|
||||
MP_UNITS_THROW(MP_UNITS_STD_FMT::format_error("width is not integer"));
|
||||
MP_UNITS_THROW(MP_UNITS_STD_FMT::format_error("width is not integer"));
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( pop )
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
@@ -82,7 +82,8 @@
|
||||
#define MP_UNITS_TYPENAME typename
|
||||
#define MP_UNITS_EXPRESSION(x) (x)
|
||||
#define MP_UNITS_IS_VALUE(x) (x)
|
||||
#define MP_UNITS_IS_CONST_EXPR(x) decltype(x){}
|
||||
#define MP_UNITS_IS_CONST_EXPR(x) \
|
||||
decltype(x) {}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -30,23 +30,24 @@
|
||||
|
||||
namespace mp_units::detail {
|
||||
|
||||
template <typename AlwaysVoid, typename... Ts>
|
||||
template<typename AlwaysVoid, typename... Ts>
|
||||
struct has_common_type_impl : std::false_type {};
|
||||
|
||||
template <typename... Ts>
|
||||
template<typename... Ts>
|
||||
struct has_common_type_impl<std::void_t<std::common_type_t<Ts...>>, Ts...> : std::true_type {};
|
||||
|
||||
template <typename... Ts>
|
||||
template<typename... Ts>
|
||||
using has_common_type = typename has_common_type_impl<void, Ts...>::type;
|
||||
|
||||
template <typename... Ts> constexpr bool has_common_type_v = has_common_type_impl<void, Ts...>::value;
|
||||
template<typename... Ts>
|
||||
constexpr bool has_common_type_v = has_common_type_impl<void, Ts...>::value;
|
||||
|
||||
template<typename T, typename Other>
|
||||
struct get_common_type : std::common_type<T, Other> {};
|
||||
|
||||
template<typename T, typename Other>
|
||||
using maybe_common_type = MP_UNITS_TYPENAME std::conditional_t<has_common_type_v<T, Other>,
|
||||
get_common_type<T, Other>, std::type_identity<T>>::type;
|
||||
using maybe_common_type = MP_UNITS_TYPENAME
|
||||
std::conditional_t<has_common_type_v<T, Other>, get_common_type<T, Other>, std::type_identity<T>>::type;
|
||||
|
||||
/**
|
||||
* @brief Details about the conversion from one quantity to another.
|
||||
|
||||
@@ -452,7 +452,7 @@ class MP_UNITS_STD_FMT::formatter<mp_units::quantity<Reference, Rep>, Char> {
|
||||
}
|
||||
// user provided format
|
||||
quantity_formatter f{*this, out, q, locale};
|
||||
parse_quantity_specs(modifiers_format_str_.data(), modifiers_format_str_.data() + modifiers_format_str_.size(), f);
|
||||
parse_quantity_specs(modifiers_format_str_.data(), modifiers_format_str_.data() + modifiers_format_str_.size(), f);
|
||||
return f.out;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ template<Reference R>
|
||||
struct absolute_ {
|
||||
template<typename Rep>
|
||||
requires RepresentationOf<std::remove_cvref_t<Rep>, get_quantity_spec(R{}).character>
|
||||
[[nodiscard]] constexpr quantity_point<MP_UNITS_EXPRESSION(R{}), default_point_origin(R{}), std::remove_cvref_t<Rep>> operator()(
|
||||
Rep&& lhs) const
|
||||
[[nodiscard]] constexpr quantity_point<MP_UNITS_EXPRESSION(R{}), default_point_origin(R{}), std::remove_cvref_t<Rep>>
|
||||
operator()(Rep&& lhs) const
|
||||
{
|
||||
return quantity_point{quantity{std::forward<Rep>(lhs), R{}}};
|
||||
}
|
||||
|
||||
@@ -461,8 +461,8 @@ public:
|
||||
}
|
||||
friend constexpr decltype(auto) operator*=(Q1&& lhs, const Q2& rhs)
|
||||
{
|
||||
lhs.numerical_value_is_an_implementation_detail_ = lhs.numerical_value_is_an_implementation_detail_ *
|
||||
rhs.numerical_value_is_an_implementation_detail_;
|
||||
lhs.numerical_value_is_an_implementation_detail_ =
|
||||
lhs.numerical_value_is_an_implementation_detail_ * rhs.numerical_value_is_an_implementation_detail_;
|
||||
return std::forward<Q1>(lhs);
|
||||
}
|
||||
|
||||
@@ -490,8 +490,8 @@ public:
|
||||
friend constexpr decltype(auto) operator/=(Q1&& lhs, const Q2& rhs)
|
||||
{
|
||||
MP_UNITS_EXPECTS_DEBUG(rhs != rhs.zero());
|
||||
lhs.numerical_value_is_an_implementation_detail_ = lhs.numerical_value_is_an_implementation_detail_
|
||||
/ rhs.numerical_value_is_an_implementation_detail_;
|
||||
lhs.numerical_value_is_an_implementation_detail_ =
|
||||
lhs.numerical_value_is_an_implementation_detail_ / rhs.numerical_value_is_an_implementation_detail_;
|
||||
return std::forward<Q1>(lhs);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,14 +54,16 @@ template<PointOrigin PO>
|
||||
struct point_origin_interface {
|
||||
template<PointOrigin PO, Quantity Q>
|
||||
requires ReferenceOf<std::remove_const_t<decltype(Q::reference)>, PO::quantity_spec>
|
||||
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION(PO{}), typename Q::rep> operator+(PO, Q&& q)
|
||||
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION(PO{}), typename Q::rep> operator+(
|
||||
PO, Q&& q)
|
||||
{
|
||||
return quantity_point{std::forward<Q>(q), PO{}};
|
||||
}
|
||||
|
||||
template<Quantity Q, PointOrigin PO>
|
||||
requires ReferenceOf<std::remove_const_t<decltype(Q::reference)>, PO::quantity_spec>
|
||||
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION(PO{}), typename Q::rep> operator+(Q&& q, PO po)
|
||||
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION(PO{}), typename Q::rep> operator+(
|
||||
Q&& q, PO po)
|
||||
{
|
||||
return po + std::forward<Q>(q);
|
||||
}
|
||||
@@ -264,8 +266,7 @@ public:
|
||||
quantity_point& operator=(quantity_point&&) = default;
|
||||
|
||||
template<detail::SameAbsolutePointOriginAs<absolute_point_origin> NewPO>
|
||||
[[nodiscard]] constexpr QuantityPointOf<(NewPO{})> auto point_for(
|
||||
NewPO new_origin) const
|
||||
[[nodiscard]] constexpr QuantityPointOf<(NewPO{})> auto point_for(NewPO new_origin) const
|
||||
{
|
||||
if constexpr (is_same_v<NewPO, decltype(point_origin)>)
|
||||
return *this;
|
||||
|
||||
@@ -673,7 +673,8 @@ template<QuantitySpec Q>
|
||||
template<Dimension D1, Dimension D2>
|
||||
[[nodiscard]] consteval bool ingredients_dimension_less(D1 lhs, D2 rhs)
|
||||
{
|
||||
if constexpr (MP_UNITS_IS_CONST_EXPR(lhs) == MP_UNITS_IS_CONST_EXPR(rhs) || MP_UNITS_IS_CONST_EXPR(lhs) == dimension_one)
|
||||
if constexpr (MP_UNITS_IS_CONST_EXPR(lhs) == MP_UNITS_IS_CONST_EXPR(rhs) ||
|
||||
MP_UNITS_IS_CONST_EXPR(lhs) == dimension_one)
|
||||
return false;
|
||||
else if constexpr (MP_UNITS_IS_CONST_EXPR(rhs) == dimension_one)
|
||||
return true;
|
||||
@@ -1344,15 +1345,21 @@ template<QuantitySpec From, QuantitySpec To>
|
||||
using enum specs_convertible_result;
|
||||
return res == no ? no : yes;
|
||||
};
|
||||
if constexpr ((NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR(from_kind))> && NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR(to_kind))>) ||
|
||||
if constexpr ((NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR(from_kind))> &&
|
||||
NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR(to_kind))>) ||
|
||||
get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind)) == get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind)))
|
||||
return convertible_impl(MP_UNITS_IS_CONST_EXPR(from_kind), MP_UNITS_IS_CONST_EXPR(to_kind));
|
||||
else if constexpr (get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind)) > get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind)))
|
||||
return exploded_kind_result(
|
||||
convertible_impl(get_kind_tree_root(explode<get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind))>(MP_UNITS_IS_CONST_EXPR(from_kind)).quantity), MP_UNITS_IS_CONST_EXPR(to_kind)));
|
||||
else if constexpr (get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind)) >
|
||||
get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind)))
|
||||
return exploded_kind_result(convertible_impl(
|
||||
get_kind_tree_root(
|
||||
explode<get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind))>(MP_UNITS_IS_CONST_EXPR(from_kind)).quantity),
|
||||
MP_UNITS_IS_CONST_EXPR(to_kind)));
|
||||
else
|
||||
return exploded_kind_result(
|
||||
convertible_impl(MP_UNITS_IS_CONST_EXPR(from_kind), get_kind_tree_root(explode<get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind))>(MP_UNITS_IS_CONST_EXPR(to_kind)).quantity)));
|
||||
return exploded_kind_result(convertible_impl(
|
||||
MP_UNITS_IS_CONST_EXPR(from_kind),
|
||||
get_kind_tree_root(
|
||||
explode<get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind))>(MP_UNITS_IS_CONST_EXPR(to_kind)).quantity)));
|
||||
}
|
||||
|
||||
template<NamedQuantitySpec From, NamedQuantitySpec To>
|
||||
@@ -1369,7 +1376,9 @@ template<NamedQuantitySpec From, NamedQuantitySpec To>
|
||||
return no;
|
||||
else if constexpr (get_complexity(From{}) != get_complexity(To{})) {
|
||||
if constexpr (get_complexity(From{}) > get_complexity(To{}))
|
||||
return convertible_impl(explode<get_complexity(MP_UNITS_IS_CONST_EXPR(to))>(MP_UNITS_IS_CONST_EXPR(from)).quantity, MP_UNITS_IS_CONST_EXPR(to));
|
||||
return convertible_impl(
|
||||
explode<get_complexity(MP_UNITS_IS_CONST_EXPR(to))>(MP_UNITS_IS_CONST_EXPR(from)).quantity,
|
||||
MP_UNITS_IS_CONST_EXPR(to));
|
||||
else {
|
||||
auto res = explode<get_complexity(MP_UNITS_IS_CONST_EXPR(from))>(MP_UNITS_IS_CONST_EXPR(to));
|
||||
return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR(from), res.quantity));
|
||||
@@ -1388,7 +1397,8 @@ template<QuantitySpec From, QuantitySpec To>
|
||||
else if constexpr (From::dimension != To::dimension)
|
||||
return no;
|
||||
else if constexpr (QuantityKindSpec<From> || QuantityKindSpec<To>)
|
||||
return convertible_kinds(get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(from)), get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(to)));
|
||||
return convertible_kinds(get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(from)),
|
||||
get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(to)));
|
||||
else if constexpr (NestedQuantityKindSpecOf<get_kind_tree_root(To{}), from> && get_kind_tree_root(To{}) == To{})
|
||||
return yes;
|
||||
else if constexpr (NamedQuantitySpec<From> && NamedQuantitySpec<To>)
|
||||
|
||||
@@ -87,40 +87,47 @@ struct reference {
|
||||
}
|
||||
|
||||
template<typename Q2, typename U2>
|
||||
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} * Q2{}), MP_UNITS_EXPRESSION(U{} * U2{})> operator*(reference, reference<Q2, U2>)
|
||||
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} * Q2{}), MP_UNITS_EXPRESSION(U{} * U2{})>
|
||||
operator*(reference, reference<Q2, U2>)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<AssociatedUnit U2>
|
||||
[[nodiscard]] friend consteval detail::reference_t<(MP_UNITS_EXPRESSION(Q{} * get_quantity_spec(U2{}))), MP_UNITS_EXPRESSION(U{} * U2{})> operator*(reference,
|
||||
U2)
|
||||
[[nodiscard]] friend consteval detail::reference_t<(MP_UNITS_EXPRESSION(Q{} * get_quantity_spec(U2{}))),
|
||||
MP_UNITS_EXPRESSION(U{} * U2{})>
|
||||
operator*(reference, U2)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<AssociatedUnit U1>
|
||||
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(get_quantity_spec(U1{}) * Q{}), MP_UNITS_EXPRESSION(U1{} * U{})> operator*(U1,
|
||||
reference)
|
||||
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(get_quantity_spec(U1{}) * Q{}),
|
||||
MP_UNITS_EXPRESSION(U1{} * U{})>
|
||||
operator*(U1, reference)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Q2, typename U2>
|
||||
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} / Q2{}), MP_UNITS_EXPRESSION(U{} / U2{})> operator/(reference, reference<Q2, U2>)
|
||||
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} / Q2{}), MP_UNITS_EXPRESSION(U{} / U2{})>
|
||||
operator/(reference, reference<Q2, U2>)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<AssociatedUnit U2>
|
||||
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} / get_quantity_spec(U2{})), MP_UNITS_EXPRESSION(U{} / U2{})> operator/(reference,
|
||||
U2)
|
||||
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} / get_quantity_spec(U2{})),
|
||||
MP_UNITS_EXPRESSION(U{} / U2{})>
|
||||
operator/(reference, U2)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<AssociatedUnit U1>
|
||||
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(get_quantity_spec(U1{}) / Q{}), MP_UNITS_EXPRESSION(U1{} / U{})> operator/(U1, reference)
|
||||
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(get_quantity_spec(U1{}) / Q{}),
|
||||
MP_UNITS_EXPRESSION(U1{} / U{})>
|
||||
operator/(U1, reference)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@@ -288,9 +295,10 @@ template<Reference R1, Reference R2, Reference... Rest>
|
||||
} -> Unit;
|
||||
}
|
||||
{
|
||||
return detail::reference_t<common_quantity_spec(get_quantity_spec(MP_UNITS_IS_CONST_EXPR(r1)), get_quantity_spec(MP_UNITS_IS_CONST_EXPR(r2)),
|
||||
get_quantity_spec(rest)...),
|
||||
common_unit(get_unit(MP_UNITS_IS_CONST_EXPR(r1)), get_unit(MP_UNITS_IS_CONST_EXPR(r2)), get_unit(rest)...)>{};
|
||||
return detail::reference_t<
|
||||
common_quantity_spec(get_quantity_spec(MP_UNITS_IS_CONST_EXPR(r1)), get_quantity_spec(MP_UNITS_IS_CONST_EXPR(r2)),
|
||||
get_quantity_spec(rest)...),
|
||||
common_unit(get_unit(MP_UNITS_IS_CONST_EXPR(r1)), get_unit(MP_UNITS_IS_CONST_EXPR(r2)), get_unit(rest)...)>{};
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
@@ -128,7 +128,8 @@ public:
|
||||
MP_UNITS_EXPECTS(detail::is_basic_literal_character_set(a));
|
||||
}
|
||||
|
||||
constexpr symbol_text(const fixed_u8string<N>& unicode, const fixed_string<M>& ascii) : unicode_(unicode), ascii_(ascii)
|
||||
constexpr symbol_text(const fixed_u8string<N>& unicode, const fixed_string<M>& ascii) :
|
||||
unicode_(unicode), ascii_(ascii)
|
||||
{
|
||||
MP_UNITS_EXPECTS(detail::is_basic_literal_character_set(ascii.data_));
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ std::basic_ostream<CharT, Traits>& to_stream(std::basic_ostream<CharT, Traits>&
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<typename OStream, typename T>
|
||||
concept is_mp_units_stream = requires (OStream os, T v) { detail::to_stream_impl(os, v); };
|
||||
concept is_mp_units_stream = requires(OStream os, T v) { detail::to_stream_impl(os, v); };
|
||||
|
||||
template<typename CharT, typename Traits, typename T>
|
||||
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const T& v)
|
||||
|
||||
Reference in new issue
Block a user