feat: preventing possible future units crash when using namespace std;
Resolves #317
This commit is contained in:
1 parent
6b72dd39c1
commit
2cf736a1e6
123 files changed
+1205
-1092
No files matched your search
+5
-5
@@ -22,13 +22,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
#include <mp_units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
#include <compare>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <ranges>
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
// TODO refactor two below functions with std::ranges when moved to modules
|
||||
|
||||
@@ -109,7 +109,7 @@ constexpr auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2, Cmp
|
||||
template<class I1, class I2>
|
||||
constexpr auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2)
|
||||
{
|
||||
return ::units::detail::lexicographical_compare_three_way(f1, l1, f2, l2, std::compare_three_way());
|
||||
return ::mp_units::detail::lexicographical_compare_three_way(f1, l1, f2, l2, std::compare_three_way());
|
||||
}
|
||||
|
||||
template<class ForwardIt>
|
||||
@@ -169,8 +169,8 @@ template<std::ranges::input_range R, std::weakly_incrementable O>
|
||||
requires std::indirectly_copyable<std::ranges::iterator_t<R>, O>
|
||||
constexpr copy_result<std::ranges::borrowed_iterator_t<R>, O> copy(R&& r, O result)
|
||||
{
|
||||
return ::units::detail::copy(std::ranges::begin(r), std::ranges::end(r), std::move(result));
|
||||
return ::mp_units::detail::copy(std::ranges::begin(r), std::ranges::end(r), std::move(result));
|
||||
}
|
||||
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
||||
+6
-6
@@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/type_list.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/math_concepts.h>
|
||||
#include <units/bits/ratio.h>
|
||||
#include <mp_units/bits/external/type_list.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/math_concepts.h>
|
||||
#include <mp_units/bits/ratio.h>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief Type list type used by the expression template framework
|
||||
@@ -554,4 +554,4 @@ template<template<typename> typename Proj, template<typename...> typename To, ty
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
+4
-4
@@ -22,9 +22,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
#include <mp_units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
// TODO use <algorithm> when moved to C++20 modules (parsing takes too long for each translation unit)
|
||||
#include <units/bits/algorithm.h>
|
||||
#include <mp_units/bits/algorithm.h>
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <compare>
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief A compile-time fixed string
|
||||
@@ -111,4 +111,4 @@ basic_fixed_string(CharT) -> basic_fixed_string<CharT, 1>;
|
||||
template<std::size_t N>
|
||||
using fixed_string = basic_fixed_string<char, N>;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
Vendored
File renamed without changes.
+3
-3
@@ -22,14 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
#include <mp_units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
UNITS_DIAGNOSTIC_PUSH
|
||||
UNITS_DIAGNOSTIC_IGNORE_EXPR_ALWAYS_TF
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -294,6 +294,6 @@ struct type_list_sort_impl<List<Types...>, Pred> {
|
||||
template<TypeList List, template<typename, typename> typename Pred>
|
||||
using type_list_sort = TYPENAME detail::type_list_sort_impl<List, Pred>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
|
||||
UNITS_DIAGNOSTIC_POP
|
||||
File renamed without changes.
+3
-3
@@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
// conditional
|
||||
namespace detail {
|
||||
@@ -80,4 +80,4 @@ concept is_derived_from_specialization_of = requires(T* t) { detail::to_base_spe
|
||||
template<typename T, typename... Ts>
|
||||
concept one_of = (false || ... || std::same_as<T, Ts>);
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
+12
-12
@@ -22,23 +22,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <units/bits/external/type_name.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/math_concepts.h>
|
||||
#include <units/bits/prime.h>
|
||||
#include <units/bits/ratio.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
#include <units/bits/text_tools.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <mp_units/bits/expression_template.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <mp_units/bits/external/type_name.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/math_concepts.h>
|
||||
#include <mp_units/bits/prime.h>
|
||||
#include <mp_units/bits/ratio.h>
|
||||
#include <mp_units/bits/symbol_text.h>
|
||||
#include <mp_units/bits/text_tools.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
#include <numbers>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -844,4 +844,4 @@ template<Magnitude auto M>
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
+2
-2
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
template<auto N>
|
||||
concept gt_zero = (N > 0);
|
||||
@@ -32,4 +32,4 @@ concept gt_zero = (N > 0);
|
||||
template<auto N>
|
||||
concept non_zero = (N != 0);
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/algorithm.h>
|
||||
#include <mp_units/bits/algorithm.h>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
[[nodiscard]] consteval bool is_prime_by_trial_division(std::uintmax_t n)
|
||||
{
|
||||
@@ -153,4 +153,4 @@ struct wheel_factorizer {
|
||||
[[nodiscard]] static consteval bool is_prime(std::size_t n) { return (n > 1) && find_first_factor(n) == n; }
|
||||
};
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
||||
+15
-15
@@ -22,19 +22,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/magnitude.h>
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/magnitude.h>
|
||||
#include <mp_units/bits/quantity_concepts.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/reference.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
UNITS_DIAGNOSTIC_PUSH
|
||||
// warning C4244: 'argument': conversion from 'intmax_t' to 'T', possible loss of data with T=int
|
||||
UNITS_DIAGNOSTIC_IGNORE_LOSS_OF_DATA
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
template<Reference auto R, RepresentationOf<R.quantity_spec.character> Rep>
|
||||
class quantity;
|
||||
@@ -188,11 +188,11 @@ template<Representation ToRep, auto R, typename Rep>
|
||||
// *
|
||||
// * This cast gets the target quantity point type to cast to or anything that works for quantity_cast. For example:
|
||||
// *
|
||||
// * auto q1 = units::quantity_point_cast<decltype(quantity_point{0_q_s})>(quantity_point{1_q_ms});
|
||||
// * auto q1 = units::quantity_point_cast<units::isq::si::time<units::isq::si::second>>(quantity_point{1_q_ms});
|
||||
// * auto q1 = units::quantity_point_cast<units::isq::si::dim_acceleration>(quantity_point{200_q_Gal});
|
||||
// * auto q1 = units::quantity_point_cast<units::isq::si::second>(quantity_point{1_q_ms});
|
||||
// * auto q1 = units::quantity_point_cast<int>(quantity_point{1_q_ms});
|
||||
// * auto q1 = mp_units::quantity_point_cast<decltype(quantity_point{0_q_s})>(quantity_point{1_q_ms});
|
||||
// * auto q1 = mp_units::quantity_point_cast<mp_units::isq::si::time<mp_units::isq::si::second>>(quantity_point{1_q_ms});
|
||||
// * auto q1 = mp_units::quantity_point_cast<mp_units::isq::si::dim_acceleration>(quantity_point{200_q_Gal});
|
||||
// * auto q1 = mp_units::quantity_point_cast<mp_units::isq::si::second>(quantity_point{1_q_ms});
|
||||
// * auto q1 = mp_units::quantity_point_cast<int>(quantity_point{1_q_ms});
|
||||
// *
|
||||
// * @tparam CastSpec a target quantity point type to cast to or anything that works for quantity_cast
|
||||
// */
|
||||
@@ -219,7 +219,7 @@ template<Representation ToRep, auto R, typename Rep>
|
||||
// *
|
||||
// * This cast gets both the target dimension and unit to cast to. For example:
|
||||
// *
|
||||
// * auto q1 = units::quantity_point_cast<units::isq::si::dim_speed, units::isq::si::kilometre_per_hour>(v1);
|
||||
// * auto q1 = mp_units::quantity_point_cast<mp_units::isq::si::dim_speed, mp_units::isq::si::kilometre_per_hour>(v1);
|
||||
// *
|
||||
// * @note This cast is especially useful when working with quantity points of unknown dimensions
|
||||
// * (@c unknown_dimension).
|
||||
@@ -234,6 +234,6 @@ template<Representation ToRep, auto R, typename Rep>
|
||||
// return quantity_point_cast<quantity_point<rebind_point_origin_dimension<O, ToD>, ToU, Rep>>(q);
|
||||
// }
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
|
||||
UNITS_DIAGNOSTIC_POP
|
||||
+6
-6
@@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief Quantity character
|
||||
@@ -243,4 +243,4 @@ concept quantity_point_like = requires(T q) {
|
||||
decltype(quantity_point_like_traits<T>::relative(q))>;
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
@@ -23,8 +23,8 @@
|
||||
#pragma once
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <units/bits/math_concepts.h>
|
||||
#include <units/bits/ratio_maths.h>
|
||||
#include <mp_units/bits/math_concepts.h>
|
||||
#include <mp_units/bits/ratio_maths.h>
|
||||
#include <cstdint>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <compare>
|
||||
#include <numeric>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
struct ratio;
|
||||
constexpr ratio inverse(const ratio& r);
|
||||
@@ -89,4 +89,4 @@ struct ratio {
|
||||
return ratio(res[0], res[1]);
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
+2
-2
@@ -31,7 +31,7 @@
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] constexpr T abs(T v) noexcept
|
||||
@@ -92,4 +92,4 @@ constexpr void normalize(std::intmax_t& num, std::intmax_t& den)
|
||||
return lhs * rhs;
|
||||
}
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
||||
+4
-4
@@ -23,8 +23,8 @@
|
||||
#pragma once
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <units/bits/external/fixed_string.h>
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <mp_units/bits/external/fixed_string.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <compare>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -185,4 +185,4 @@ template<typename UnicodeCharT, std::size_t N, std::size_t M>
|
||||
basic_symbol_text(const basic_fixed_string<UnicodeCharT, N>&, const basic_fixed_string<char, M>&)
|
||||
-> basic_symbol_text<UnicodeCharT, N, M>;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
+4
-4
@@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/fixed_string.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
#include <mp_units/bits/external/fixed_string.h>
|
||||
#include <mp_units/bits/symbol_text.h>
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
template<std::intmax_t Value>
|
||||
requires(0 <= Value) && (Value < 10)
|
||||
@@ -84,4 +84,4 @@ template<std::intmax_t Value>
|
||||
return regular<Value / 10>() + regular<Value % 10>();
|
||||
}
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
||||
+7
-7
@@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief Specifies if a value of a type should be treated as a floating-point value
|
||||
@@ -64,8 +64,8 @@ inline constexpr bool is_scalar = std::is_floating_point_v<Rep> || (std::is_inte
|
||||
*
|
||||
* @code{.cpp}
|
||||
* template<class T>
|
||||
* requires units::is_scalar<T>
|
||||
* inline constexpr bool units::is_vector<T> = true;
|
||||
* requires mp_units::is_scalar<T>
|
||||
* inline constexpr bool mp_units::is_vector<T> = true;
|
||||
* @endcode
|
||||
*/
|
||||
template<typename Rep>
|
||||
@@ -85,7 +85,7 @@ inline constexpr bool is_tensor = false;
|
||||
/**
|
||||
* @brief A type trait that defines zero, one, min, and max for a representation type
|
||||
*
|
||||
* The zero, one, min, and max member functions in units::quantity forward their work to
|
||||
* The zero, one, min, and max member functions in mp_units::quantity forward their work to
|
||||
* these methods. This type can be specialized if the representation Rep requires a specific
|
||||
* implementation to return these quantity objects.
|
||||
*
|
||||
@@ -153,4 +153,4 @@ struct quantity_like_traits;
|
||||
template<typename T>
|
||||
struct quantity_point_like_traits;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
@@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
#include <mp_units/bits/expression_template.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/symbol_text.h>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief A dimension of a base quantity
|
||||
@@ -256,4 +256,4 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Dimension D>
|
||||
|
||||
// TODO consider adding the support for text output of the dimensional equation
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
@@ -23,19 +23,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/quantity_cast.h>
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/quantity_cast.h>
|
||||
#include <mp_units/bits/quantity_concepts.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
#include <mp_units/reference.h>
|
||||
#include <mp_units/unit.h>
|
||||
#include <compare>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -153,10 +153,10 @@ public:
|
||||
#endif
|
||||
|
||||
template<Unit U>
|
||||
requires quantity_convertible_to_<quantity, quantity<::units::reference<quantity_spec, U{}>{}, Rep>>
|
||||
[[nodiscard]] constexpr quantity<::units::reference<quantity_spec, U{}>{}, Rep> operator[](U) const
|
||||
requires quantity_convertible_to_<quantity, quantity<::mp_units::reference<quantity_spec, U{}>{}, Rep>>
|
||||
[[nodiscard]] constexpr quantity<::mp_units::reference<quantity_spec, U{}>{}, Rep> operator[](U) const
|
||||
{
|
||||
return quantity<::units::reference<quantity_spec, U{}>{}, Rep>{*this};
|
||||
return quantity<::mp_units::reference<quantity_spec, U{}>{}, Rep>{*this};
|
||||
}
|
||||
|
||||
// member unary operators
|
||||
@@ -337,44 +337,44 @@ public:
|
||||
[[nodiscard]] friend constexpr Quantity auto operator+(const quantity& lhs, const Value& rhs)
|
||||
requires requires { // TODO: Simplify when Clang catches up.
|
||||
requires !Quantity<Value>;
|
||||
requires unit == ::units::one;
|
||||
requires unit == ::mp_units::one;
|
||||
requires invoke_result_of_<R.quantity_spec.character, std::plus<>, rep, Value>;
|
||||
}
|
||||
{
|
||||
return ::units::quantity(lhs.number() + rhs);
|
||||
return ::mp_units::quantity(lhs.number() + rhs);
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator+(const Value& lhs, const quantity& rhs)
|
||||
requires requires { // TODO: Simplify when Clang catches up.
|
||||
requires !Quantity<Value>;
|
||||
requires unit == ::units::one;
|
||||
requires unit == ::mp_units::one;
|
||||
requires invoke_result_of_<R.quantity_spec.character, std::plus<>, Value, rep>;
|
||||
}
|
||||
{
|
||||
return ::units::quantity(lhs + rhs.number());
|
||||
return ::mp_units::quantity(lhs + rhs.number());
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator-(const quantity& lhs, const Value& rhs)
|
||||
requires requires { // TODO: Simplify when Clang catches up.
|
||||
requires !Quantity<Value>;
|
||||
requires unit == ::units::one;
|
||||
requires unit == ::mp_units::one;
|
||||
requires invoke_result_of_<R.quantity_spec.character, std::minus<>, rep, Value>;
|
||||
}
|
||||
{
|
||||
return ::units::quantity(lhs.number() - rhs);
|
||||
return ::mp_units::quantity(lhs.number() - rhs);
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator-(const Value& lhs, const quantity& rhs)
|
||||
requires requires { // TODO: Simplify when Clang catches up.
|
||||
requires !Quantity<Value>;
|
||||
requires unit == ::units::one;
|
||||
requires unit == ::mp_units::one;
|
||||
requires invoke_result_of_<R.quantity_spec.character, std::minus<>, Value, rep>;
|
||||
}
|
||||
{
|
||||
return ::units::quantity(lhs - rhs.number());
|
||||
return ::mp_units::quantity(lhs - rhs.number());
|
||||
}
|
||||
|
||||
template<Representation Value>
|
||||
@@ -406,7 +406,7 @@ public:
|
||||
requires(!Quantity<Value>) && invoke_result_of_<R.quantity_spec.character, std::divides<>, const Value&, rep>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator/(const Value& v, const quantity& q)
|
||||
{
|
||||
return (dimensionless[::units::one] / reference)(v / q.number());
|
||||
return (dimensionless[::mp_units::one] / reference)(v / q.number());
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@@ -444,7 +444,7 @@ public:
|
||||
template<auto R, typename Rep>
|
||||
explicit(false) quantity(quantity<R, Rep>) -> quantity<R, Rep>;
|
||||
|
||||
template<RepresentationOf<units::quantity_character::scalar> Rep>
|
||||
template<RepresentationOf<mp_units::quantity_character::scalar> Rep>
|
||||
explicit(false) quantity(Rep) -> quantity<dimensionless[one], Rep>;
|
||||
|
||||
#if !UNITS_COMP_CLANG || UNITS_COMP_CLANG > 16
|
||||
@@ -524,21 +524,21 @@ template<Quantity Q1, Quantity Q2>
|
||||
return quantity_cast<ref>(lhs).number() == quantity_cast<ref>(rhs).number();
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
|
||||
namespace std {
|
||||
|
||||
template<units::Quantity Q1, units::Quantity Q2>
|
||||
template<mp_units::Quantity Q1, mp_units::Quantity Q2>
|
||||
requires requires {
|
||||
{
|
||||
units::common_reference(Q1::reference, Q2::reference)
|
||||
} -> units::Reference;
|
||||
mp_units::common_reference(Q1::reference, Q2::reference)
|
||||
} -> mp_units::Reference;
|
||||
typename common_type_t<typename Q1::rep, typename Q2::rep>;
|
||||
}
|
||||
struct common_type<Q1, Q2> {
|
||||
public:
|
||||
using type = units::quantity<units::common_reference(Q1::reference, Q2::reference),
|
||||
common_type_t<typename Q1::rep, typename Q2::rep>>;
|
||||
using type = mp_units::quantity<mp_units::common_reference(Q1::reference, Q2::reference),
|
||||
common_type_t<typename Q1::rep, typename Q2::rep>>;
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
+4
-4
@@ -23,11 +23,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/customization_points.h>
|
||||
#include <units/quantity.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/quantity.h>
|
||||
#include <compare>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -234,4 +234,4 @@ explicit quantity_point(QP)
|
||||
-> quantity_point<quantity_point_like_traits<QP>::reference, quantity_point_like_traits<QP>::point_origin,
|
||||
typename quantity_point_like_traits<QP>::rep>;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
+13
-13
@@ -22,16 +22,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/algorithm.h>
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/type_name.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/algorithm.h>
|
||||
#include <mp_units/bits/expression_template.h>
|
||||
#include <mp_units/bits/external/type_name.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/quantity_concepts.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/unit.h>
|
||||
#include <tuple>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -381,14 +381,14 @@ struct quantity_spec<Self, Q, Args...> : std::remove_const_t<decltype(Q)> {
|
||||
|
||||
#ifdef __cpp_explicit_this_parameter
|
||||
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
inline constexpr struct name : ::units::quantity_spec<##__VA_ARGS__> { \
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
inline constexpr struct name : ::mp_units::quantity_spec<##__VA_ARGS__> { \
|
||||
} name
|
||||
|
||||
#else
|
||||
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
inline constexpr struct name : ::units::quantity_spec<name, ##__VA_ARGS__> { \
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
inline constexpr struct name : ::mp_units::quantity_spec<name, ##__VA_ARGS__> { \
|
||||
} name
|
||||
|
||||
#endif
|
||||
@@ -503,4 +503,4 @@ template<std::intmax_t Num, std::intmax_t Den = 1, QuantitySpec Q>
|
||||
detail::type_list_of_quantity_spec_less>(q);
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/quantity_concepts.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief Quantity reference type
|
||||
@@ -109,4 +109,4 @@ template<Reference R1, Reference R2>
|
||||
common_unit(r1.unit, r2.unit, rest.unit...)>{};
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
+5
-5
@@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
#include <mp_units/reference.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief System-specific reference
|
||||
@@ -69,4 +69,4 @@ struct system_reference {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
@@ -22,20 +22,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/algorithm.h>
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/fixed_string.h>
|
||||
#include <units/bits/external/type_name.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/magnitude.h>
|
||||
#include <units/bits/ratio.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
#include <units/bits/text_tools.h>
|
||||
#include <units/dimension.h>
|
||||
#include <mp_units/bits/algorithm.h>
|
||||
#include <mp_units/bits/expression_template.h>
|
||||
#include <mp_units/bits/external/fixed_string.h>
|
||||
#include <mp_units/bits/external/type_name.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/magnitude.h>
|
||||
#include <mp_units/bits/ratio.h>
|
||||
#include <mp_units/bits/symbol_text.h>
|
||||
#include <mp_units/bits/text_tools.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
#ifdef __cpp_explicit_this_parameter
|
||||
template<auto...>
|
||||
@@ -483,7 +483,7 @@ template<Unit T, basic_symbol_text Symbol, Unit auto U>
|
||||
template<typename F, int Num, int... Den, typename... Us>
|
||||
[[nodiscard]] consteval auto get_canonical_unit_impl(const power<F, Num, Den...>&, const type_list<Us...>&)
|
||||
{
|
||||
auto mag = (units::mag<1> * ... * pow<Num, Den...>(get_canonical_unit_impl(Us{}, Us{}).mag));
|
||||
auto mag = (mp_units::mag<1> * ... * pow<Num, Den...>(get_canonical_unit_impl(Us{}, Us{}).mag));
|
||||
auto u = (one * ... * pow<Num, Den...>(get_canonical_unit_impl(Us{}, Us{}).reference_unit));
|
||||
return canonical_unit{mag, u};
|
||||
}
|
||||
@@ -506,7 +506,7 @@ template<typename T, typename F, int Num, int... Den>
|
||||
template<typename... Us>
|
||||
[[nodiscard]] consteval auto get_canonical_unit_impl(const type_list<Us...>&)
|
||||
{
|
||||
auto mag = (units::mag<1> * ... * get_canonical_unit_impl(Us{}, Us{}).mag);
|
||||
auto mag = (mp_units::mag<1> * ... * get_canonical_unit_impl(Us{}, Us{}).mag);
|
||||
auto u = (one * ... * get_canonical_unit_impl(Us{}, Us{}).reference_unit);
|
||||
return canonical_unit{mag, u};
|
||||
}
|
||||
@@ -564,7 +564,7 @@ using type_list_of_unit_less = expr_less<T1, T2, unit_less>;
|
||||
template<Magnitude M, Unit U>
|
||||
[[nodiscard]] consteval Unit auto operator*(M mag, const U u)
|
||||
{
|
||||
if constexpr (mag == units::mag<1>)
|
||||
if constexpr (mag == mp_units::mag<1>)
|
||||
return u;
|
||||
else
|
||||
return scaled_unit<mag, U>{};
|
||||
@@ -923,4 +923,4 @@ template<typename CharT = char, Unit U>
|
||||
return buffer;
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
Reference in new issue
Block a user