mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-29 18:07:16 +02:00
[clang-format]
This commit is contained in:
@ -45,8 +45,8 @@ namespace {
|
||||
|
||||
using namespace mp_units;
|
||||
|
||||
QuantityOf<(isq::mechanical_energy)> auto total_energy(QuantityOf<(isq::momentum)> auto p, QuantityOf<(isq::mass)> auto m,
|
||||
QuantityOf<(isq::speed)> auto c)
|
||||
QuantityOf<(isq::mechanical_energy)> auto total_energy(QuantityOf<(isq::momentum)> auto p,
|
||||
QuantityOf<(isq::mass)> auto m, QuantityOf<(isq::speed)> auto c)
|
||||
{
|
||||
return isq::mechanical_energy(sqrt(pow<2>(p * c) + pow<2>(m * pow<2>(c))));
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -132,8 +132,8 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
common_reference(R1, R2);
|
||||
requires requires { atan2(v1, v2); } || requires { std::atan2(v1, v2); };
|
||||
}
|
||||
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto atan2(const quantity<R1, Rep1>& y,
|
||||
const quantity<R2, Rep2>& x) noexcept
|
||||
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto atan2(
|
||||
const quantity<R1, Rep1>& y, const quantity<R2, Rep2>& x) noexcept
|
||||
{
|
||||
constexpr auto ref = common_reference(R1, R2);
|
||||
constexpr auto unit = get_unit(ref);
|
||||
|
@ -63,7 +63,8 @@ static_assert(std::constructible_from<quantity<(isq::time[si::hour]), std::chron
|
||||
static_assert(std::convertible_to<std::chrono::hours, quantity<(isq::time[si::hour]), std::chrono::hours::rep>>);
|
||||
static_assert(std::constructible_from<quantity<(isq::time[si::second]), std::chrono::hours::rep>, std::chrono::hours>);
|
||||
static_assert(std::convertible_to<std::chrono::hours, quantity<(isq::time[si::second]), std::chrono::hours::rep>>);
|
||||
static_assert(!std::constructible_from<quantity<(isq::time[si::hour]), std::chrono::seconds::rep>, std::chrono::seconds>);
|
||||
static_assert(
|
||||
!std::constructible_from<quantity<(isq::time[si::hour]), std::chrono::seconds::rep>, std::chrono::seconds>);
|
||||
static_assert(!std::convertible_to<std::chrono::seconds, quantity<(isq::time[si::hour]), std::chrono::seconds::rep>>);
|
||||
static_assert(
|
||||
std::constructible_from<time_point<(si::second), std::chrono::system_clock, sys_seconds::rep>, sys_seconds>);
|
||||
@ -76,7 +77,8 @@ static_assert(std::convertible_to<sys_days, time_point<(si::day), std::chrono::s
|
||||
static_assert(std::constructible_from<time_point<(si::second), std::chrono::system_clock, sys_days::rep>, sys_days>);
|
||||
static_assert(!std::constructible_from<time_point<(si::second), std::chrono::steady_clock, sys_days::rep>, sys_days>);
|
||||
static_assert(std::convertible_to<sys_days, time_point<(si::second), std::chrono::system_clock, sys_days::rep>>);
|
||||
static_assert(!std::constructible_from<time_point<(si::day), std::chrono::system_clock, sys_seconds::rep>, sys_seconds>);
|
||||
static_assert(
|
||||
!std::constructible_from<time_point<(si::day), std::chrono::system_clock, sys_seconds::rep>, sys_seconds>);
|
||||
static_assert(!std::convertible_to<sys_seconds, time_point<(si::day), std::chrono::system_clock, sys_seconds::rep>>);
|
||||
|
||||
// construction - different rep type (integral to a floating-point)
|
||||
|
@ -102,7 +102,8 @@ static_assert(creates_quantity<min_impl<double>, percent>);
|
||||
static_assert(std::constructible_from<quantity<(si::metre), min_impl<int>>, quantity<(si::metre), min_impl<int>>>);
|
||||
static_assert(std::convertible_to<quantity<(si::metre), min_impl<int>>, quantity<(si::metre), min_impl<int>>>);
|
||||
|
||||
static_assert(std::constructible_from<quantity<(si::metre), min_impl<double>>, quantity<(si::metre), min_impl<double>>>);
|
||||
static_assert(
|
||||
std::constructible_from<quantity<(si::metre), min_impl<double>>, quantity<(si::metre), min_impl<double>>>);
|
||||
static_assert(std::convertible_to<quantity<(si::metre), min_impl<double>>, quantity<(si::metre), min_impl<double>>>);
|
||||
|
||||
static_assert(std::constructible_from<quantity<(si::metre), min_impl<double>>, quantity<(si::metre), min_impl<int>>>);
|
||||
@ -122,8 +123,8 @@ static_assert(std::convertible_to<quantity<(si::metre), double>, quantity<(si::m
|
||||
static_assert(std::constructible_from<quantity<(si::metre), min_impl<double>>, quantity<(si::metre), int>>);
|
||||
static_assert(std::convertible_to<quantity<(si::metre), int>, quantity<(si::metre), min_impl<double>>>);
|
||||
|
||||
static_assert(
|
||||
!std::constructible_from<quantity<(si::metre), min_impl<int>>, quantity<(si::metre), double>>); // narrowing conversion
|
||||
static_assert(!std::constructible_from<quantity<(si::metre), min_impl<int>>,
|
||||
quantity<(si::metre), double>>); // narrowing conversion
|
||||
static_assert(!std::convertible_to<quantity<(si::metre), double>, quantity<(si::metre), min_impl<int>>>);
|
||||
|
||||
// min_impl<T> -> T
|
||||
@ -136,8 +137,8 @@ static_assert(std::convertible_to<quantity<(si::metre), min_impl<double>>, quant
|
||||
static_assert(std::constructible_from<quantity<(si::metre), double>, quantity<(si::metre), min_impl<int>>>);
|
||||
static_assert(std::convertible_to<quantity<(si::metre), min_impl<int>>, quantity<(si::metre), double>>);
|
||||
|
||||
static_assert(
|
||||
!std::constructible_from<quantity<(si::metre), int>, quantity<(si::metre), min_impl<double>>>); // narrowing conversion
|
||||
static_assert(!std::constructible_from<quantity<(si::metre), int>,
|
||||
quantity<(si::metre), min_impl<double>>>); // narrowing conversion
|
||||
static_assert(!std::convertible_to<quantity<(si::metre), min_impl<double>>, quantity<(si::metre), int>>);
|
||||
|
||||
|
||||
|
@ -236,7 +236,8 @@ static_assert(quantity_point<si::metre>::quantity_spec == kind_of<isq::length>);
|
||||
static_assert(quantity_point<si::metre>::dimension == isq::dim_length);
|
||||
static_assert(quantity_point<si::metre>::unit == si::metre);
|
||||
static_assert(is_of_type<quantity_point<(si::metre)>::point_origin, zeroth_point_origin_<kind_of<isq::length>>>);
|
||||
static_assert(is_of_type<quantity_point<(si::metre)>::absolute_point_origin, zeroth_point_origin_<kind_of<isq::length>>>);
|
||||
static_assert(
|
||||
is_of_type<quantity_point<(si::metre)>::absolute_point_origin, zeroth_point_origin_<kind_of<isq::length>>>);
|
||||
|
||||
static_assert(quantity_point<isq::height[m]>::reference == isq::height[m]);
|
||||
static_assert(quantity_point<isq::height[m]>::quantity_spec == isq::height);
|
||||
@ -257,7 +258,8 @@ static_assert(quantity_point<isq::height[m], mean_sea_level>::quantity_spec == i
|
||||
static_assert(quantity_point<isq::height[m], mean_sea_level>::dimension == isq::dim_length);
|
||||
static_assert(quantity_point<isq::height[m], mean_sea_level>::unit == si::metre);
|
||||
static_assert(is_of_type<quantity_point<(isq::height[m]), mean_sea_level>::point_origin, struct mean_sea_level>);
|
||||
static_assert(is_of_type<quantity_point<(isq::height[m]), mean_sea_level>::absolute_point_origin, struct mean_sea_level>);
|
||||
static_assert(
|
||||
is_of_type<quantity_point<(isq::height[m]), mean_sea_level>::absolute_point_origin, struct mean_sea_level>);
|
||||
|
||||
static_assert(quantity_point<isq::height[m], ground_level>::reference == isq::height[m]);
|
||||
static_assert(quantity_point<isq::height[m], ground_level>::quantity_spec == isq::height);
|
||||
@ -288,8 +290,9 @@ static_assert(quantity_point<isq::thermodynamic_temperature[si::kelvin], si::abs
|
||||
static_assert(quantity_point<isq::thermodynamic_temperature[si::kelvin], si::absolute_zero>::dimension ==
|
||||
isq::dim_thermodynamic_temperature);
|
||||
static_assert(quantity_point<isq::thermodynamic_temperature[si::kelvin], si::absolute_zero>::unit == si::kelvin);
|
||||
static_assert(is_of_type<quantity_point<(isq::thermodynamic_temperature[si::kelvin]), (si::absolute_zero)>::point_origin,
|
||||
struct si::absolute_zero>);
|
||||
static_assert(
|
||||
is_of_type<quantity_point<(isq::thermodynamic_temperature[si::kelvin]), (si::absolute_zero)>::point_origin,
|
||||
struct si::absolute_zero>);
|
||||
static_assert(
|
||||
is_of_type<quantity_point<(isq::thermodynamic_temperature[si::kelvin]), (si::absolute_zero)>::absolute_point_origin,
|
||||
struct si::absolute_zero>);
|
||||
@ -303,8 +306,9 @@ static_assert(quantity_point<isq::Celsius_temperature[si::kelvin], si::absolute_
|
||||
static_assert(quantity_point<isq::Celsius_temperature[si::kelvin], si::absolute_zero>::unit == si::kelvin);
|
||||
static_assert(is_of_type<quantity_point<(isq::Celsius_temperature[si::kelvin]), (si::absolute_zero)>::point_origin,
|
||||
struct si::absolute_zero>);
|
||||
static_assert(is_of_type<quantity_point<(isq::Celsius_temperature[si::kelvin]), (si::absolute_zero)>::absolute_point_origin,
|
||||
struct si::absolute_zero>);
|
||||
static_assert(
|
||||
is_of_type<quantity_point<(isq::Celsius_temperature[si::kelvin]), (si::absolute_zero)>::absolute_point_origin,
|
||||
struct si::absolute_zero>);
|
||||
|
||||
static_assert(quantity_point<si::degree_Celsius, si::ice_point>::reference == si::degree_Celsius);
|
||||
static_assert(quantity_point<si::degree_Celsius, si::ice_point>::quantity_spec ==
|
||||
@ -545,7 +549,8 @@ static_assert(std::convertible_to<quantity_point<(si::metre)>, quantity_point<(i
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(isq::length[m]) / isq::time[s]>, quantity_point<(isq::speed[m / s])>>);
|
||||
static_assert(std::convertible_to<quantity_point<(isq::speed[m / s])>, quantity_point<(isq::length[m]) / isq::time[s]>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::speed[m / s])>, quantity_point<(isq::length[m]) / isq::time[s]>>);
|
||||
|
||||
static_assert(std::constructible_from<quantity_point<m / s>, quantity_point<(isq::speed[m / s])>>);
|
||||
static_assert(std::convertible_to<quantity_point<(isq::speed[m / s])>, quantity_point<m / s>>);
|
||||
@ -577,12 +582,14 @@ static_assert(!std::convertible_to<quantity_point<(isq::height[m])>, quantity_po
|
||||
// mixed origins
|
||||
static_assert(!std::constructible_from<quantity_point<(si::metre), mean_sea_level>, quantity_point<(si::metre)>>);
|
||||
static_assert(!std::convertible_to<quantity_point<(si::metre)>, quantity_point<(si::metre), mean_sea_level>>);
|
||||
static_assert(!std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(isq::height[m])>>);
|
||||
static_assert(
|
||||
!std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(isq::height[m])>>);
|
||||
static_assert(!std::convertible_to<quantity_point<(isq::height[m])>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
|
||||
static_assert(!std::constructible_from<quantity_point<(si::metre)>, quantity_point<(si::metre), mean_sea_level>>);
|
||||
static_assert(!std::convertible_to<quantity_point<(si::metre), mean_sea_level>, quantity_point<(si::metre)>>);
|
||||
static_assert(!std::constructible_from<quantity_point<(isq::height[m])>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(
|
||||
!std::constructible_from<quantity_point<(isq::height[m])>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(!std::convertible_to<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(isq::height[m])>>);
|
||||
|
||||
// same explicit origins
|
||||
@ -593,26 +600,26 @@ static_assert(
|
||||
|
||||
static_assert(std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>,
|
||||
quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(std::convertible_to<quantity_point<(isq::height[m]), mean_sea_level>,
|
||||
quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
|
||||
static_assert(std::constructible_from<quantity_point<(isq::height[km]), mean_sea_level>,
|
||||
quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(isq::height[km]), mean_sea_level>>);
|
||||
static_assert(std::convertible_to<quantity_point<(isq::height[m]), mean_sea_level>,
|
||||
quantity_point<(isq::height[km]), mean_sea_level>>);
|
||||
|
||||
static_assert(std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>,
|
||||
quantity_point<(isq::height[km]), mean_sea_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::height[km]), mean_sea_level>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(std::convertible_to<quantity_point<(isq::height[km]), mean_sea_level>,
|
||||
quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(si::metre), mean_sea_level>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(std::constructible_from<quantity_point<(si::metre), mean_sea_level>,
|
||||
quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(si::metre), mean_sea_level>>);
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(si::metre), mean_sea_level>>);
|
||||
static_assert(std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>,
|
||||
quantity_point<(si::metre), mean_sea_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(si::metre), mean_sea_level>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
|
||||
@ -623,20 +630,21 @@ static_assert(std::convertible_to<quantity_point<special_height[m], mean_sea_lev
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(si::metre), ground_level>, quantity_point<(si::metre), ground_level>>);
|
||||
static_assert(std::convertible_to<quantity_point<(si::metre), ground_level>, quantity_point<(si::metre), ground_level>>);
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(isq::height[m]), ground_level>, quantity_point<(isq::height[m]), ground_level>>);
|
||||
std::convertible_to<quantity_point<(si::metre), ground_level>, quantity_point<(si::metre), ground_level>>);
|
||||
|
||||
static_assert(std::constructible_from<quantity_point<(isq::height[m]), ground_level>,
|
||||
quantity_point<(isq::height[m]), ground_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::height[m]), ground_level>, quantity_point<(isq::height[m]), ground_level>>);
|
||||
|
||||
static_assert(std::constructible_from<quantity_point<(isq::height[km]), ground_level>,
|
||||
quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::height[m]), ground_level>, quantity_point<(isq::height[km]), mean_sea_level>>);
|
||||
static_assert(std::convertible_to<quantity_point<(isq::height[m]), ground_level>,
|
||||
quantity_point<(isq::height[km]), mean_sea_level>>);
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(isq::height[m]), ground_level>, quantity_point<(isq::height[km]), ground_level>>);
|
||||
static_assert(std::constructible_from<quantity_point<(isq::height[m]), ground_level>,
|
||||
quantity_point<(isq::height[km]), ground_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::height[km]), ground_level>, quantity_point<(isq::height[m]), ground_level>>);
|
||||
|
||||
@ -657,11 +665,13 @@ static_assert(
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(si::metre), mean_sea_level>, quantity_point<(si::metre), ground_level>>);
|
||||
static_assert(std::convertible_to<quantity_point<(si::metre), ground_level>, quantity_point<(si::metre), mean_sea_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(si::metre), ground_level>, quantity_point<(si::metre), mean_sea_level>>);
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(si::metre), ground_level>, quantity_point<(si::metre), mean_sea_level>>);
|
||||
static_assert(std::convertible_to<quantity_point<(si::metre), mean_sea_level>, quantity_point<(si::metre), ground_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(si::metre), mean_sea_level>, quantity_point<(si::metre), ground_level>>);
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(si::metre), ground_level>, quantity_point<(si::metre), other_ground_level>>);
|
||||
@ -684,25 +694,25 @@ static_assert(
|
||||
|
||||
static_assert(std::constructible_from<quantity_point<(isq::length[m]), zeroth_length>,
|
||||
quantity_point<(isq::height[m]), zeroth_length>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::height[m]), zeroth_length>, quantity_point<(isq::length[m]), zeroth_length>>);
|
||||
static_assert(std::convertible_to<quantity_point<(isq::height[m]), zeroth_length>,
|
||||
quantity_point<(isq::length[m]), zeroth_length>>);
|
||||
|
||||
// quantity_specs with common_quantity_spec
|
||||
static_assert(!std::constructible_from<quantity_point<(isq::width[m]), zeroth_length>,
|
||||
quantity_point<(isq::height[m]), zeroth_length>>);
|
||||
static_assert(
|
||||
!std::convertible_to<quantity_point<(isq::height[m]), zeroth_length>, quantity_point<(isq::width[m]), zeroth_length>>);
|
||||
static_assert(!std::convertible_to<quantity_point<(isq::height[m]), zeroth_length>,
|
||||
quantity_point<(isq::width[m]), zeroth_length>>);
|
||||
|
||||
static_assert(!std::constructible_from<quantity_point<(isq::height[m]), zeroth_length>,
|
||||
quantity_point<(isq::width[m]), zeroth_length>>);
|
||||
static_assert(
|
||||
!std::convertible_to<quantity_point<(isq::width[m]), zeroth_length>, quantity_point<(isq::height[m]), zeroth_length>>);
|
||||
static_assert(!std::convertible_to<quantity_point<(isq::width[m]), zeroth_length>,
|
||||
quantity_point<(isq::height[m]), zeroth_length>>);
|
||||
|
||||
// different dimensions
|
||||
static_assert(
|
||||
!std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(si::kelvin), (si::ice_point)>>);
|
||||
static_assert(
|
||||
!std::convertible_to<quantity_point<(si::kelvin), (si::ice_point)>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(!std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>,
|
||||
quantity_point<(si::kelvin), (si::ice_point)>>);
|
||||
static_assert(!std::convertible_to<quantity_point<(si::kelvin), (si::ice_point)>,
|
||||
quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
|
||||
// non-convertible quantity_specs
|
||||
static_assert(!std::constructible_from<quantity_point<special_height[m], mean_sea_level>,
|
||||
@ -748,16 +758,16 @@ static_assert(std::convertible_to<quantity_point<(isq::height[m]), mean_sea_leve
|
||||
// same but not a default origin
|
||||
static_assert(std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>,
|
||||
quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(std::convertible_to<quantity_point<(isq::height[m]), mean_sea_level>,
|
||||
quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(si::metre), mean_sea_level>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(std::constructible_from<quantity_point<(si::metre), mean_sea_level>,
|
||||
quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(si::metre), mean_sea_level>>);
|
||||
|
||||
static_assert(
|
||||
std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>, quantity_point<(si::metre), mean_sea_level>>);
|
||||
static_assert(std::constructible_from<quantity_point<(isq::height[m]), mean_sea_level>,
|
||||
quantity_point<(si::metre), mean_sea_level>>);
|
||||
static_assert(
|
||||
std::convertible_to<quantity_point<(si::metre), mean_sea_level>, quantity_point<(isq::height[m]), mean_sea_level>>);
|
||||
|
||||
@ -793,8 +803,8 @@ static_assert(
|
||||
std::convertible_to<sys_seconds, quantity_point<(isq::time[s]), chrono_point_origin<std::chrono::system_clock>>>);
|
||||
|
||||
// incompatible origin
|
||||
static_assert(
|
||||
!std::constructible_from<quantity_point<(isq::time[s]), chrono_point_origin<std::chrono::steady_clock>>, sys_seconds>);
|
||||
static_assert(!std::constructible_from<quantity_point<(isq::time[s]), chrono_point_origin<std::chrono::steady_clock>>,
|
||||
sys_seconds>);
|
||||
static_assert(
|
||||
!std::convertible_to<sys_seconds, quantity_point<(isq::time[s]), chrono_point_origin<std::chrono::steady_clock>>>);
|
||||
#endif
|
||||
@ -832,9 +842,11 @@ static_assert(quantity_point<(isq::height[m]), mean_sea_level>(tower_peak + 42 *
|
||||
|
||||
static_assert(quantity_point<(isq::height[m]), ground_level>(mean_sea_level + 84 * m).quantity_from(ground_level) ==
|
||||
42 * m);
|
||||
static_assert(quantity_point<(isq::height[m]), ground_level>(tower_peak + 42 * m).quantity_from(ground_level) == 84 * m);
|
||||
static_assert(quantity_point<(isq::height[m]), ground_level>(tower_peak + 42 * m).quantity_from(ground_level) ==
|
||||
84 * m);
|
||||
|
||||
static_assert(quantity_point<(isq::height[m]), tower_peak>(mean_sea_level + 42 * m).quantity_from(tower_peak) == -42 * m);
|
||||
static_assert(quantity_point<(isq::height[m]), tower_peak>(mean_sea_level + 42 * m).quantity_from(tower_peak) ==
|
||||
-42 * m);
|
||||
static_assert(quantity_point<(isq::height[m]), tower_peak>(ground_level + 84 * m).quantity_from(tower_peak) == 42 * m);
|
||||
|
||||
static_assert((mean_sea_level + 42 * m).point_for(mean_sea_level).quantity_from(mean_sea_level) == 42 * m);
|
||||
@ -1642,8 +1654,8 @@ static_assert(is_of_type<(zero_Hz + 5 * isq::frequency[Hz]) - (zero_Hz + 10 / (2
|
||||
|
||||
static_assert((quantity_point{10 / (2 * isq::period_duration[s])} + 5 * isq::frequency[Hz]).quantity_from_zero() ==
|
||||
10 * isq::frequency[Hz]);
|
||||
static_assert((10 / (2 * isq::period_duration[s]) + (zero_Hz + 5 * isq::frequency[Hz]))
|
||||
.quantity_from_zero() == 10 * isq::frequency[Hz]);
|
||||
static_assert((10 / (2 * isq::period_duration[s]) + (zero_Hz + 5 * isq::frequency[Hz])).quantity_from_zero() ==
|
||||
10 * isq::frequency[Hz]);
|
||||
static_assert((quantity_point{5 * isq::frequency[Hz]} + 10 / (2 * isq::period_duration[s])).quantity_from_zero() ==
|
||||
10 * isq::frequency[Hz]);
|
||||
static_assert((5 * isq::frequency[Hz] + quantity_point{10 / (2 * isq::period_duration[s])}).quantity_from_zero() ==
|
||||
|
@ -173,8 +173,9 @@ static_assert(!std::constructible_from<quantity<(isq::length[m])>, quantity<(isq
|
||||
static_assert(!std::convertible_to<quantity<(isq::speed[m / s])>, quantity<(isq::length[m])>>);
|
||||
|
||||
// implicit conversion from another quantity only if non-truncating
|
||||
static_assert(std::constructible_from<quantity<(isq::length[m])>, quantity<(isq::length[m]), int>>); // int -> double OK
|
||||
static_assert(std::convertible_to<quantity<(isq::length[m]), int>, quantity<(isq::length[m])>>); // int -> double OK
|
||||
static_assert(
|
||||
std::constructible_from<quantity<(isq::length[m])>, quantity<(isq::length[m]), int>>); // int -> double OK
|
||||
static_assert(std::convertible_to<quantity<(isq::length[m]), int>, quantity<(isq::length[m])>>); // int -> double OK
|
||||
|
||||
static_assert(!std::constructible_from<quantity<(isq::length[m]), int>,
|
||||
quantity<(isq::length[m])>>); // truncating double -> int not allowed
|
||||
@ -188,7 +189,7 @@ static_assert(std::convertible_to<quantity<(isq::length[km]), int>,
|
||||
|
||||
static_assert(!std::constructible_from<quantity<(isq::length[km]), int>,
|
||||
quantity<(isq::length[m]), int>>); // truncating metre<int> ->
|
||||
// kilometre<int> not allowed
|
||||
// kilometre<int> not allowed
|
||||
static_assert(
|
||||
!std::convertible_to<quantity<(isq::length[m]), int>,
|
||||
quantity<(isq::length[km]), int>>); // truncating metre<int> -> kilometre<int> not allowed
|
||||
@ -355,8 +356,8 @@ static_assert(quantity{123}.quantity_spec == kind_of<dimensionless>);
|
||||
#if MP_UNITS_HOSTED
|
||||
using namespace std::chrono_literals;
|
||||
static_assert(std::is_same_v<decltype(quantity{123s})::rep, std::chrono::seconds::rep>);
|
||||
//return type for "s" is not specified. is double for msvc
|
||||
//static_assert(std::is_same_v<decltype(quantity{123.s})::rep, long double>);
|
||||
// return type for "s" is not specified. is double for msvc
|
||||
// static_assert(std::is_same_v<decltype(quantity{123.s})::rep, long double>);
|
||||
static_assert(quantity{24h}.unit == si::hour);
|
||||
static_assert(quantity{24h}.quantity_spec == kind_of<isq::time>);
|
||||
#endif
|
||||
@ -455,7 +456,7 @@ static_assert((std::uint8_t{255}* m %= 257 * m).numerical_value_in(m) != [] {
|
||||
#if !(defined MP_UNITS_COMP_CLANG && MP_UNITS_COMP_CLANG < 18 && defined MP_UNITS_MODULES)
|
||||
// next two lines trigger conversions warnings
|
||||
// (warning disabled in CMake for this file)
|
||||
static_assert(((22 * m) *= 33.33).numerical_value_in(m) ==733);
|
||||
static_assert(((22 * m) *= 33.33).numerical_value_in(m) == 733);
|
||||
static_assert(((22 * m) /= 3.33).numerical_value_in(m) == 6);
|
||||
static_assert(((22 * m) *= 33.33 * one).numerical_value_in(m) == 733);
|
||||
static_assert(((22 * m) /= 3.33 * one).numerical_value_in(m) == 6);
|
||||
@ -850,14 +851,17 @@ static_assert(std::equality_comparable_with<quantity<(si::metre)>, quantity<si::
|
||||
static_assert(std::equality_comparable_with<quantity<(si::metre), int>, quantity<si::kilo<(si::metre)>, int>>);
|
||||
static_assert(std::equality_comparable_with<quantity<(isq::length[(si::metre)])>, quantity<(si::metre)>>);
|
||||
static_assert(std::equality_comparable_with<quantity<(isq::length[(si::metre)])>, quantity<(si::metre), int>>);
|
||||
static_assert(std::equality_comparable_with<quantity<(isq::length[(si::metre)])>, quantity<si::kilo<(si::metre)>, int>>);
|
||||
static_assert(
|
||||
std::equality_comparable_with<quantity<(isq::length[(si::metre)])>, quantity<si::kilo<(si::metre)>, int>>);
|
||||
static_assert(std::equality_comparable_with<quantity<(isq::width[(si::metre)])>, quantity<(si::metre)>>);
|
||||
static_assert(std::equality_comparable_with<quantity<(isq::width[(si::metre)])>, quantity<(si::metre), int>>);
|
||||
static_assert(std::equality_comparable_with<quantity<(isq::width[(si::metre)])>, quantity<(si::kilo<(si::metre)>), int>>);
|
||||
static_assert(std::equality_comparable_with<quantity<(isq::width[(si::metre)])>, quantity<(isq::height[(si::metre)])>>);
|
||||
static_assert(std::equality_comparable_with<quantity<(isq::width[(si::metre)])>, quantity<(isq::height[(si::metre)]), int>>);
|
||||
static_assert(
|
||||
std::equality_comparable_with<quantity<(isq::width[(si::metre)])>, quantity<(isq::height[(si::kilo<(si::metre)>)]), int>>);
|
||||
std::equality_comparable_with<quantity<(isq::width[(si::metre)])>, quantity<(si::kilo<(si::metre)>), int>>);
|
||||
static_assert(std::equality_comparable_with<quantity<(isq::width[(si::metre)])>, quantity<(isq::height[(si::metre)])>>);
|
||||
static_assert(
|
||||
std::equality_comparable_with<quantity<(isq::width[(si::metre)])>, quantity<(isq::height[(si::metre)]), int>>);
|
||||
static_assert(std::equality_comparable_with<quantity<(isq::width[(si::metre)])>,
|
||||
quantity<(isq::height[(si::kilo<(si::metre)>)]), int>>);
|
||||
|
||||
template<auto M>
|
||||
concept no_crossdimensional_equality = requires {
|
||||
@ -1054,11 +1058,12 @@ static_assert(QuantityOf<quantity<m / s>, isq::position_vector / isq::duration>)
|
||||
static_assert(QuantityOf<quantity<kind_of<(isq::speed)>[m / s]>, isq::position_vector / isq::duration>);
|
||||
static_assert(QuantityOf<quantity<(isq::velocity)[m / s], int>, isq::position_vector / isq::duration>);
|
||||
|
||||
static_assert(QuantityOf<decltype(10 * m), (isq::height)>); // kind of
|
||||
static_assert(QuantityOf<decltype(10 * m), (isq::height)>); // kind of
|
||||
static_assert(QuantityOf<decltype(10 * kind_of<(isq::length)>[m]), (isq::height)>); // kind of
|
||||
static_assert(!QuantityOf<decltype(10 * (isq::length[m])), (isq::height)>); // different kinds
|
||||
static_assert(!QuantityOf<decltype(10 * (isq::width[m])), (isq::height)>); // different kinds
|
||||
static_assert(QuantityOf<decltype(10 * (isq::speed[m / s])), (isq::speed)>);
|
||||
static_assert(QuantityOf<decltype(20 * (isq::length[m]) / (2 * isq::time[s])), (isq::speed)>); // derived unnamed quantity
|
||||
static_assert(
|
||||
QuantityOf<decltype(20 * (isq::length[m]) / (2 * isq::time[s])), (isq::speed)>); // derived unnamed quantity
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user