mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 19:04:27 +02:00
feat: proper exports implemented for C++ modules
This commit is contained in:
@@ -46,6 +46,7 @@ add_mp_units_module(
|
||||
include/mp-units/bits/get_associated_quantity.h
|
||||
include/mp-units/bits/get_common_base.h
|
||||
include/mp-units/bits/magnitude.h
|
||||
include/mp-units/bits/module_macros.h
|
||||
include/mp-units/bits/quantity_cast.h
|
||||
include/mp-units/bits/quantity_concepts.h
|
||||
include/mp-units/bits/quantity_point_concepts.h
|
||||
|
@@ -24,11 +24,12 @@
|
||||
|
||||
#include <mp-units/bits/expression_template.h>
|
||||
#include <mp-units/bits/external/type_traits.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/symbol_text.h>
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
template<basic_symbol_text Symbol>
|
||||
MP_UNITS_EXPORT template<basic_symbol_text Symbol>
|
||||
struct base_dimension;
|
||||
|
||||
namespace detail {
|
||||
@@ -98,7 +99,7 @@ concept DerivedDimension = is_specialization_of<T, derived_dimension> || is_dime
|
||||
*
|
||||
* Satisfied by all dimension types for which either `BaseDimension<T>` or `DerivedDimension<T>` is `true`.
|
||||
*/
|
||||
template<typename T>
|
||||
MP_UNITS_EXPORT template<typename T>
|
||||
concept Dimension = detail::BaseDimension<T> || detail::DerivedDimension<T>;
|
||||
|
||||
/**
|
||||
@@ -106,7 +107,7 @@ concept Dimension = detail::BaseDimension<T> || detail::DerivedDimension<T>;
|
||||
*
|
||||
* Satisfied when both argument satisfy a `Dimension` concept and when they compare equal.
|
||||
*/
|
||||
template<typename T, auto D>
|
||||
MP_UNITS_EXPORT template<typename T, auto D>
|
||||
concept DimensionOf = Dimension<T> && Dimension<std::remove_const_t<decltype(D)>> && (T{} == D);
|
||||
|
||||
} // namespace mp_units
|
||||
|
@@ -23,10 +23,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <compare>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <ranges>
|
||||
#endif
|
||||
|
||||
namespace mp_units::detail {
|
||||
|
||||
|
@@ -24,17 +24,17 @@
|
||||
|
||||
// TODO use <algorithm> when moved to C++20 modules (parsing takes too long for each translation unit)
|
||||
#include <mp-units/bits/external/algorithm.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/compat_macros.h> // IWYU pragma: keep
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <compare>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <ostream>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
|
@@ -22,7 +22,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <version>
|
||||
#endif
|
||||
|
||||
#if __clang__
|
||||
#define MP_UNITS_COMP_CLANG __clang_major__
|
||||
|
@@ -22,7 +22,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <cstdint>
|
||||
#endif
|
||||
|
||||
namespace mp_units::detail {
|
||||
|
||||
|
@@ -23,12 +23,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/external/algorithm.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
#endif
|
||||
|
||||
namespace mp_units::detail {
|
||||
|
||||
|
@@ -23,9 +23,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
MP_UNITS_DIAGNOSTIC_PUSH
|
||||
MP_UNITS_DIAGNOSTIC_IGNORE_EXPR_ALWAYS_TF
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] consteval std::string_view type_name()
|
||||
|
@@ -23,8 +23,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/external/hacks.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
@@ -45,6 +49,8 @@ struct conditional_impl<true> {
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<bool B, typename T, typename F>
|
||||
using conditional = MP_UNITS_TYPENAME detail::conditional_impl<B>::template type<T, F>;
|
||||
|
||||
@@ -71,6 +77,8 @@ inline constexpr bool is_specialization_of_v = false;
|
||||
template<auto... Params, template<auto...> typename Type>
|
||||
inline constexpr bool is_specialization_of_v<Type<Params...>, Type> = true;
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
// is_derived_from_specialization_of
|
||||
namespace detail {
|
||||
|
||||
|
@@ -29,11 +29,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <mp-units/compat_macros.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <concepts>
|
||||
#include <limits>
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
// most of the below code is based on/copied from fmtlib
|
||||
|
||||
|
@@ -28,14 +28,18 @@
|
||||
#include <mp-units/bits/external/prime.h>
|
||||
#include <mp-units/bits/external/type_name.h>
|
||||
#include <mp-units/bits/external/type_traits.h>
|
||||
#include <mp-units/bits/module_macros.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>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
#include <numbers>
|
||||
#include <optional>
|
||||
#endif
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
@@ -59,7 +63,7 @@ inline constexpr bool is_specialization_of_magnitude = false;
|
||||
/**
|
||||
* @brief Concept to detect whether T is a valid Magnitude.
|
||||
*/
|
||||
template<typename T>
|
||||
MP_UNITS_EXPORT template<typename T>
|
||||
concept Magnitude = detail::is_magnitude<T>;
|
||||
|
||||
/**
|
||||
@@ -525,6 +529,8 @@ constexpr T get_value(const magnitude<Ms...>&)
|
||||
return result;
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
/**
|
||||
* @brief A convenient Magnitude constant for pi, which we can manipulate like a regular number.
|
||||
*/
|
||||
@@ -575,6 +581,8 @@ template<auto... Ms>
|
||||
return pow<1, 3>(m);
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Magnitude product implementation.
|
||||
|
||||
@@ -595,6 +603,7 @@ consteval bool less(MagnitudeSpec auto lhs, MagnitudeSpec auto rhs)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
// Base cases, for when either (or both) inputs are the identity.
|
||||
constexpr Magnitude auto operator*(magnitude<>, magnitude<>) { return magnitude<>{}; }
|
||||
@@ -644,6 +653,8 @@ template<auto H1, auto... T1, auto H2, auto... T2>
|
||||
|
||||
[[nodiscard]] consteval auto operator/(Magnitude auto l, Magnitude auto r) { return l * pow<-1>(r); }
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Magnitude numerator and denominator implementation.
|
||||
|
||||
@@ -776,7 +787,7 @@ using common_magnitude_type = decltype(common_magnitude_type_impl(M));
|
||||
// To provide the first factor for a given number, specialize this variable template.
|
||||
//
|
||||
// WARNING: The program behaviour will be undefined if you provide a wrong answer, so check your math!
|
||||
template<std::intmax_t N>
|
||||
MP_UNITS_EXPORT template<std::intmax_t N>
|
||||
inline constexpr std::optional<std::intmax_t> known_first_factor = std::nullopt;
|
||||
|
||||
namespace detail {
|
||||
@@ -819,14 +830,14 @@ inline constexpr auto prime_factorization_v = prime_factorization<N>::value;
|
||||
* This will be the main way end users create Magnitudes. They should rarely (if ever) create a magnitude<...> by
|
||||
* manually adding base powers.
|
||||
*/
|
||||
template<ratio R>
|
||||
MP_UNITS_EXPORT template<ratio R>
|
||||
requires detail::gt_zero<R.num>
|
||||
inline constexpr Magnitude auto mag = detail::prime_factorization_v<R.num> / detail::prime_factorization_v<R.den>;
|
||||
|
||||
/**
|
||||
* @brief Create a Magnitude which is some rational number raised to a rational power.
|
||||
*/
|
||||
template<ratio Base, ratio Pow>
|
||||
MP_UNITS_EXPORT template<ratio Base, ratio Pow>
|
||||
requires detail::gt_zero<Base.num>
|
||||
inline constexpr Magnitude auto mag_power = pow<Pow.num, Pow.den>(mag<Base>);
|
||||
|
||||
|
40
src/core/include/mp-units/bits/module_macros.h
Normal file
40
src/core/include/mp-units/bits/module_macros.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// the below line is commented out on purpose (clang-17 does not work otherwise)
|
||||
// #pragma once
|
||||
|
||||
#ifdef MP_UNITS_IN_MODULE_INTERFACE
|
||||
|
||||
#define MP_UNITS_EXPORT export
|
||||
#define MP_UNITS_EXPORT_BEGIN \
|
||||
export \
|
||||
{
|
||||
#define MP_UNITS_EXPORT_END }
|
||||
|
||||
#else
|
||||
|
||||
#define MP_UNITS_EXPORT
|
||||
#define MP_UNITS_EXPORT_BEGIN
|
||||
#define MP_UNITS_EXPORT_END
|
||||
|
||||
#endif
|
@@ -22,11 +22,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_concepts.h>
|
||||
#include <mp-units/bits/quantity_point_concepts.h>
|
||||
#include <mp-units/reference.h>
|
||||
#include <type_traits>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_spec_concepts.h>
|
||||
#include <mp-units/bits/reference_concepts.h>
|
||||
#include <mp-units/bits/representation_concepts.h>
|
||||
@@ -29,7 +30,7 @@
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
template<Reference auto R, RepresentationOf<get_quantity_spec(R).character> Rep>
|
||||
MP_UNITS_EXPORT template<Reference auto R, RepresentationOf<get_quantity_spec(R).character> Rep>
|
||||
class quantity;
|
||||
|
||||
namespace detail {
|
||||
@@ -43,6 +44,8 @@ inline constexpr bool is_derived_from_specialization_of_quantity =
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
/**
|
||||
* @brief A concept matching all quantities in the library
|
||||
*
|
||||
@@ -82,4 +85,6 @@ concept QuantityLike = requires {
|
||||
} -> detail::ConversionSpecOf<T>;
|
||||
};
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_concepts.h>
|
||||
#include <mp-units/bits/quantity_spec_concepts.h>
|
||||
#include <mp-units/bits/reference_concepts.h>
|
||||
@@ -30,7 +31,7 @@
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
template<typename Derived, QuantitySpec auto QS>
|
||||
MP_UNITS_EXPORT template<typename Derived, QuantitySpec auto QS>
|
||||
struct absolute_point_origin;
|
||||
|
||||
namespace detail {
|
||||
@@ -62,10 +63,10 @@ concept AbsolutePointOrigin =
|
||||
*
|
||||
* Satisfied by all types being either a specialization or derived from `quantity_point`
|
||||
*/
|
||||
template<typename T>
|
||||
MP_UNITS_EXPORT template<typename T>
|
||||
concept QuantityPoint = detail::is_quantity_point<T>;
|
||||
|
||||
template<QuantityPoint auto QP>
|
||||
MP_UNITS_EXPORT template<QuantityPoint auto QP>
|
||||
struct relative_point_origin;
|
||||
|
||||
namespace detail {
|
||||
@@ -94,7 +95,7 @@ concept RelativePointOrigin =
|
||||
*
|
||||
* Satisfied by either quantity points or by all types derived from `absolute_point_origin` class template.
|
||||
*/
|
||||
template<typename T>
|
||||
MP_UNITS_EXPORT template<typename T>
|
||||
concept PointOrigin = detail::AbsolutePointOrigin<T> || detail::RelativePointOrigin<T>;
|
||||
|
||||
/**
|
||||
@@ -102,11 +103,11 @@ concept PointOrigin = detail::AbsolutePointOrigin<T> || detail::RelativePointOri
|
||||
*
|
||||
* Satisfied by all quantity point origins that are defined using a provided quantity specification.
|
||||
*/
|
||||
template<typename T, auto QS>
|
||||
MP_UNITS_EXPORT template<typename T, auto QS>
|
||||
concept PointOriginFor = PointOrigin<T> && QuantitySpecOf<std::remove_const_t<decltype(QS)>, T::quantity_spec>;
|
||||
|
||||
template<Reference auto R, PointOriginFor<get_quantity_spec(R)> auto PO,
|
||||
RepresentationOf<get_quantity_spec(R).character> Rep>
|
||||
MP_UNITS_EXPORT template<Reference auto R, PointOriginFor<get_quantity_spec(R)> auto PO,
|
||||
RepresentationOf<get_quantity_spec(R).character> Rep>
|
||||
class quantity_point;
|
||||
|
||||
namespace detail {
|
||||
@@ -151,7 +152,7 @@ concept SameAbsolutePointOriginAs =
|
||||
* the provided quantity_spec type, or quantity points having the origin with the same
|
||||
* `absolute_point_origin`.
|
||||
*/
|
||||
template<typename QP, auto V>
|
||||
MP_UNITS_EXPORT template<typename QP, auto V>
|
||||
concept QuantityPointOf =
|
||||
QuantityPoint<QP> && (QuantitySpecOf<std::remove_const_t<decltype(QP::quantity_spec)>, V> ||
|
||||
detail::SameAbsolutePointOriginAs<std::remove_const_t<decltype(QP::absolute_point_origin)>, V>);
|
||||
@@ -162,7 +163,7 @@ concept QuantityPointOf =
|
||||
* Satisfied by all external types (not-defined in mp-units) that via a `quantity_point_like_traits` provide
|
||||
* all quantity_point-specific information.
|
||||
*/
|
||||
template<typename T>
|
||||
MP_UNITS_EXPORT template<typename T>
|
||||
concept QuantityPointLike = requires {
|
||||
quantity_point_like_traits<T>::reference;
|
||||
requires Reference<std::remove_const_t<decltype(quantity_point_like_traits<T>::reference)>>;
|
||||
|
@@ -24,9 +24,11 @@
|
||||
|
||||
#include <mp-units/bits/dimension_concepts.h>
|
||||
#include <mp-units/bits/expression_template.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
#ifdef __cpp_explicit_this_parameter
|
||||
template<auto...>
|
||||
#else
|
||||
@@ -125,11 +127,11 @@ concept IntermediateDerivedQuantitySpec =
|
||||
} // namespace detail
|
||||
|
||||
|
||||
template<typename T>
|
||||
MP_UNITS_EXPORT template<typename T>
|
||||
concept QuantitySpec =
|
||||
detail::NamedQuantitySpec<T> || detail::IntermediateDerivedQuantitySpec<T> || detail::QuantityKindSpec<T>;
|
||||
|
||||
template<QuantitySpec Q>
|
||||
MP_UNITS_EXPORT template<QuantitySpec Q>
|
||||
[[nodiscard]] consteval detail::QuantityKindSpec auto get_kind(Q q);
|
||||
|
||||
namespace detail {
|
||||
@@ -142,7 +144,7 @@ concept NestedQuantityKindSpecOf =
|
||||
|
||||
}
|
||||
|
||||
template<typename T, auto QS>
|
||||
MP_UNITS_EXPORT template<typename T, auto QS>
|
||||
concept QuantitySpecOf =
|
||||
QuantitySpec<T> && QuantitySpec<std::remove_const_t<decltype(QS)>> && implicitly_convertible(T{}, QS) &&
|
||||
// the below is to make the following work
|
||||
|
@@ -24,9 +24,13 @@
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <mp-units/bits/external/hacks.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <compare>
|
||||
#include <cstdint>
|
||||
#include <numeric>
|
||||
#endif
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
@@ -63,7 +67,7 @@ template<typename T>
|
||||
* This class is really similar to @c std::ratio. An important difference is the fact that the objects of that class
|
||||
* are used as class NTTPs rather then a type template parameter kind.
|
||||
*/
|
||||
struct ratio {
|
||||
MP_UNITS_EXPORT struct ratio {
|
||||
std::intmax_t num;
|
||||
std::intmax_t den;
|
||||
|
||||
|
@@ -22,12 +22,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_spec_concepts.h>
|
||||
#include <mp-units/bits/unit_concepts.h>
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
template<QuantitySpec Q, Unit U>
|
||||
MP_UNITS_EXPORT template<QuantitySpec Q, Unit U>
|
||||
struct reference;
|
||||
|
||||
namespace detail {
|
||||
@@ -41,6 +42,8 @@ struct is_specialization_of_reference<reference<Q, U>> : std::true_type {};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
/**
|
||||
* @brief A concept matching all references in the library.
|
||||
*
|
||||
@@ -74,4 +77,6 @@ template<typename Q, typename U>
|
||||
template<typename T, auto QS>
|
||||
concept ReferenceOf = Reference<T> && QuantitySpecOf<std::remove_const_t<decltype(get_quantity_spec(T{}))>, QS>;
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units
|
||||
|
@@ -22,11 +22,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/customization_points.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
@@ -48,7 +52,7 @@ namespace mp_units {
|
||||
* For example, the Cauchy stress tensor possess magnitude, direction,
|
||||
* and orientation qualities.
|
||||
*/
|
||||
enum class quantity_character { scalar, vector, tensor };
|
||||
MP_UNITS_EXPORT enum class quantity_character { scalar, vector, tensor };
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -75,10 +79,10 @@ concept Scalable =
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
MP_UNITS_EXPORT template<typename T>
|
||||
concept Representation = (is_scalar<T> || is_vector<T> || is_tensor<T>)&&std::regular<T> && detail::Scalable<T>;
|
||||
|
||||
template<typename T, quantity_character Ch>
|
||||
MP_UNITS_EXPORT template<typename T, quantity_character Ch>
|
||||
concept RepresentationOf = Representation<T> && ((Ch == quantity_character::scalar && is_scalar<T>) ||
|
||||
(Ch == quantity_character::vector && is_vector<T>) ||
|
||||
(Ch == quantity_character::tensor && is_tensor<T>));
|
||||
|
@@ -25,15 +25,19 @@
|
||||
// IWYU pragma: begin_exports
|
||||
#include <mp-units/bits/external/fixed_string.h>
|
||||
#include <mp-units/bits/external/hacks.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <compare>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#endif
|
||||
|
||||
#if __cpp_lib_text_encoding
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <text_encoding>
|
||||
#endif
|
||||
static_assert(std::text_encoding::literal().mib() == std::text_encoding::id::UTF8);
|
||||
#endif
|
||||
|
||||
@@ -74,7 +78,7 @@ constexpr fixed_u8string<N> to_u8string(fixed_string<N> txt)
|
||||
* @tparam N The size of a Unicode symbol
|
||||
* @tparam M The size of the ASCII-only symbol
|
||||
*/
|
||||
template<std::size_t N, std::size_t M>
|
||||
MP_UNITS_EXPORT template<std::size_t N, std::size_t M>
|
||||
struct basic_symbol_text {
|
||||
fixed_u8string<N> unicode_;
|
||||
fixed_string<M> ascii_;
|
||||
|
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <mp-units/bits/expression_template.h>
|
||||
#include <mp-units/bits/magnitude.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_spec_concepts.h>
|
||||
#include <mp-units/bits/symbol_text.h>
|
||||
|
||||
@@ -42,13 +43,13 @@ struct is_unit : std::false_type {};
|
||||
*
|
||||
* Satisfied by all unit types provided by the library.
|
||||
*/
|
||||
template<typename T>
|
||||
MP_UNITS_EXPORT template<typename T>
|
||||
concept Unit = detail::is_unit<T>::value;
|
||||
|
||||
template<Magnitude auto M, Unit U>
|
||||
struct scaled_unit;
|
||||
|
||||
template<basic_symbol_text Symbol, auto...>
|
||||
MP_UNITS_EXPORT template<basic_symbol_text Symbol, auto...>
|
||||
struct named_unit;
|
||||
|
||||
namespace detail {
|
||||
@@ -84,13 +85,13 @@ concept NamedUnit =
|
||||
* `hour` or `degree_Celsius`. For those a partial specialization with the value `false` should be
|
||||
* provided.
|
||||
*/
|
||||
template<Unit auto V>
|
||||
MP_UNITS_EXPORT template<Unit auto V>
|
||||
inline constexpr bool unit_can_be_prefixed = true;
|
||||
|
||||
/**
|
||||
* @brief A concept to be used to define prefixes for a unit
|
||||
*/
|
||||
template<typename T>
|
||||
MP_UNITS_EXPORT template<typename T>
|
||||
concept PrefixableUnit = detail::NamedUnit<T> && unit_can_be_prefixed<T{}>;
|
||||
|
||||
namespace detail {
|
||||
@@ -113,7 +114,7 @@ concept DerivedUnitExpr = Unit<T> || detail::is_power_of_unit<T> || detail::is_p
|
||||
template<detail::DerivedUnitExpr... Expr>
|
||||
struct derived_unit;
|
||||
|
||||
template<basic_symbol_text Symbol, Magnitude auto M, PrefixableUnit auto U>
|
||||
MP_UNITS_EXPORT template<basic_symbol_text Symbol, Magnitude auto M, PrefixableUnit auto U>
|
||||
requires(!Symbol.empty())
|
||||
struct prefixed_unit;
|
||||
|
||||
@@ -177,7 +178,7 @@ template<Unit U>
|
||||
/**
|
||||
* @brief A concept matching all units that can be used as quantity references
|
||||
*/
|
||||
template<typename U>
|
||||
MP_UNITS_EXPORT template<typename U>
|
||||
concept AssociatedUnit = Unit<U> && detail::has_associated_quantity(U{});
|
||||
|
||||
/**
|
||||
@@ -186,7 +187,7 @@ concept AssociatedUnit = Unit<U> && detail::has_associated_quantity(U{});
|
||||
* Satisfied by all units associated with the quantity_spec being the instantiation derived from
|
||||
* the provided quantity_spec type.
|
||||
*/
|
||||
template<typename U, auto QS>
|
||||
MP_UNITS_EXPORT template<typename U, auto QS>
|
||||
concept UnitOf =
|
||||
AssociatedUnit<U> && QuantitySpec<std::remove_const_t<decltype(QS)>> &&
|
||||
implicitly_convertible(get_quantity_spec(U{}), QS) &&
|
||||
@@ -205,7 +206,7 @@ namespace detail {
|
||||
* Satisfied by all units that have the same canonical reference as `U2` and in case they
|
||||
* have associated quantity specification it should satisfy `UnitOf<QS>`.
|
||||
*/
|
||||
template<typename U, auto U2, auto QS>
|
||||
MP_UNITS_EXPORT template<typename U, auto U2, auto QS>
|
||||
concept UnitCompatibleWith =
|
||||
Unit<U> && Unit<std::remove_const_t<decltype(U2)>> && QuantitySpec<std::remove_const_t<decltype(QS)>> &&
|
||||
(!AssociatedUnit<U> || UnitOf<U, QS>)&&detail::have_same_canonical_reference_unit(U{}, U2);
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_concepts.h>
|
||||
#include <mp-units/bits/quantity_point_concepts.h>
|
||||
#include <mp-units/bits/representation_concepts.h>
|
||||
@@ -29,6 +30,7 @@
|
||||
#include <mp-units/bits/unit_concepts.h>
|
||||
#include <mp-units/reference.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
|
@@ -22,8 +22,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <compare>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <compare>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units {
|
||||
|
||||
template<typename T>
|
||||
|
@@ -23,11 +23,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/external/type_traits.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
/**
|
||||
* @brief Specifies if a value of a type should be treated as a floating-point value
|
||||
*
|
||||
@@ -149,15 +155,6 @@ struct convert_implicitly {
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
concept ConversionSpec = is_specialization_of<T, convert_explicitly> || is_specialization_of<T, convert_implicitly>;
|
||||
|
||||
template<typename T, typename U>
|
||||
concept ConversionSpecOf = ConversionSpec<T> && std::same_as<typename T::value_type, U>;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* @brief Provides support for external quantity-like types
|
||||
@@ -192,4 +189,16 @@ struct quantity_like_traits;
|
||||
template<typename T>
|
||||
struct quantity_point_like_traits;
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
concept ConversionSpec = is_specialization_of<T, convert_explicitly> || is_specialization_of<T, convert_implicitly>;
|
||||
|
||||
template<typename T, typename U>
|
||||
concept ConversionSpecOf = ConversionSpec<T> && std::same_as<typename T::value_type, U>;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace mp_units
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include <mp-units/bits/dimension_concepts.h>
|
||||
#include <mp-units/bits/expression_template.h>
|
||||
#include <mp-units/bits/external/type_traits.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/symbol_text.h>
|
||||
|
||||
namespace mp_units {
|
||||
@@ -57,7 +58,7 @@ namespace mp_units {
|
||||
*
|
||||
* @tparam Symbol an unique identifier of the base dimension used to provide dimensional analysis support
|
||||
*/
|
||||
template<basic_symbol_text Symbol>
|
||||
MP_UNITS_EXPORT template<basic_symbol_text Symbol>
|
||||
struct base_dimension {
|
||||
static constexpr auto symbol = Symbol; ///< Unique base dimension identifier
|
||||
};
|
||||
@@ -124,7 +125,7 @@ struct derived_dimension : detail::expr_fractions<detail::is_dimension_one, Expr
|
||||
* dimensions are zero. It is a dimension of a quantity of dimension one also known as
|
||||
* "dimensionless".
|
||||
*/
|
||||
inline constexpr struct dimension_one : derived_dimension<> {
|
||||
MP_UNITS_EXPORT inline constexpr struct dimension_one : derived_dimension<> {
|
||||
} dimension_one;
|
||||
|
||||
namespace detail {
|
||||
@@ -136,14 +137,14 @@ struct is_dimension_one<struct dimension_one> : std::true_type {};
|
||||
|
||||
// Operators
|
||||
|
||||
template<Dimension Lhs, Dimension Rhs>
|
||||
MP_UNITS_EXPORT template<Dimension Lhs, Dimension Rhs>
|
||||
[[nodiscard]] consteval Dimension auto operator*(Lhs, Rhs)
|
||||
{
|
||||
return detail::expr_multiply<derived_dimension, struct dimension_one, detail::type_list_of_base_dimension_less>(
|
||||
Lhs{}, Rhs{});
|
||||
}
|
||||
|
||||
template<Dimension Lhs, Dimension Rhs>
|
||||
MP_UNITS_EXPORT template<Dimension Lhs, Dimension Rhs>
|
||||
[[nodiscard]] consteval Dimension auto operator/(Lhs, Rhs)
|
||||
{
|
||||
return detail::expr_divide<derived_dimension, struct dimension_one, detail::type_list_of_base_dimension_less>(Lhs{},
|
||||
@@ -163,13 +164,13 @@ template<auto Symbol>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<Dimension Lhs, Dimension Rhs>
|
||||
MP_UNITS_EXPORT template<Dimension Lhs, Dimension Rhs>
|
||||
[[nodiscard]] consteval bool operator==(Lhs lhs, Rhs rhs)
|
||||
{
|
||||
return is_same_v<Lhs, Rhs> || detail::derived_from_the_same_base_dimension(lhs, rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] consteval Dimension auto inverse(Dimension auto d) { return dimension_one / d; }
|
||||
MP_UNITS_EXPORT [[nodiscard]] consteval Dimension auto inverse(Dimension auto d) { return dimension_one / d; }
|
||||
|
||||
/**
|
||||
* @brief Computes the value of a dimension raised to the `Num/Den` power
|
||||
@@ -180,7 +181,7 @@ template<Dimension Lhs, Dimension Rhs>
|
||||
*
|
||||
* @return Dimension The result of computation
|
||||
*/
|
||||
template<std::intmax_t Num, std::intmax_t Den = 1, Dimension D>
|
||||
MP_UNITS_EXPORT template<std::intmax_t Num, std::intmax_t Den = 1, Dimension D>
|
||||
requires detail::non_zero<Den>
|
||||
[[nodiscard]] consteval Dimension auto pow(D d)
|
||||
{
|
||||
@@ -201,7 +202,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Dimension D>
|
||||
*
|
||||
* @return Dimension The result of computation
|
||||
*/
|
||||
[[nodiscard]] consteval Dimension auto sqrt(Dimension auto d) { return pow<1, 2>(d); }
|
||||
MP_UNITS_EXPORT [[nodiscard]] consteval Dimension auto sqrt(Dimension auto d) { return pow<1, 2>(d); }
|
||||
|
||||
/**
|
||||
* @brief Computes the cubic root of a dimension
|
||||
@@ -210,7 +211,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Dimension D>
|
||||
*
|
||||
* @return Dimension The result of computation
|
||||
*/
|
||||
[[nodiscard]] consteval Dimension auto cbrt(Dimension auto d) { return pow<1, 3>(d); }
|
||||
MP_UNITS_EXPORT [[nodiscard]] consteval Dimension auto cbrt(Dimension auto d) { return pow<1, 3>(d); }
|
||||
|
||||
|
||||
// TODO consider adding the support for text output of the dimensional equation
|
||||
|
@@ -28,8 +28,10 @@
|
||||
#include <mp-units/customization_points.h>
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/unit.h>
|
||||
#include <cstdint>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <cstdint>
|
||||
#endif
|
||||
|
||||
namespace mp_units::detail {
|
||||
|
||||
|
@@ -22,20 +22,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/value_cast.h>
|
||||
#include <mp-units/customization_points.h>
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/unit.h>
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
#include <limits>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief Computes the value of a quantity raised to the `Num/Den` power
|
||||
*
|
||||
|
@@ -23,9 +23,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/unit.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
@@ -51,6 +55,8 @@ void to_stream(std::basic_ostream<CharT, Traits>& os, const quantity<R, Rep>& q)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<typename CharT, typename Traits, Unit U>
|
||||
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, U u)
|
||||
{
|
||||
@@ -86,4 +92,6 @@ std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>&
|
||||
return os;
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/dimension_concepts.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_concepts.h>
|
||||
#include <mp-units/bits/quantity_spec_concepts.h>
|
||||
#include <mp-units/bits/reference_concepts.h>
|
||||
@@ -32,8 +33,11 @@
|
||||
#include <mp-units/bits/unit_concepts.h>
|
||||
#include <mp-units/customization_points.h>
|
||||
#include <mp-units/reference.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <compare>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
// the below is not used in this header but should be exposed with it
|
||||
#include <mp-units/bits/quantity_cast.h>
|
||||
@@ -82,6 +86,8 @@ using common_quantity_for = quantity<common_reference(Q1::reference, Q2::referen
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
/**
|
||||
* @brief A quantity
|
||||
*
|
||||
@@ -520,6 +526,8 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
return ct_lhs.numerical_value_ref_in(ct::unit) <=> ct_rhs.numerical_value_ref_in(ct::unit);
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units
|
||||
|
||||
namespace std {
|
||||
|
@@ -22,21 +22,25 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_point_concepts.h>
|
||||
#include <mp-units/compare.h>
|
||||
#include <mp-units/customization_points.h>
|
||||
#include <mp-units/quantity.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <compare>
|
||||
#endif
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
template<typename Derived, QuantitySpec auto QS>
|
||||
MP_UNITS_EXPORT template<typename Derived, QuantitySpec auto QS>
|
||||
struct absolute_point_origin {
|
||||
static constexpr QuantitySpec auto quantity_spec = QS;
|
||||
using _type_ = absolute_point_origin;
|
||||
};
|
||||
|
||||
template<QuantityPoint auto QP>
|
||||
MP_UNITS_EXPORT template<QuantityPoint auto QP>
|
||||
struct relative_point_origin {
|
||||
static constexpr QuantityPoint auto quantity_point = QP;
|
||||
static constexpr QuantitySpec auto quantity_spec = []() {
|
||||
@@ -52,7 +56,7 @@ struct relative_point_origin {
|
||||
template<QuantitySpec auto QS>
|
||||
struct zeroth_point_origin_ : absolute_point_origin<zeroth_point_origin_<QS>, QS> {};
|
||||
|
||||
template<QuantitySpec auto QS>
|
||||
MP_UNITS_EXPORT template<QuantitySpec auto QS>
|
||||
inline constexpr zeroth_point_origin_<QS> zeroth_point_origin;
|
||||
|
||||
namespace detail {
|
||||
@@ -71,7 +75,7 @@ template<PointOrigin PO>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<PointOrigin PO1, PointOrigin PO2>
|
||||
MP_UNITS_EXPORT template<PointOrigin PO1, PointOrigin PO2>
|
||||
[[nodiscard]] consteval bool operator==(PO1 po1, PO2 po2)
|
||||
{
|
||||
if constexpr (detail::AbsolutePointOrigin<PO1> && detail::AbsolutePointOrigin<PO2>)
|
||||
@@ -86,7 +90,7 @@ template<PointOrigin PO1, PointOrigin PO2>
|
||||
return detail::same_absolute_point_origins(po1, po2) && is_eq_zero(PO2::quantity_point.quantity_from_zero());
|
||||
}
|
||||
|
||||
template<Reference R>
|
||||
MP_UNITS_EXPORT template<Reference R>
|
||||
[[nodiscard]] consteval PointOriginFor<get_quantity_spec(R{})> auto default_point_origin(R)
|
||||
{
|
||||
if constexpr (requires { get_unit(R{}).point_origin; })
|
||||
@@ -108,6 +112,8 @@ template<PointOrigin PO>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
/**
|
||||
* @brief A quantity point
|
||||
*
|
||||
@@ -507,4 +513,6 @@ template<QuantityPoint QP1, QuantityPointOf<QP1::absolute_point_origin> QP2>
|
||||
return lhs - lhs.absolute_point_origin == rhs - rhs.absolute_point_origin;
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units
|
||||
|
@@ -27,19 +27,22 @@
|
||||
#include <mp-units/bits/external/type_name.h>
|
||||
#include <mp-units/bits/external/type_traits.h>
|
||||
#include <mp-units/bits/get_common_base.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_concepts.h>
|
||||
#include <mp-units/bits/quantity_spec_concepts.h>
|
||||
#include <mp-units/bits/reference_concepts.h>
|
||||
#include <mp-units/bits/representation_concepts.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <mp-units/dimension.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <tuple>
|
||||
#endif
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
||||
template<QuantitySpec QS, Unit U>
|
||||
requires(!AssociatedUnit<U>) || UnitOf<U, QS{}>
|
||||
[[nodiscard]] consteval Reference auto make_reference(QS, U u)
|
||||
@@ -143,6 +146,8 @@ struct quantity_spec_interface {
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
/**
|
||||
* @brief Quantity Specification
|
||||
*
|
||||
@@ -171,6 +176,8 @@ struct quantity_spec;
|
||||
inline constexpr struct is_kind {
|
||||
} is_kind;
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
/**
|
||||
* @brief Specialization defining a base quantity
|
||||
*
|
||||
@@ -432,7 +439,7 @@ struct derived_quantity_spec :
|
||||
* Quantity of dimension one also commonly named as "dimensionless" is a quantity with a dimension
|
||||
* for which all the exponents of the factors corresponding to the base dimensions are zero.
|
||||
*/
|
||||
QUANTITY_SPEC(dimensionless, derived_quantity_spec<>{});
|
||||
MP_UNITS_EXPORT QUANTITY_SPEC(dimensionless, derived_quantity_spec<>{});
|
||||
|
||||
/**
|
||||
* @brief Quantity kind specifier
|
||||
@@ -469,7 +476,7 @@ struct kind_of_<Q> : quantity_spec<kind_of_<Q>, Q{}> {
|
||||
};
|
||||
#endif
|
||||
|
||||
template<detail::QuantitySpecWithNoSpecifiers auto Q>
|
||||
MP_UNITS_EXPORT template<detail::QuantitySpecWithNoSpecifiers auto Q>
|
||||
requires(detail::get_kind_tree_root(Q) == Q)
|
||||
inline constexpr kind_of_<std::remove_const_t<decltype(Q)>> kind_of;
|
||||
|
||||
@@ -498,6 +505,8 @@ template<QuantitySpec Q>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
// Operators
|
||||
|
||||
template<QuantitySpec Lhs, QuantitySpec Rhs>
|
||||
@@ -579,6 +588,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, QuantitySpec Q>
|
||||
*/
|
||||
[[nodiscard]] consteval QuantitySpec auto cbrt(QuantitySpec auto q) { return pow<1, 3>(q); }
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -1386,6 +1396,8 @@ template<QuantitySpec From, QuantitySpec To>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<QuantitySpec From, QuantitySpec To>
|
||||
[[nodiscard]] consteval bool implicitly_convertible(From from, To to)
|
||||
{
|
||||
@@ -1410,6 +1422,8 @@ template<QuantitySpec QS1, QuantitySpec QS2>
|
||||
return implicitly_convertible(qs1, qs2) && implicitly_convertible(qs2, qs1);
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<QuantitySpec Q>
|
||||
@@ -1454,6 +1468,8 @@ template<QuantitySpec Q>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<QuantitySpec Q>
|
||||
[[nodiscard]] consteval detail::QuantityKindSpec auto get_kind(Q q)
|
||||
{
|
||||
@@ -1502,4 +1518,6 @@ template<QuantitySpec Q1, QuantitySpec Q2>
|
||||
return common_quantity_spec(common_quantity_spec(q1, q2), q3, rest...);
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units
|
||||
|
@@ -22,9 +22,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/quantity.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <functional>
|
||||
#include <random>
|
||||
#endif
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
@@ -82,6 +86,8 @@ std::vector<typename Q::rep> fw_bl_pwl(std::initializer_list<Q>& bl, UnaryOperat
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<Quantity Q>
|
||||
requires std::integral<typename Q::rep>
|
||||
struct uniform_int_distribution : public std::uniform_int_distribution<typename Q::rep> {
|
||||
@@ -571,4 +577,6 @@ public:
|
||||
Q max() const { return base::max() * Q::reference; }
|
||||
};
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/get_associated_quantity.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_concepts.h>
|
||||
#include <mp-units/bits/reference_concepts.h>
|
||||
#include <mp-units/bits/representation_concepts.h>
|
||||
@@ -36,6 +37,8 @@ using reference_t = reference<std::remove_const_t<decltype(Q)>, std::remove_cons
|
||||
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
[[nodiscard]] consteval QuantitySpec auto get_quantity_spec(AssociatedUnit auto u)
|
||||
{
|
||||
return detail::get_associated_quantity(u);
|
||||
@@ -241,6 +244,8 @@ template<Reference R1, Reference R2, Reference... Rest>
|
||||
common_unit(get_unit(r1), get_unit(r2), get_unit(rest)...)>{};
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<AssociatedUnit auto To, AssociatedUnit From>
|
||||
|
@@ -23,10 +23,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/external/hacks.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#include <mp-units/reference.h>
|
||||
#include <mp-units/unit.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
|
@@ -29,14 +29,18 @@
|
||||
#include <mp-units/bits/external/type_traits.h>
|
||||
#include <mp-units/bits/get_associated_quantity.h>
|
||||
#include <mp-units/bits/magnitude.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/bits/quantity_point_concepts.h>
|
||||
#include <mp-units/bits/quantity_spec_concepts.h>
|
||||
#include <mp-units/bits/ratio.h>
|
||||
#include <mp-units/bits/symbol_text.h>
|
||||
#include <mp-units/bits/text_tools.h>
|
||||
#include <mp-units/bits/unit_concepts.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
@@ -103,7 +107,7 @@ inline constexpr bool is_specialization_of_scaled_unit<scaled_unit<M, U>> = true
|
||||
*
|
||||
* @tparam Symbol a short text representation of the unit
|
||||
*/
|
||||
template<basic_symbol_text Symbol, auto...>
|
||||
MP_UNITS_EXPORT template<basic_symbol_text Symbol, auto...>
|
||||
struct named_unit;
|
||||
|
||||
/**
|
||||
@@ -220,7 +224,7 @@ struct named_unit<Symbol, U, QS, PO> : std::remove_const_t<decltype(U)> {
|
||||
* @tparam M scaling factor of the prefix
|
||||
* @tparam U a named unit to be prefixed
|
||||
*/
|
||||
template<basic_symbol_text Symbol, Magnitude auto M, PrefixableUnit auto U>
|
||||
MP_UNITS_EXPORT template<basic_symbol_text Symbol, Magnitude auto M, PrefixableUnit auto U>
|
||||
requires(!Symbol.empty())
|
||||
struct prefixed_unit : std::remove_const_t<decltype(M * U)> {
|
||||
static constexpr auto symbol = Symbol + U.symbol;
|
||||
@@ -287,7 +291,7 @@ struct derived_unit : detail::expr_fractions<detail::is_one, Expr...> {};
|
||||
* Unit of a dimensionless quantity.
|
||||
*/
|
||||
// clang-format off
|
||||
inline constexpr struct one : derived_unit<> {} one;
|
||||
MP_UNITS_EXPORT inline constexpr struct one : derived_unit<> {} one;
|
||||
// clang-format on
|
||||
|
||||
namespace detail {
|
||||
@@ -477,6 +481,7 @@ template<Unit Lhs, Unit Rhs>
|
||||
|
||||
[[nodiscard]] MP_UNITS_CONSTEVAL Unit auto inverse(Unit auto u) { return one / u; }
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -522,7 +527,7 @@ template<typename... Expr1, typename... Expr2>
|
||||
} // namespace detail
|
||||
|
||||
|
||||
[[nodiscard]] consteval bool operator==(Unit auto lhs, Unit auto rhs)
|
||||
MP_UNITS_EXPORT [[nodiscard]] consteval bool operator==(Unit auto lhs, Unit auto rhs)
|
||||
{
|
||||
auto canonical_lhs = get_canonical_unit(lhs);
|
||||
auto canonical_rhs = get_canonical_unit(rhs);
|
||||
@@ -540,6 +545,8 @@ inline constexpr bool is_specialization_of_derived_unit<derived_unit<Expr...>> =
|
||||
|
||||
} // namespace detail
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
/**
|
||||
* @brief Computes the value of a unit raised to the `Num/Den` power
|
||||
*
|
||||
@@ -700,6 +707,8 @@ struct unit_symbol_formatting {
|
||||
unit_symbol_separator separator = unit_symbol_separator::default_separator;
|
||||
};
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename CharT, std::size_t N, std::size_t M, std::output_iterator<CharT> Out>
|
||||
@@ -840,7 +849,7 @@ constexpr Out unit_symbol_impl(Out out, const derived_unit<Expr...>&, unit_symbo
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<typename CharT = char, std::output_iterator<CharT> Out, Unit U>
|
||||
MP_UNITS_EXPORT template<typename CharT = char, std::output_iterator<CharT> Out, Unit U>
|
||||
constexpr Out unit_symbol_to(Out out, U u, unit_symbol_formatting fmt = unit_symbol_formatting{})
|
||||
{
|
||||
return detail::unit_symbol_impl<CharT>(out, u, fmt, false);
|
||||
@@ -860,7 +869,7 @@ template<typename CharT, std::size_t N, unit_symbol_formatting fmt, Unit U>
|
||||
|
||||
|
||||
// TODO Refactor to `unit_symbol(U, fmt)` when P1045: constexpr Function Parameters is available
|
||||
template<unit_symbol_formatting fmt = unit_symbol_formatting{}, typename CharT = char, Unit U>
|
||||
MP_UNITS_EXPORT template<unit_symbol_formatting fmt = unit_symbol_formatting{}, typename CharT = char, Unit U>
|
||||
[[nodiscard]] consteval auto unit_symbol(U)
|
||||
{
|
||||
auto get_size = []() consteval {
|
||||
|
@@ -4,7 +4,6 @@ module;
|
||||
|
||||
export module mp_units.core;
|
||||
|
||||
export
|
||||
{
|
||||
#define MP_UNITS_IN_MODULE_INTERFACE
|
||||
|
||||
#include <mp-units/core.h>
|
||||
}
|
||||
|
@@ -22,18 +22,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/angular/units.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/bits/value_cast.h>
|
||||
#include <mp-units/customization_points.h>
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/systems/angular/units.h>
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <cmath>
|
||||
// IWYU pragma: end_exports
|
||||
#endif
|
||||
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::angular {
|
||||
|
||||
template<ReferenceOf<angle> auto R, typename Rep>
|
||||
|
@@ -22,12 +22,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/dimension.h>
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::angular {
|
||||
|
||||
// clang-format off
|
||||
|
@@ -22,11 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::cgs {
|
||||
|
||||
// clang-format off
|
||||
|
@@ -22,15 +22,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/si/si.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/systems/si/si.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units {
|
||||
|
||||
template<>
|
||||
inline constexpr std::optional<std::intmax_t> mp_units::known_first_factor<334'524'384'739> = 334'524'384'739;
|
||||
inline constexpr std::optional<std::intmax_t> known_first_factor<334'524'384'739> = 334'524'384'739;
|
||||
|
||||
namespace mp_units::hep {
|
||||
namespace hep {
|
||||
|
||||
// energy
|
||||
using si::electronvolt;
|
||||
@@ -101,5 +106,5 @@ inline constexpr auto c = speed_of_light;
|
||||
inline constexpr auto c2 = square(speed_of_light);
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
} // namespace mp_units::hep
|
||||
} // namespace hep
|
||||
} // namespace mp_units
|
||||
|
@@ -22,12 +22,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/si/constants.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::iau {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Astronomical_system_of_units
|
||||
|
@@ -22,6 +22,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
@@ -38,6 +40,8 @@ template<PrefixableUnit U> struct exbi_ : prefixed_unit<"Ei", mag_power<2, 60>,
|
||||
template<PrefixableUnit U> struct zebi_ : prefixed_unit<"Zi", mag_power<2, 70>, U{}> {};
|
||||
template<PrefixableUnit U> struct yobi_ : prefixed_unit<"Yi", mag_power<2, 80>, U{}> {};
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<PrefixableUnit auto U> inline constexpr kibi_<std::remove_const_t<decltype(U)>> kibi;
|
||||
template<PrefixableUnit auto U> inline constexpr mebi_<std::remove_const_t<decltype(U)>> mebi;
|
||||
template<PrefixableUnit auto U> inline constexpr gibi_<std::remove_const_t<decltype(U)>> gibi;
|
||||
@@ -48,4 +52,6 @@ template<PrefixableUnit auto U> inline constexpr zebi_<std::remove_const_t<declt
|
||||
template<PrefixableUnit auto U> inline constexpr yobi_<std::remove_const_t<decltype(U)>> yobi;
|
||||
// clang-format on
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units::iec80000
|
||||
|
@@ -22,13 +22,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/dimension.h>
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::iec80000 {
|
||||
|
||||
// dimensions of base quantities
|
||||
|
@@ -22,10 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/iec80000/binary_prefixes.h>
|
||||
#include <mp-units/systems/iec80000/units.h>
|
||||
#include <mp-units/systems/si/prefixes.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::iec80000::unit_symbols {
|
||||
|
||||
// bit
|
||||
|
@@ -22,12 +22,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/iec80000/quantities.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::iec80000 {
|
||||
|
||||
// clang-format off
|
||||
|
@@ -22,11 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/international/international.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/systems/international/international.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::imperial {
|
||||
|
||||
using namespace international;
|
||||
|
@@ -22,12 +22,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/si/constants.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::international {
|
||||
|
||||
// clang-format off
|
||||
|
@@ -22,11 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/si_quantities.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
#include <mp-units/systems/isq/si_quantities.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::isq {
|
||||
|
||||
|
||||
|
@@ -22,12 +22,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/dimension.h>
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::isq {
|
||||
|
||||
// clang-format off
|
||||
|
@@ -22,13 +22,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/base_quantities.h>
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(electric_charge, electric_current* time);
|
||||
|
@@ -22,12 +22,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/si_quantities.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(mass_density, mass / volume);
|
||||
|
@@ -22,11 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/base_quantities.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
#include <mp-units/systems/isq/base_quantities.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::isq {
|
||||
|
||||
// space and time
|
||||
|
@@ -22,11 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/si_quantities.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
#include <mp-units/systems/isq/si_quantities.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(height, length);
|
||||
|
@@ -22,13 +22,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/si_quantities.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(Celsius_temperature, thermodynamic_temperature); // TODO should we account for T0 here?
|
||||
|
@@ -22,13 +22,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/angular/angular.h>
|
||||
#include <mp-units/systems/isq/isq.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#include <mp-units/reference.h>
|
||||
#endif
|
||||
#include <mp-units/systems/angular/angular.h>
|
||||
#include <mp-units/systems/isq/isq.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::isq_angle {
|
||||
|
||||
using namespace isq;
|
||||
|
@@ -22,14 +22,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/system_reference.h>
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/prefixes.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/system_reference.h>
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::natural {
|
||||
|
||||
// clang-format off
|
||||
|
@@ -22,14 +22,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/prefixes.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/customization_points.h>
|
||||
#include <mp-units/quantity_point.h>
|
||||
#include <chrono>
|
||||
#endif
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/prefixes.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
@@ -62,7 +64,7 @@ template<typename Period>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<typename Rep, typename Period>
|
||||
MP_UNITS_EXPORT template<typename Rep, typename Period>
|
||||
struct quantity_like_traits<std::chrono::duration<Rep, Period>> {
|
||||
static constexpr auto reference = detail::time_unit_from_chrono_period<Period>();
|
||||
using rep = Rep;
|
||||
@@ -84,9 +86,10 @@ template<typename C>
|
||||
struct chrono_point_origin_ : absolute_point_origin<chrono_point_origin_<C>, isq::time> {
|
||||
using clock = C;
|
||||
};
|
||||
template<typename C>
|
||||
MP_UNITS_EXPORT template<typename C>
|
||||
inline constexpr chrono_point_origin_<C> chrono_point_origin;
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<typename C, typename Rep, typename Period>
|
||||
struct quantity_point_like_traits<std::chrono::time_point<C, std::chrono::duration<Rep, Period>>> {
|
||||
@@ -111,7 +114,7 @@ struct quantity_point_like_traits<std::chrono::time_point<C, std::chrono::durati
|
||||
template<QuantityOf<isq::time> Q>
|
||||
[[nodiscard]] constexpr auto to_chrono_duration(const Q& q)
|
||||
{
|
||||
constexpr auto canonical = detail::get_canonical_unit(Q::unit);
|
||||
constexpr auto canonical = get_canonical_unit(Q::unit);
|
||||
constexpr ratio r = as_ratio(canonical.mag);
|
||||
return std::chrono::duration<typename Q::rep, std::ratio<r.num, r.den>>{q};
|
||||
}
|
||||
@@ -122,10 +125,12 @@ template<QuantityPointOf<isq::time> QP>
|
||||
{
|
||||
using clock = MP_UNITS_TYPENAME decltype(QP::absolute_point_origin)::clock;
|
||||
using rep = MP_UNITS_TYPENAME QP::rep;
|
||||
constexpr auto canonical = detail::get_canonical_unit(QP::unit);
|
||||
constexpr auto canonical = get_canonical_unit(QP::unit);
|
||||
constexpr ratio r = as_ratio(canonical.mag);
|
||||
using ret_type = std::chrono::time_point<clock, std::chrono::duration<rep, std::ratio<r.num, r.den>>>;
|
||||
return ret_type(to_chrono_duration(qp - qp.absolute_point_origin));
|
||||
}
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units
|
||||
|
@@ -22,11 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity.h>
|
||||
#endif
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::si {
|
||||
|
||||
namespace si2019 {
|
||||
|
@@ -22,21 +22,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/bits/value_cast.h>
|
||||
#include <mp-units/customization_points.h>
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <cmath>
|
||||
// IWYU pragma: end_exports
|
||||
#endif
|
||||
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::si {
|
||||
|
||||
template<ReferenceOf<isq::angular_measure> auto R, typename Rep>
|
||||
requires requires(Rep v) { sin(v); } || requires(Rep v) { std::sin(v); }
|
||||
[[nodiscard]] inline QuantityOf<dimensionless> auto sin(const quantity<R, Rep>& q) noexcept
|
||||
|
@@ -22,6 +22,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
@@ -54,6 +56,8 @@ template<PrefixableUnit U> struct yotta_ : prefixed_unit<"Y", mag_power<10, 24>,
|
||||
template<PrefixableUnit U> struct ronna_ : prefixed_unit<"R", mag_power<10, 27>, U{}> {};
|
||||
template<PrefixableUnit U> struct quetta_ : prefixed_unit<"Q", mag_power<10, 30>, U{}> {};
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
template<PrefixableUnit auto U> inline constexpr quecto_<std::remove_const_t<decltype(U)>> quecto;
|
||||
template<PrefixableUnit auto U> inline constexpr ronto_<std::remove_const_t<decltype(U)>> ronto;
|
||||
template<PrefixableUnit auto U> inline constexpr yocto_<std::remove_const_t<decltype(U)>> yocto;
|
||||
@@ -80,4 +84,6 @@ template<PrefixableUnit auto U> inline constexpr ronna_<std::remove_const_t<decl
|
||||
template<PrefixableUnit auto U> inline constexpr quetta_<std::remove_const_t<decltype(U)>> quetta;
|
||||
// clang-format on
|
||||
|
||||
MP_UNITS_EXPORT_END
|
||||
|
||||
} // namespace mp_units::si
|
||||
|
@@ -22,9 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/si/prefixes.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units {
|
||||
|
||||
namespace si::unit_symbols {
|
||||
|
@@ -22,14 +22,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/isq/si_quantities.h>
|
||||
#include <mp-units/systems/si/prefixes.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/quantity_point.h>
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
// #include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/si_quantities.h>
|
||||
#include <mp-units/systems/si/prefixes.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units {
|
||||
|
||||
namespace si {
|
||||
@@ -58,20 +60,17 @@ inline constexpr struct radian : named_unit<"rad", metre / metre, kind_of<isq::a
|
||||
inline constexpr struct steradian : named_unit<"sr", square(metre) / square(metre), kind_of<isq::solid_angular_measure>> {} steradian;
|
||||
inline constexpr struct hertz : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz;
|
||||
inline constexpr struct newton : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
// inline constexpr struct newton : named_unit<"N", kilogram * metre / square(second), kind_of<isq::force>> {} newton;
|
||||
#ifdef pascal
|
||||
#pragma push_macro("pascal")
|
||||
#undef pascal
|
||||
#define MP_UNITS_REDEFINE_PASCAL
|
||||
#endif
|
||||
inline constexpr struct pascal : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
// inline constexpr struct pascal : named_unit<"Pa", newton / square(metre), kind_of<isq::pressure>> {} pascal;
|
||||
#ifdef MP_UNITS_REDEFINE_PASCAL
|
||||
#pragma pop_macro("pascal")
|
||||
#undef MP_UNITS_REDEFINE_PASCAL
|
||||
#endif
|
||||
inline constexpr struct joule : named_unit<"J", newton * metre> {} joule;
|
||||
// inline constexpr struct joule : named_unit<"J", newton * metre, kind_of<isq::energy>> {} joule;
|
||||
inline constexpr struct watt : named_unit<"W", joule / second> {} watt;
|
||||
inline constexpr struct coulomb : named_unit<"C", ampere * second> {} coulomb;
|
||||
inline constexpr struct volt : named_unit<"V", watt / ampere> {} volt;
|
||||
|
@@ -22,11 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/international/international.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/systems/international/international.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::typographic {
|
||||
|
||||
// clang-format off
|
||||
|
@@ -22,11 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/systems/international/international.h>
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
#include <mp-units/systems/international/international.h>
|
||||
|
||||
MP_UNITS_EXPORT
|
||||
namespace mp_units::usc {
|
||||
|
||||
using namespace international;
|
||||
|
@@ -7,8 +7,6 @@ export module mp_units.systems;
|
||||
|
||||
export import mp_units.core;
|
||||
|
||||
export
|
||||
{
|
||||
#define MP_UNITS_IN_MODULE_INTERFACE
|
||||
|
||||
#include <mp-units/systems/angular/angular.h>
|
||||
@@ -24,4 +22,3 @@ export
|
||||
#include <mp-units/systems/si/si.h>
|
||||
#include <mp-units/systems/typographic/typographic.h>
|
||||
#include <mp-units/systems/usc/usc.h>
|
||||
}
|
||||
|
@@ -23,9 +23,6 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
add_library(unit_tests_static_truncating quantity_test.cpp)
|
||||
if(${projectPrefix}BUILD_CXX_MODULES)
|
||||
target_compile_definitions(unit_tests_static_truncating PUBLIC ${projectPrefix}MODULES)
|
||||
endif()
|
||||
target_link_libraries(unit_tests_static_truncating PRIVATE mp-units::mp-units)
|
||||
target_compile_options(
|
||||
unit_tests_static_truncating PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/wd4242 /wd4244,-Wno-conversion>
|
||||
@@ -68,7 +65,4 @@ add_library(
|
||||
)
|
||||
|
||||
target_link_libraries(unit_tests_static PRIVATE mp-units::mp-units)
|
||||
if(${projectPrefix}BUILD_CXX_MODULES)
|
||||
target_compile_definitions(unit_tests_static PUBLIC ${projectPrefix}MODULES)
|
||||
endif()
|
||||
target_link_libraries(unit_tests_static PRIVATE unit_tests_static_truncating)
|
||||
|
@@ -20,12 +20,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <numbers>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/systems/isq_angle/isq_angle.h>
|
||||
#endif
|
||||
#include <numbers>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -21,14 +21,10 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "test_tools.h"
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/systems/cgs/cgs.h>
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/unit_symbols.h>
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
requires mp_units::is_scalar<T>
|
||||
|
@@ -21,15 +21,10 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "test_tools.h"
|
||||
#include <ratio>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
#include <chrono>
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/bits/external/type_traits.h>
|
||||
#include <mp-units/quantity_point.h>
|
||||
#include <mp-units/systems/si/si.h>
|
||||
#endif
|
||||
#include <ratio>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,12 +20,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/compare.h>
|
||||
#include <mp-units/systems/si/si.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,19 +20,15 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <chrono>
|
||||
#include <complex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/concepts.h>
|
||||
#include <mp-units/quantity_point.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/natural/natural.h>
|
||||
#include <mp-units/systems/si/si.h>
|
||||
#endif
|
||||
#include <chrono>
|
||||
#include <complex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
template<typename T>
|
||||
inline constexpr bool mp_units::is_scalar<std::complex<T>> = true;
|
||||
|
@@ -21,13 +21,9 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include <mp-units/bits/external/hacks.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
#include <concepts>
|
||||
#include <type_traits>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/systems/si/units.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -21,15 +21,11 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "test_tools.h"
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/dimension.h>
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#include <mp-units/reference.h>
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,11 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/bits/external/fixed_string.h>
|
||||
#endif
|
||||
|
||||
using namespace mp_units;
|
||||
|
||||
|
@@ -21,13 +21,9 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include <mp-units/compat_macros.h>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/math.h>
|
||||
#include <mp-units/systems/isq/electromagnetism.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,14 +20,10 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/systems/hep/hep.h>
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/si.h>
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
requires mp_units::is_scalar<T>
|
||||
|
@@ -20,14 +20,10 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/math.h>
|
||||
#include <mp-units/systems/iau/iau.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/si.h>
|
||||
#endif
|
||||
|
||||
/* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */
|
||||
|
||||
|
@@ -20,14 +20,10 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/reference.h>
|
||||
#include <mp-units/systems/iec80000/iec80000.h>
|
||||
#include <mp-units/systems/si/unit_symbols.h>
|
||||
#endif
|
||||
|
||||
/* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */
|
||||
|
||||
|
@@ -20,13 +20,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/systems/imperial/imperial.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/unit_symbols.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,16 +20,12 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/math.h>
|
||||
#include <mp-units/systems/international/international.h>
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/constants.h>
|
||||
#include <mp-units/systems/si/units.h>
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
requires mp_units::is_scalar<T>
|
||||
|
@@ -20,12 +20,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/systems/isq_angle/isq_angle.h>
|
||||
#include <mp-units/systems/si/unit_symbols.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,13 +20,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/reference.h>
|
||||
#include <mp-units/systems/isq/isq.h>
|
||||
#include <mp-units/systems/si/unit_symbols.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -21,14 +21,10 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include <optional>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/math.h> // IWYU pragma: keep
|
||||
#include <mp-units/systems/international/international.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/unit_symbols.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,12 +20,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/math.h>
|
||||
#include <mp-units/systems/natural/natural.h>
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
requires mp_units::is_scalar<T>
|
||||
|
@@ -20,13 +20,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <mp-units/bits/external/prime.h>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/bits/external/prime.h>
|
||||
#endif
|
||||
|
||||
using namespace mp_units::detail;
|
||||
|
||||
|
@@ -24,15 +24,10 @@
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
#include <chrono>
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/quantity_point.h>
|
||||
#include <mp-units/systems/isq/isq.h>
|
||||
#include <mp-units/systems/si/si.h>
|
||||
#include <mp-units/systems/usc/usc.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -21,14 +21,10 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "test_tools.h"
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#include <mp-units/reference.h>
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,19 +20,13 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <mp-units/bits/external/hacks.h>
|
||||
//
|
||||
#include "test_tools.h"
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
#include <chrono>
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/bits/external/hacks.h>
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/si.h>
|
||||
#endif
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
template<>
|
||||
inline constexpr bool mp_units::is_vector<int> = true;
|
||||
|
@@ -20,11 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/bits/ratio.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -21,9 +21,6 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "test_tools.h"
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/dimension.h>
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/quantity_spec.h>
|
||||
@@ -31,7 +28,6 @@ import mp_units;
|
||||
#include <mp-units/system_reference.h>
|
||||
#include <mp-units/systems/si/prefixes.h>
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -21,12 +21,8 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include <type_traits>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/math.h>
|
||||
#include <mp-units/systems/si/si.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,11 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/bits/symbol_text.h>
|
||||
#endif
|
||||
|
||||
using namespace mp_units;
|
||||
|
||||
|
@@ -23,12 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
#include <mp-units/compat_macros.h>
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/quantity_spec.h>
|
||||
#endif
|
||||
|
||||
template<auto V, typename T>
|
||||
inline constexpr bool is_of_type = std::is_same_v<std::remove_cvref_t<decltype(V)>, T>;
|
||||
|
@@ -20,13 +20,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <type_traits>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/bits/external/type_list.h>
|
||||
#include <mp-units/bits/external/type_traits.h>
|
||||
#endif
|
||||
#include <type_traits>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,13 +20,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/systems/international/international.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/typographic/typographic.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -20,13 +20,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/systems/iau/iau.h>
|
||||
#include <mp-units/systems/iec80000/iec80000.h>
|
||||
#include <mp-units/systems/si/si.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -21,15 +21,11 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "test_tools.h"
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/dimension.h>
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/reference.h>
|
||||
#include <mp-units/systems/si/prefixes.h>
|
||||
#include <mp-units/unit.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -21,14 +21,10 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include <mp-units/bits/external/hacks.h>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
#else
|
||||
#include <mp-units/systems/isq/mechanics.h>
|
||||
#include <mp-units/systems/isq/space_and_time.h>
|
||||
#include <mp-units/systems/si/unit_symbols.h>
|
||||
#include <mp-units/systems/usc/usc.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
Reference in New Issue
Block a user