From 5ca91683813fa7052352c4858d5709bc0380b9a1 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 23 Feb 2024 21:09:17 +0100 Subject: [PATCH] feat: proper exports implemented for C++ modules --- src/core/CMakeLists.txt | 1 + .../mp-units/bits/dimension_concepts.h | 7 ++-- .../mp-units/bits/external/algorithm.h | 3 ++ .../mp-units/bits/external/fixed_string.h | 10 ++--- .../include/mp-units/bits/external/hacks.h | 2 + .../mp-units/bits/external/math_concepts.h | 2 + .../include/mp-units/bits/external/prime.h | 3 ++ .../mp-units/bits/external/type_list.h | 3 ++ .../mp-units/bits/external/type_name.h | 2 + .../mp-units/bits/external/type_traits.h | 8 ++++ src/core/include/mp-units/bits/fmt.h | 5 ++- src/core/include/mp-units/bits/magnitude.h | 19 +++++++-- .../include/mp-units/bits/module_macros.h | 40 +++++++++++++++++++ .../include/mp-units/bits/quantity_cast.h | 7 +++- .../include/mp-units/bits/quantity_concepts.h | 7 +++- .../mp-units/bits/quantity_point_concepts.h | 19 ++++----- .../mp-units/bits/quantity_spec_concepts.h | 8 ++-- src/core/include/mp-units/bits/ratio.h | 6 ++- .../mp-units/bits/reference_concepts.h | 7 +++- .../mp-units/bits/representation_concepts.h | 10 +++-- src/core/include/mp-units/bits/symbol_text.h | 12 ++++-- .../include/mp-units/bits/unit_concepts.h | 17 ++++---- src/core/include/mp-units/bits/value_cast.h | 2 + src/core/include/mp-units/compare.h | 7 +++- .../include/mp-units/customization_points.h | 27 ++++++++----- src/core/include/mp-units/dimension.h | 19 ++++----- src/core/include/mp-units/format.h | 4 +- src/core/include/mp-units/math.h | 8 ++-- src/core/include/mp-units/ostream.h | 8 ++++ src/core/include/mp-units/quantity.h | 8 ++++ src/core/include/mp-units/quantity_point.h | 18 ++++++--- src/core/include/mp-units/quantity_spec.h | 24 +++++++++-- src/core/include/mp-units/random.h | 8 ++++ src/core/include/mp-units/reference.h | 5 +++ src/core/include/mp-units/system_reference.h | 2 + src/core/include/mp-units/unit.h | 23 +++++++---- src/core/mp-units-core.cpp | 5 +-- .../include/mp-units/systems/angular/math.h | 11 ++--- .../include/mp-units/systems/angular/units.h | 3 ++ .../include/mp-units/systems/cgs/cgs.h | 5 ++- .../include/mp-units/systems/hep/hep.h | 15 ++++--- .../include/mp-units/systems/iau/iau.h | 9 +++-- .../systems/iec80000/binary_prefixes.h | 6 +++ .../mp-units/systems/iec80000/quantities.h | 7 +++- .../mp-units/systems/iec80000/unit_symbols.h | 2 + .../include/mp-units/systems/iec80000/units.h | 9 +++-- .../mp-units/systems/imperial/imperial.h | 5 ++- .../systems/international/international.h | 9 +++-- .../systems/isq/atomic_and_nuclear_physics.h | 5 ++- .../mp-units/systems/isq/base_quantities.h | 3 ++ .../mp-units/systems/isq/electromagnetism.h | 9 +++-- .../include/mp-units/systems/isq/mechanics.h | 9 +++-- .../mp-units/systems/isq/si_quantities.h | 5 ++- .../mp-units/systems/isq/space_and_time.h | 5 ++- .../mp-units/systems/isq/thermodynamics.h | 9 +++-- .../mp-units/systems/isq_angle/isq_angle.h | 7 +++- .../mp-units/systems/natural/natural.h | 11 +++-- .../include/mp-units/systems/si/chrono.h | 19 +++++---- .../include/mp-units/systems/si/constants.h | 5 ++- .../include/mp-units/systems/si/math.h | 14 +++---- .../include/mp-units/systems/si/prefixes.h | 6 +++ .../mp-units/systems/si/unit_symbols.h | 2 + .../include/mp-units/systems/si/units.h | 11 +++-- .../systems/typographic/typographic.h | 5 ++- .../include/mp-units/systems/usc/usc.h | 5 ++- src/systems/mp-units-systems.cpp | 3 -- test/static/CMakeLists.txt | 6 --- test/static/angular_test.cpp | 6 +-- test/static/cgs_test.cpp | 4 -- test/static/chrono_test.cpp | 7 +--- test/static/compare_test.cpp | 4 -- test/static/concepts_test.cpp | 12 ++---- test/static/custom_rep_test_min_impl.cpp | 6 +-- test/static/dimension_test.cpp | 4 -- test/static/fixed_string_test.cpp | 4 -- test/static/fractional_exponent_quantity.cpp | 4 -- test/static/hep_test.cpp | 4 -- test/static/iau_test.cpp | 4 -- test/static/iec80000_test.cpp | 4 -- test/static/imperial_test.cpp | 4 -- test/static/international_test.cpp | 4 -- test/static/isq_angle_test.cpp | 4 -- test/static/isq_test.cpp | 4 -- test/static/math_test.cpp | 4 -- test/static/natural_test.cpp | 4 -- test/static/prime_test.cpp | 6 +-- test/static/quantity_point_test.cpp | 5 --- test/static/quantity_spec_test.cpp | 4 -- test/static/quantity_test.cpp | 12 ++---- test/static/ratio_test.cpp | 4 -- test/static/reference_test.cpp | 4 -- test/static/si_test.cpp | 4 -- test/static/symbol_text_test.cpp | 4 -- test/static/test_tools.h | 5 --- test/static/type_list_test.cpp | 6 +-- test/static/typographic_test.cpp | 4 -- test/static/unit_symbol_test.cpp | 4 -- test/static/unit_test.cpp | 4 -- test/static/usc_test.cpp | 4 -- 99 files changed, 439 insertions(+), 304 deletions(-) create mode 100644 src/core/include/mp-units/bits/module_macros.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b2f966d0..0be0f696 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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 diff --git a/src/core/include/mp-units/bits/dimension_concepts.h b/src/core/include/mp-units/bits/dimension_concepts.h index 770c0f7b..56e64d1b 100644 --- a/src/core/include/mp-units/bits/dimension_concepts.h +++ b/src/core/include/mp-units/bits/dimension_concepts.h @@ -24,11 +24,12 @@ #include #include +#include #include namespace mp_units { -template +MP_UNITS_EXPORT template struct base_dimension; namespace detail { @@ -98,7 +99,7 @@ concept DerivedDimension = is_specialization_of || is_dime * * Satisfied by all dimension types for which either `BaseDimension` or `DerivedDimension` is `true`. */ -template +MP_UNITS_EXPORT template concept Dimension = detail::BaseDimension || detail::DerivedDimension; /** @@ -106,7 +107,7 @@ concept Dimension = detail::BaseDimension || detail::DerivedDimension; * * Satisfied when both argument satisfy a `Dimension` concept and when they compare equal. */ -template +MP_UNITS_EXPORT template concept DimensionOf = Dimension && Dimension> && (T{} == D); } // namespace mp_units diff --git a/src/core/include/mp-units/bits/external/algorithm.h b/src/core/include/mp-units/bits/external/algorithm.h index b9a8ca96..4464efef 100644 --- a/src/core/include/mp-units/bits/external/algorithm.h +++ b/src/core/include/mp-units/bits/external/algorithm.h @@ -23,10 +23,13 @@ #pragma once #include // IWYU pragma: keep + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include #include +#endif namespace mp_units::detail { diff --git a/src/core/include/mp-units/bits/external/fixed_string.h b/src/core/include/mp-units/bits/external/fixed_string.h index 44844911..b15d214c 100644 --- a/src/core/include/mp-units/bits/external/fixed_string.h +++ b/src/core/include/mp-units/bits/external/fixed_string.h @@ -24,17 +24,17 @@ // TODO use when moved to C++20 modules (parsing takes too long for each translation unit) #include +#include #include // IWYU pragma: keep -// IWYU pragma: begin_exports +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include +#include #include #include -// IWYU pragma: end_exports - -#include - +#endif +MP_UNITS_EXPORT namespace mp_units { /** diff --git a/src/core/include/mp-units/bits/external/hacks.h b/src/core/include/mp-units/bits/external/hacks.h index e0a2edde..788aea11 100644 --- a/src/core/include/mp-units/bits/external/hacks.h +++ b/src/core/include/mp-units/bits/external/hacks.h @@ -22,7 +22,9 @@ #pragma once +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include +#endif #if __clang__ #define MP_UNITS_COMP_CLANG __clang_major__ diff --git a/src/core/include/mp-units/bits/external/math_concepts.h b/src/core/include/mp-units/bits/external/math_concepts.h index 80079220..7b95dfd4 100644 --- a/src/core/include/mp-units/bits/external/math_concepts.h +++ b/src/core/include/mp-units/bits/external/math_concepts.h @@ -22,7 +22,9 @@ #pragma once +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include +#endif namespace mp_units::detail { diff --git a/src/core/include/mp-units/bits/external/prime.h b/src/core/include/mp-units/bits/external/prime.h index dbc3e976..06d03dde 100644 --- a/src/core/include/mp-units/bits/external/prime.h +++ b/src/core/include/mp-units/bits/external/prime.h @@ -23,12 +23,15 @@ #pragma once #include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include #include #include #include +#endif namespace mp_units::detail { diff --git a/src/core/include/mp-units/bits/external/type_list.h b/src/core/include/mp-units/bits/external/type_list.h index 80b66e06..90fec0b6 100644 --- a/src/core/include/mp-units/bits/external/type_list.h +++ b/src/core/include/mp-units/bits/external/type_list.h @@ -23,9 +23,12 @@ #pragma once #include // IWYU pragma: keep + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include +#endif MP_UNITS_DIAGNOSTIC_PUSH MP_UNITS_DIAGNOSTIC_IGNORE_EXPR_ALWAYS_TF diff --git a/src/core/include/mp-units/bits/external/type_name.h b/src/core/include/mp-units/bits/external/type_name.h index e8fb007f..d4867033 100644 --- a/src/core/include/mp-units/bits/external/type_name.h +++ b/src/core/include/mp-units/bits/external/type_name.h @@ -2,7 +2,9 @@ #pragma once +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include +#endif template [[nodiscard]] consteval std::string_view type_name() diff --git a/src/core/include/mp-units/bits/external/type_traits.h b/src/core/include/mp-units/bits/external/type_traits.h index f98db6c9..3322a790 100644 --- a/src/core/include/mp-units/bits/external/type_traits.h +++ b/src/core/include/mp-units/bits/external/type_traits.h @@ -23,8 +23,12 @@ #pragma once #include +#include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include +#endif namespace mp_units { @@ -45,6 +49,8 @@ struct conditional_impl { } // namespace detail +MP_UNITS_EXPORT_BEGIN + template using conditional = MP_UNITS_TYPENAME detail::conditional_impl::template type; @@ -71,6 +77,8 @@ inline constexpr bool is_specialization_of_v = false; template typename Type> inline constexpr bool is_specialization_of_v, Type> = true; +MP_UNITS_EXPORT_END + // is_derived_from_specialization_of namespace detail { diff --git a/src/core/include/mp-units/bits/fmt.h b/src/core/include/mp-units/bits/fmt.h index 4d1848e6..8ffb7284 100644 --- a/src/core/include/mp-units/bits/fmt.h +++ b/src/core/include/mp-units/bits/fmt.h @@ -29,11 +29,14 @@ #pragma once -#include #include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include #include #include #include +#endif // most of the below code is based on/copied from fmtlib diff --git a/src/core/include/mp-units/bits/magnitude.h b/src/core/include/mp-units/bits/magnitude.h index 4b4e7646..7fa09d94 100644 --- a/src/core/include/mp-units/bits/magnitude.h +++ b/src/core/include/mp-units/bits/magnitude.h @@ -28,14 +28,18 @@ #include #include #include +#include #include #include #include #include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include #include +#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 +MP_UNITS_EXPORT template concept Magnitude = detail::is_magnitude; /** @@ -525,6 +529,8 @@ constexpr T get_value(const magnitude&) 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 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 [[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 +MP_UNITS_EXPORT template inline constexpr std::optional known_first_factor = std::nullopt; namespace detail { @@ -819,14 +830,14 @@ inline constexpr auto prime_factorization_v = prime_factorization::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 +MP_UNITS_EXPORT template requires detail::gt_zero inline constexpr Magnitude auto mag = detail::prime_factorization_v / detail::prime_factorization_v; /** * @brief Create a Magnitude which is some rational number raised to a rational power. */ -template +MP_UNITS_EXPORT template requires detail::gt_zero inline constexpr Magnitude auto mag_power = pow(mag); diff --git a/src/core/include/mp-units/bits/module_macros.h b/src/core/include/mp-units/bits/module_macros.h new file mode 100644 index 00000000..f0378d4d --- /dev/null +++ b/src/core/include/mp-units/bits/module_macros.h @@ -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 diff --git a/src/core/include/mp-units/bits/quantity_cast.h b/src/core/include/mp-units/bits/quantity_cast.h index 04228a3b..0f1c30af 100644 --- a/src/core/include/mp-units/bits/quantity_cast.h +++ b/src/core/include/mp-units/bits/quantity_cast.h @@ -22,11 +22,16 @@ #pragma once +#include #include #include #include -#include +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#endif + +MP_UNITS_EXPORT namespace mp_units { /** diff --git a/src/core/include/mp-units/bits/quantity_concepts.h b/src/core/include/mp-units/bits/quantity_concepts.h index bcebab84..4b7e9aef 100644 --- a/src/core/include/mp-units/bits/quantity_concepts.h +++ b/src/core/include/mp-units/bits/quantity_concepts.h @@ -22,6 +22,7 @@ #pragma once +#include #include #include #include @@ -29,7 +30,7 @@ namespace mp_units { -template Rep> +MP_UNITS_EXPORT template 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; }; +MP_UNITS_EXPORT_END + } // namespace mp_units diff --git a/src/core/include/mp-units/bits/quantity_point_concepts.h b/src/core/include/mp-units/bits/quantity_point_concepts.h index 765717a3..0a2cc8fc 100644 --- a/src/core/include/mp-units/bits/quantity_point_concepts.h +++ b/src/core/include/mp-units/bits/quantity_point_concepts.h @@ -22,6 +22,7 @@ #pragma once +#include #include #include #include @@ -30,7 +31,7 @@ namespace mp_units { -template +MP_UNITS_EXPORT template 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 +MP_UNITS_EXPORT template concept QuantityPoint = detail::is_quantity_point; -template +MP_UNITS_EXPORT template 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 +MP_UNITS_EXPORT template concept PointOrigin = detail::AbsolutePointOrigin || detail::RelativePointOrigin; /** @@ -102,11 +103,11 @@ concept PointOrigin = detail::AbsolutePointOrigin || detail::RelativePointOri * * Satisfied by all quantity point origins that are defined using a provided quantity specification. */ -template +MP_UNITS_EXPORT template concept PointOriginFor = PointOrigin && QuantitySpecOf, T::quantity_spec>; -template auto PO, - RepresentationOf Rep> +MP_UNITS_EXPORT template auto PO, + RepresentationOf 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 +MP_UNITS_EXPORT template concept QuantityPointOf = QuantityPoint && (QuantitySpecOf, V> || detail::SameAbsolutePointOriginAs, 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 +MP_UNITS_EXPORT template concept QuantityPointLike = requires { quantity_point_like_traits::reference; requires Reference::reference)>>; diff --git a/src/core/include/mp-units/bits/quantity_spec_concepts.h b/src/core/include/mp-units/bits/quantity_spec_concepts.h index 6ddff15c..5897d3d1 100644 --- a/src/core/include/mp-units/bits/quantity_spec_concepts.h +++ b/src/core/include/mp-units/bits/quantity_spec_concepts.h @@ -24,9 +24,11 @@ #include #include +#include namespace mp_units { +MP_UNITS_EXPORT #ifdef __cpp_explicit_this_parameter template #else @@ -125,11 +127,11 @@ concept IntermediateDerivedQuantitySpec = } // namespace detail -template +MP_UNITS_EXPORT template concept QuantitySpec = detail::NamedQuantitySpec || detail::IntermediateDerivedQuantitySpec || detail::QuantityKindSpec; -template +MP_UNITS_EXPORT template [[nodiscard]] consteval detail::QuantityKindSpec auto get_kind(Q q); namespace detail { @@ -142,7 +144,7 @@ concept NestedQuantityKindSpecOf = } -template +MP_UNITS_EXPORT template concept QuantitySpecOf = QuantitySpec && QuantitySpec> && implicitly_convertible(T{}, QS) && // the below is to make the following work diff --git a/src/core/include/mp-units/bits/ratio.h b/src/core/include/mp-units/bits/ratio.h index ce4921b3..b1b6d286 100644 --- a/src/core/include/mp-units/bits/ratio.h +++ b/src/core/include/mp-units/bits/ratio.h @@ -24,9 +24,13 @@ #include #include +#include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include +#endif namespace mp_units { @@ -63,7 +67,7 @@ template * 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; diff --git a/src/core/include/mp-units/bits/reference_concepts.h b/src/core/include/mp-units/bits/reference_concepts.h index f963a42a..639fcbca 100644 --- a/src/core/include/mp-units/bits/reference_concepts.h +++ b/src/core/include/mp-units/bits/reference_concepts.h @@ -22,12 +22,13 @@ #pragma once +#include #include #include namespace mp_units { -template +MP_UNITS_EXPORT template struct reference; namespace detail { @@ -41,6 +42,8 @@ struct is_specialization_of_reference> : std::true_type {}; } // namespace detail +MP_UNITS_EXPORT_BEGIN + /** * @brief A concept matching all references in the library. * @@ -74,4 +77,6 @@ template template concept ReferenceOf = Reference && QuantitySpecOf, QS>; +MP_UNITS_EXPORT_END + } // namespace mp_units diff --git a/src/core/include/mp-units/bits/representation_concepts.h b/src/core/include/mp-units/bits/representation_concepts.h index f25a0d9b..9f9bfa52 100644 --- a/src/core/include/mp-units/bits/representation_concepts.h +++ b/src/core/include/mp-units/bits/representation_concepts.h @@ -22,11 +22,15 @@ #pragma once +#include #include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include #include +#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 +MP_UNITS_EXPORT template concept Representation = (is_scalar || is_vector || is_tensor)&&std::regular && detail::Scalable; -template +MP_UNITS_EXPORT template concept RepresentationOf = Representation && ((Ch == quantity_character::scalar && is_scalar) || (Ch == quantity_character::vector && is_vector) || (Ch == quantity_character::tensor && is_tensor)); diff --git a/src/core/include/mp-units/bits/symbol_text.h b/src/core/include/mp-units/bits/symbol_text.h index e32cd55e..cf3c05ef 100644 --- a/src/core/include/mp-units/bits/symbol_text.h +++ b/src/core/include/mp-units/bits/symbol_text.h @@ -25,15 +25,19 @@ // IWYU pragma: begin_exports #include #include +#include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include #include #include #include -// IWYU pragma: end_exports - -#include +#endif #if __cpp_lib_text_encoding +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include +#endif static_assert(std::text_encoding::literal().mib() == std::text_encoding::id::UTF8); #endif @@ -74,7 +78,7 @@ constexpr fixed_u8string to_u8string(fixed_string txt) * @tparam N The size of a Unicode symbol * @tparam M The size of the ASCII-only symbol */ -template +MP_UNITS_EXPORT template struct basic_symbol_text { fixed_u8string unicode_; fixed_string ascii_; diff --git a/src/core/include/mp-units/bits/unit_concepts.h b/src/core/include/mp-units/bits/unit_concepts.h index f4e616c8..02e954e1 100644 --- a/src/core/include/mp-units/bits/unit_concepts.h +++ b/src/core/include/mp-units/bits/unit_concepts.h @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -42,13 +43,13 @@ struct is_unit : std::false_type {}; * * Satisfied by all unit types provided by the library. */ -template +MP_UNITS_EXPORT template concept Unit = detail::is_unit::value; template struct scaled_unit; -template +MP_UNITS_EXPORT template 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 +MP_UNITS_EXPORT template inline constexpr bool unit_can_be_prefixed = true; /** * @brief A concept to be used to define prefixes for a unit */ -template +MP_UNITS_EXPORT template concept PrefixableUnit = detail::NamedUnit && unit_can_be_prefixed; namespace detail { @@ -113,7 +114,7 @@ concept DerivedUnitExpr = Unit || detail::is_power_of_unit || detail::is_p template struct derived_unit; -template +MP_UNITS_EXPORT template requires(!Symbol.empty()) struct prefixed_unit; @@ -177,7 +178,7 @@ template /** * @brief A concept matching all units that can be used as quantity references */ -template +MP_UNITS_EXPORT template concept AssociatedUnit = Unit && detail::has_associated_quantity(U{}); /** @@ -186,7 +187,7 @@ concept AssociatedUnit = Unit && 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 +MP_UNITS_EXPORT template concept UnitOf = AssociatedUnit && QuantitySpec> && 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`. */ -template +MP_UNITS_EXPORT template concept UnitCompatibleWith = Unit && Unit> && QuantitySpec> && (!AssociatedUnit || UnitOf)&&detail::have_same_canonical_reference_unit(U{}, U2); diff --git a/src/core/include/mp-units/bits/value_cast.h b/src/core/include/mp-units/bits/value_cast.h index 11192a1c..7b2c6ddd 100644 --- a/src/core/include/mp-units/bits/value_cast.h +++ b/src/core/include/mp-units/bits/value_cast.h @@ -22,6 +22,7 @@ #pragma once +#include #include #include #include @@ -29,6 +30,7 @@ #include #include +MP_UNITS_EXPORT namespace mp_units { /** diff --git a/src/core/include/mp-units/compare.h b/src/core/include/mp-units/compare.h index d94645b5..e2fb0deb 100644 --- a/src/core/include/mp-units/compare.h +++ b/src/core/include/mp-units/compare.h @@ -22,8 +22,13 @@ #pragma once -#include +#include +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#endif + +MP_UNITS_EXPORT namespace mp_units { template diff --git a/src/core/include/mp-units/customization_points.h b/src/core/include/mp-units/customization_points.h index 2741679e..99578ea4 100644 --- a/src/core/include/mp-units/customization_points.h +++ b/src/core/include/mp-units/customization_points.h @@ -23,11 +23,17 @@ #pragma once #include +#include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include +#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 -concept ConversionSpec = is_specialization_of || is_specialization_of; - -template -concept ConversionSpecOf = ConversionSpec && std::same_as; - -} // namespace detail /** * @brief Provides support for external quantity-like types @@ -192,4 +189,16 @@ struct quantity_like_traits; template struct quantity_point_like_traits; +MP_UNITS_EXPORT_END + +namespace detail { + +template +concept ConversionSpec = is_specialization_of || is_specialization_of; + +template +concept ConversionSpecOf = ConversionSpec && std::same_as; + +} // namespace detail + } // namespace mp_units diff --git a/src/core/include/mp-units/dimension.h b/src/core/include/mp-units/dimension.h index 14ce1898..88d78792 100644 --- a/src/core/include/mp-units/dimension.h +++ b/src/core/include/mp-units/dimension.h @@ -25,6 +25,7 @@ #include #include #include +#include #include 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 +MP_UNITS_EXPORT template struct base_dimension { static constexpr auto symbol = Symbol; ///< Unique base dimension identifier }; @@ -124,7 +125,7 @@ struct derived_dimension : detail::expr_fractions { +MP_UNITS_EXPORT inline constexpr struct dimension_one : derived_dimension<> { } dimension_one; namespace detail { @@ -136,14 +137,14 @@ struct is_dimension_one : std::true_type {}; // Operators -template +MP_UNITS_EXPORT template [[nodiscard]] consteval Dimension auto operator*(Lhs, Rhs) { return detail::expr_multiply( Lhs{}, Rhs{}); } -template +MP_UNITS_EXPORT template [[nodiscard]] consteval Dimension auto operator/(Lhs, Rhs) { return detail::expr_divide(Lhs{}, @@ -163,13 +164,13 @@ template } // namespace detail -template +MP_UNITS_EXPORT template [[nodiscard]] consteval bool operator==(Lhs lhs, Rhs rhs) { return is_same_v || 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 * * @return Dimension The result of computation */ -template +MP_UNITS_EXPORT template requires detail::non_zero [[nodiscard]] consteval Dimension auto pow(D d) { @@ -201,7 +202,7 @@ template * * @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 * * @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 diff --git a/src/core/include/mp-units/format.h b/src/core/include/mp-units/format.h index f7b40f2a..79195f2f 100644 --- a/src/core/include/mp-units/format.h +++ b/src/core/include/mp-units/format.h @@ -28,8 +28,10 @@ #include #include #include -#include +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#endif namespace mp_units::detail { diff --git a/src/core/include/mp-units/math.h b/src/core/include/mp-units/math.h index cf5ab987..6620a63c 100644 --- a/src/core/include/mp-units/math.h +++ b/src/core/include/mp-units/math.h @@ -22,20 +22,20 @@ #pragma once +#include #include #include #include #include -// IWYU pragma: begin_exports +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include -// IWYU pragma: end_exports - #include +#endif +MP_UNITS_EXPORT namespace mp_units { - /** * @brief Computes the value of a quantity raised to the `Num/Den` power * diff --git a/src/core/include/mp-units/ostream.h b/src/core/include/mp-units/ostream.h index 3f462fb1..4bf25669 100644 --- a/src/core/include/mp-units/ostream.h +++ b/src/core/include/mp-units/ostream.h @@ -23,9 +23,13 @@ #pragma once +#include #include #include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include +#endif namespace mp_units { @@ -51,6 +55,8 @@ void to_stream(std::basic_ostream& os, const quantity& q) } // namespace detail +MP_UNITS_EXPORT_BEGIN + template std::basic_ostream& operator<<(std::basic_ostream& os, U u) { @@ -86,4 +92,6 @@ std::basic_ostream& operator<<(std::basic_ostream& return os; } +MP_UNITS_EXPORT_END + } // namespace mp_units diff --git a/src/core/include/mp-units/quantity.h b/src/core/include/mp-units/quantity.h index ace7c31c..fb9a3445 100644 --- a/src/core/include/mp-units/quantity.h +++ b/src/core/include/mp-units/quantity.h @@ -24,6 +24,7 @@ #pragma once #include +#include #include #include #include @@ -32,8 +33,11 @@ #include #include #include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include +#endif // the below is not used in this header but should be exposed with it #include @@ -82,6 +86,8 @@ using common_quantity_for = quantity 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 { diff --git a/src/core/include/mp-units/quantity_point.h b/src/core/include/mp-units/quantity_point.h index c42994c0..1f6bcba6 100644 --- a/src/core/include/mp-units/quantity_point.h +++ b/src/core/include/mp-units/quantity_point.h @@ -22,21 +22,25 @@ #pragma once +#include #include #include #include #include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include +#endif namespace mp_units { -template +MP_UNITS_EXPORT template struct absolute_point_origin { static constexpr QuantitySpec auto quantity_spec = QS; using _type_ = absolute_point_origin; }; -template +MP_UNITS_EXPORT template 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 struct zeroth_point_origin_ : absolute_point_origin, QS> {}; -template +MP_UNITS_EXPORT template inline constexpr zeroth_point_origin_ zeroth_point_origin; namespace detail { @@ -71,7 +75,7 @@ template } // namespace detail -template +MP_UNITS_EXPORT template [[nodiscard]] consteval bool operator==(PO1 po1, PO2 po2) { if constexpr (detail::AbsolutePointOrigin && detail::AbsolutePointOrigin) @@ -86,7 +90,7 @@ template return detail::same_absolute_point_origins(po1, po2) && is_eq_zero(PO2::quantity_point.quantity_from_zero()); } -template +MP_UNITS_EXPORT template [[nodiscard]] consteval PointOriginFor auto default_point_origin(R) { if constexpr (requires { get_unit(R{}).point_origin; }) @@ -108,6 +112,8 @@ template } // namespace detail +MP_UNITS_EXPORT_BEGIN + /** * @brief A quantity point * @@ -507,4 +513,6 @@ template QP2> return lhs - lhs.absolute_point_origin == rhs - rhs.absolute_point_origin; } +MP_UNITS_EXPORT_END + } // namespace mp_units diff --git a/src/core/include/mp-units/quantity_spec.h b/src/core/include/mp-units/quantity_spec.h index f5e01bc8..4b54c647 100644 --- a/src/core/include/mp-units/quantity_spec.h +++ b/src/core/include/mp-units/quantity_spec.h @@ -27,19 +27,22 @@ #include #include #include +#include #include #include #include #include #include #include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include +#endif namespace mp_units { namespace detail { - template requires(!AssociatedUnit) || UnitOf [[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_ : quantity_spec, Q{}> { }; #endif -template +MP_UNITS_EXPORT template requires(detail::get_kind_tree_root(Q) == Q) inline constexpr kind_of_> kind_of; @@ -498,6 +505,8 @@ template } // namespace detail +MP_UNITS_EXPORT_BEGIN + // Operators template @@ -579,6 +588,7 @@ template */ [[nodiscard]] consteval QuantitySpec auto cbrt(QuantitySpec auto q) { return pow<1, 3>(q); } +MP_UNITS_EXPORT_END namespace detail { @@ -1386,6 +1396,8 @@ template } // namespace detail +MP_UNITS_EXPORT_BEGIN + template [[nodiscard]] consteval bool implicitly_convertible(From from, To to) { @@ -1410,6 +1422,8 @@ template return implicitly_convertible(qs1, qs2) && implicitly_convertible(qs2, qs1); } +MP_UNITS_EXPORT_END + namespace detail { template @@ -1454,6 +1468,8 @@ template } // namespace detail +MP_UNITS_EXPORT_BEGIN + template [[nodiscard]] consteval detail::QuantityKindSpec auto get_kind(Q q) { @@ -1502,4 +1518,6 @@ template return common_quantity_spec(common_quantity_spec(q1, q2), q3, rest...); } +MP_UNITS_EXPORT_END + } // namespace mp_units diff --git a/src/core/include/mp-units/random.h b/src/core/include/mp-units/random.h index 8cbb40fa..b66cfb22 100644 --- a/src/core/include/mp-units/random.h +++ b/src/core/include/mp-units/random.h @@ -22,9 +22,13 @@ #pragma once +#include #include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include +#endif namespace mp_units { @@ -82,6 +86,8 @@ std::vector fw_bl_pwl(std::initializer_list& bl, UnaryOperat } } // namespace detail +MP_UNITS_EXPORT_BEGIN + template requires std::integral struct uniform_int_distribution : public std::uniform_int_distribution { @@ -571,4 +577,6 @@ public: Q max() const { return base::max() * Q::reference; } }; +MP_UNITS_EXPORT_END + } // namespace mp_units diff --git a/src/core/include/mp-units/reference.h b/src/core/include/mp-units/reference.h index eb0f34c5..047f13c4 100644 --- a/src/core/include/mp-units/reference.h +++ b/src/core/include/mp-units/reference.h @@ -23,6 +23,7 @@ #pragma once #include +#include #include #include #include @@ -36,6 +37,8 @@ using reference_t = reference, 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 common_unit(get_unit(r1), get_unit(r2), get_unit(rest)...)>{}; } +MP_UNITS_EXPORT_END + namespace detail { template diff --git a/src/core/include/mp-units/system_reference.h b/src/core/include/mp-units/system_reference.h index fed03ae3..7bf30383 100644 --- a/src/core/include/mp-units/system_reference.h +++ b/src/core/include/mp-units/system_reference.h @@ -23,10 +23,12 @@ #pragma once #include +#include #include #include #include +MP_UNITS_EXPORT namespace mp_units { /** diff --git a/src/core/include/mp-units/unit.h b/src/core/include/mp-units/unit.h index 03d5b61b..b67f16e7 100644 --- a/src/core/include/mp-units/unit.h +++ b/src/core/include/mp-units/unit.h @@ -29,14 +29,18 @@ #include #include #include +#include #include #include #include #include #include #include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE #include -#include +#include +#endif namespace mp_units { @@ -103,7 +107,7 @@ inline constexpr bool is_specialization_of_scaled_unit> = true * * @tparam Symbol a short text representation of the unit */ -template +MP_UNITS_EXPORT template struct named_unit; /** @@ -220,7 +224,7 @@ struct named_unit : std::remove_const_t { * @tparam M scaling factor of the prefix * @tparam U a named unit to be prefixed */ -template +MP_UNITS_EXPORT template requires(!Symbol.empty()) struct prefixed_unit : std::remove_const_t { static constexpr auto symbol = Symbol + U.symbol; @@ -287,7 +291,7 @@ struct derived_unit : detail::expr_fractions {}; * 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 [[nodiscard]] MP_UNITS_CONSTEVAL Unit auto inverse(Unit auto u) { return one / u; } +MP_UNITS_EXPORT_END namespace detail { @@ -522,7 +527,7 @@ template } // 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> = } // 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 Out> @@ -840,7 +849,7 @@ constexpr Out unit_symbol_impl(Out out, const derived_unit&, unit_symbo } // namespace detail -template Out, Unit U> +MP_UNITS_EXPORT template Out, Unit U> constexpr Out unit_symbol_to(Out out, U u, unit_symbol_formatting fmt = unit_symbol_formatting{}) { return detail::unit_symbol_impl(out, u, fmt, false); @@ -860,7 +869,7 @@ template // TODO Refactor to `unit_symbol(U, fmt)` when P1045: constexpr Function Parameters is available -template +MP_UNITS_EXPORT template [[nodiscard]] consteval auto unit_symbol(U) { auto get_size = []() consteval { diff --git a/src/core/mp-units-core.cpp b/src/core/mp-units-core.cpp index 17a3d87c..c5a48436 100644 --- a/src/core/mp-units-core.cpp +++ b/src/core/mp-units-core.cpp @@ -4,7 +4,6 @@ module; export module mp_units.core; -export -{ +#define MP_UNITS_IN_MODULE_INTERFACE + #include -} diff --git a/src/systems/include/mp-units/systems/angular/math.h b/src/systems/include/mp-units/systems/angular/math.h index 4d863a0b..63a2d8f3 100644 --- a/src/systems/include/mp-units/systems/angular/math.h +++ b/src/systems/include/mp-units/systems/angular/math.h @@ -22,18 +22,19 @@ #pragma once +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include #include -#endif -#include - -// IWYU pragma: begin_exports #include -// IWYU pragma: end_exports +#endif + +MP_UNITS_EXPORT namespace mp_units::angular { template auto R, typename Rep> diff --git a/src/systems/include/mp-units/systems/angular/units.h b/src/systems/include/mp-units/systems/angular/units.h index 507be295..28b95429 100644 --- a/src/systems/include/mp-units/systems/angular/units.h +++ b/src/systems/include/mp-units/systems/angular/units.h @@ -22,12 +22,15 @@ #pragma once +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include #endif +MP_UNITS_EXPORT namespace mp_units::angular { // clang-format off diff --git a/src/systems/include/mp-units/systems/cgs/cgs.h b/src/systems/include/mp-units/systems/cgs/cgs.h index 0fe06322..ed7d4ccc 100644 --- a/src/systems/include/mp-units/systems/cgs/cgs.h +++ b/src/systems/include/mp-units/systems/cgs/cgs.h @@ -22,11 +22,14 @@ #pragma once +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif -#include +MP_UNITS_EXPORT namespace mp_units::cgs { // clang-format off diff --git a/src/systems/include/mp-units/systems/hep/hep.h b/src/systems/include/mp-units/systems/hep/hep.h index c7c4a864..61661792 100644 --- a/src/systems/include/mp-units/systems/hep/hep.h +++ b/src/systems/include/mp-units/systems/hep/hep.h @@ -22,15 +22,20 @@ #pragma once +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif -#include + +MP_UNITS_EXPORT +namespace mp_units { template<> -inline constexpr std::optional mp_units::known_first_factor<334'524'384'739> = 334'524'384'739; +inline constexpr std::optional 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 diff --git a/src/systems/include/mp-units/systems/iau/iau.h b/src/systems/include/mp-units/systems/iau/iau.h index 3bd55032..ccb54ede 100644 --- a/src/systems/include/mp-units/systems/iau/iau.h +++ b/src/systems/include/mp-units/systems/iau/iau.h @@ -22,12 +22,15 @@ #pragma once -#ifndef MP_UNITS_IN_MODULE_INTERFACE -#include -#endif +#include #include #include +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#endif + +MP_UNITS_EXPORT namespace mp_units::iau { // https://en.wikipedia.org/wiki/Astronomical_system_of_units diff --git a/src/systems/include/mp-units/systems/iec80000/binary_prefixes.h b/src/systems/include/mp-units/systems/iec80000/binary_prefixes.h index f32daffb..65a2e498 100644 --- a/src/systems/include/mp-units/systems/iec80000/binary_prefixes.h +++ b/src/systems/include/mp-units/systems/iec80000/binary_prefixes.h @@ -22,6 +22,8 @@ #pragma once +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif @@ -38,6 +40,8 @@ template struct exbi_ : prefixed_unit<"Ei", mag_power<2, 60>, template struct zebi_ : prefixed_unit<"Zi", mag_power<2, 70>, U{}> {}; template struct yobi_ : prefixed_unit<"Yi", mag_power<2, 80>, U{}> {}; +MP_UNITS_EXPORT_BEGIN + template inline constexpr kibi_> kibi; template inline constexpr mebi_> mebi; template inline constexpr gibi_> gibi; @@ -48,4 +52,6 @@ template inline constexpr zebi_ inline constexpr yobi_> yobi; // clang-format on +MP_UNITS_EXPORT_END + } // namespace mp_units::iec80000 diff --git a/src/systems/include/mp-units/systems/iec80000/quantities.h b/src/systems/include/mp-units/systems/iec80000/quantities.h index 45050479..1a8e319f 100644 --- a/src/systems/include/mp-units/systems/iec80000/quantities.h +++ b/src/systems/include/mp-units/systems/iec80000/quantities.h @@ -22,13 +22,16 @@ #pragma once +#include +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #endif -#include -#include +MP_UNITS_EXPORT namespace mp_units::iec80000 { // dimensions of base quantities diff --git a/src/systems/include/mp-units/systems/iec80000/unit_symbols.h b/src/systems/include/mp-units/systems/iec80000/unit_symbols.h index 476544e9..53d423a8 100644 --- a/src/systems/include/mp-units/systems/iec80000/unit_symbols.h +++ b/src/systems/include/mp-units/systems/iec80000/unit_symbols.h @@ -22,10 +22,12 @@ #pragma once +#include #include #include #include +MP_UNITS_EXPORT namespace mp_units::iec80000::unit_symbols { // bit diff --git a/src/systems/include/mp-units/systems/iec80000/units.h b/src/systems/include/mp-units/systems/iec80000/units.h index 31c958a8..c8ec5aeb 100644 --- a/src/systems/include/mp-units/systems/iec80000/units.h +++ b/src/systems/include/mp-units/systems/iec80000/units.h @@ -22,12 +22,15 @@ #pragma once -#ifndef MP_UNITS_IN_MODULE_INTERFACE -#include -#endif +#include #include #include +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#endif + +MP_UNITS_EXPORT namespace mp_units::iec80000 { // clang-format off diff --git a/src/systems/include/mp-units/systems/imperial/imperial.h b/src/systems/include/mp-units/systems/imperial/imperial.h index cd48d83f..52bcae3b 100644 --- a/src/systems/include/mp-units/systems/imperial/imperial.h +++ b/src/systems/include/mp-units/systems/imperial/imperial.h @@ -22,11 +22,14 @@ #pragma once +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif -#include +MP_UNITS_EXPORT namespace mp_units::imperial { using namespace international; diff --git a/src/systems/include/mp-units/systems/international/international.h b/src/systems/include/mp-units/systems/international/international.h index 93208fc5..e49b3293 100644 --- a/src/systems/include/mp-units/systems/international/international.h +++ b/src/systems/include/mp-units/systems/international/international.h @@ -22,12 +22,15 @@ #pragma once -#ifndef MP_UNITS_IN_MODULE_INTERFACE -#include -#endif +#include #include #include +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#endif + +MP_UNITS_EXPORT namespace mp_units::international { // clang-format off diff --git a/src/systems/include/mp-units/systems/isq/atomic_and_nuclear_physics.h b/src/systems/include/mp-units/systems/isq/atomic_and_nuclear_physics.h index 706ad242..7bc3ca10 100644 --- a/src/systems/include/mp-units/systems/isq/atomic_and_nuclear_physics.h +++ b/src/systems/include/mp-units/systems/isq/atomic_and_nuclear_physics.h @@ -22,11 +22,14 @@ #pragma once +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif -#include +MP_UNITS_EXPORT namespace mp_units::isq { diff --git a/src/systems/include/mp-units/systems/isq/base_quantities.h b/src/systems/include/mp-units/systems/isq/base_quantities.h index bbb0af2e..2cf41402 100644 --- a/src/systems/include/mp-units/systems/isq/base_quantities.h +++ b/src/systems/include/mp-units/systems/isq/base_quantities.h @@ -22,12 +22,15 @@ #pragma once +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include #endif +MP_UNITS_EXPORT namespace mp_units::isq { // clang-format off diff --git a/src/systems/include/mp-units/systems/isq/electromagnetism.h b/src/systems/include/mp-units/systems/isq/electromagnetism.h index 6d120808..c4722ec5 100644 --- a/src/systems/include/mp-units/systems/isq/electromagnetism.h +++ b/src/systems/include/mp-units/systems/isq/electromagnetism.h @@ -22,13 +22,16 @@ #pragma once -#ifndef MP_UNITS_IN_MODULE_INTERFACE -#include -#endif +#include #include #include #include +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#endif + +MP_UNITS_EXPORT namespace mp_units::isq { QUANTITY_SPEC(electric_charge, electric_current* time); diff --git a/src/systems/include/mp-units/systems/isq/mechanics.h b/src/systems/include/mp-units/systems/isq/mechanics.h index cc220182..95e90a98 100644 --- a/src/systems/include/mp-units/systems/isq/mechanics.h +++ b/src/systems/include/mp-units/systems/isq/mechanics.h @@ -22,12 +22,15 @@ #pragma once -#ifndef MP_UNITS_IN_MODULE_INTERFACE -#include -#endif +#include #include #include +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#endif + +MP_UNITS_EXPORT namespace mp_units::isq { QUANTITY_SPEC(mass_density, mass / volume); diff --git a/src/systems/include/mp-units/systems/isq/si_quantities.h b/src/systems/include/mp-units/systems/isq/si_quantities.h index 6ed1095c..3d42bd53 100644 --- a/src/systems/include/mp-units/systems/isq/si_quantities.h +++ b/src/systems/include/mp-units/systems/isq/si_quantities.h @@ -22,11 +22,14 @@ #pragma once +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif -#include +MP_UNITS_EXPORT namespace mp_units::isq { // space and time diff --git a/src/systems/include/mp-units/systems/isq/space_and_time.h b/src/systems/include/mp-units/systems/isq/space_and_time.h index c835f761..e72cb9eb 100644 --- a/src/systems/include/mp-units/systems/isq/space_and_time.h +++ b/src/systems/include/mp-units/systems/isq/space_and_time.h @@ -22,11 +22,14 @@ #pragma once +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif -#include +MP_UNITS_EXPORT namespace mp_units::isq { QUANTITY_SPEC(height, length); diff --git a/src/systems/include/mp-units/systems/isq/thermodynamics.h b/src/systems/include/mp-units/systems/isq/thermodynamics.h index 2e25fbf9..75743e31 100644 --- a/src/systems/include/mp-units/systems/isq/thermodynamics.h +++ b/src/systems/include/mp-units/systems/isq/thermodynamics.h @@ -22,13 +22,16 @@ #pragma once -#ifndef MP_UNITS_IN_MODULE_INTERFACE -#include -#endif +#include #include #include #include +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#endif + +MP_UNITS_EXPORT namespace mp_units::isq { QUANTITY_SPEC(Celsius_temperature, thermodynamic_temperature); // TODO should we account for T0 here? diff --git a/src/systems/include/mp-units/systems/isq_angle/isq_angle.h b/src/systems/include/mp-units/systems/isq_angle/isq_angle.h index 111853a1..2b4db46c 100644 --- a/src/systems/include/mp-units/systems/isq_angle/isq_angle.h +++ b/src/systems/include/mp-units/systems/isq_angle/isq_angle.h @@ -22,13 +22,16 @@ #pragma once +#include +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #endif -#include -#include +MP_UNITS_EXPORT namespace mp_units::isq_angle { using namespace isq; diff --git a/src/systems/include/mp-units/systems/natural/natural.h b/src/systems/include/mp-units/systems/natural/natural.h index 3d59376c..0b534cbf 100644 --- a/src/systems/include/mp-units/systems/natural/natural.h +++ b/src/systems/include/mp-units/systems/natural/natural.h @@ -22,14 +22,17 @@ #pragma once -#ifndef MP_UNITS_IN_MODULE_INTERFACE -#include -#include -#endif +#include #include #include #include +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#include +#endif + +MP_UNITS_EXPORT namespace mp_units::natural { // clang-format off diff --git a/src/systems/include/mp-units/systems/si/chrono.h b/src/systems/include/mp-units/systems/si/chrono.h index fb11307c..80bdc003 100644 --- a/src/systems/include/mp-units/systems/si/chrono.h +++ b/src/systems/include/mp-units/systems/si/chrono.h @@ -22,14 +22,16 @@ #pragma once +#include +#include +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include #endif -#include -#include -#include namespace mp_units { @@ -62,7 +64,7 @@ template } // namespace detail -template +MP_UNITS_EXPORT template struct quantity_like_traits> { static constexpr auto reference = detail::time_unit_from_chrono_period(); using rep = Rep; @@ -84,9 +86,10 @@ template struct chrono_point_origin_ : absolute_point_origin, isq::time> { using clock = C; }; -template +MP_UNITS_EXPORT template inline constexpr chrono_point_origin_ chrono_point_origin; +MP_UNITS_EXPORT_BEGIN template struct quantity_point_like_traits>> { @@ -111,7 +114,7 @@ struct quantity_point_like_traits 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>{q}; } @@ -122,10 +125,12 @@ template 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>>; return ret_type(to_chrono_duration(qp - qp.absolute_point_origin)); } +MP_UNITS_EXPORT_END + } // namespace mp_units diff --git a/src/systems/include/mp-units/systems/si/constants.h b/src/systems/include/mp-units/systems/si/constants.h index f527908a..565b2db3 100644 --- a/src/systems/include/mp-units/systems/si/constants.h +++ b/src/systems/include/mp-units/systems/si/constants.h @@ -22,11 +22,14 @@ #pragma once +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif -#include +MP_UNITS_EXPORT namespace mp_units::si { namespace si2019 { diff --git a/src/systems/include/mp-units/systems/si/math.h b/src/systems/include/mp-units/systems/si/math.h index 053d9b36..371fb2f5 100644 --- a/src/systems/include/mp-units/systems/si/math.h +++ b/src/systems/include/mp-units/systems/si/math.h @@ -22,21 +22,21 @@ #pragma once +#include +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #include #include -#endif -#include -#include - -// IWYU pragma: begin_exports #include -// IWYU pragma: end_exports +#endif + +MP_UNITS_EXPORT namespace mp_units::si { - template auto R, typename Rep> requires requires(Rep v) { sin(v); } || requires(Rep v) { std::sin(v); } [[nodiscard]] inline QuantityOf auto sin(const quantity& q) noexcept diff --git a/src/systems/include/mp-units/systems/si/prefixes.h b/src/systems/include/mp-units/systems/si/prefixes.h index a30e7546..22ef8811 100644 --- a/src/systems/include/mp-units/systems/si/prefixes.h +++ b/src/systems/include/mp-units/systems/si/prefixes.h @@ -22,6 +22,8 @@ #pragma once +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif @@ -54,6 +56,8 @@ template struct yotta_ : prefixed_unit<"Y", mag_power<10, 24>, template struct ronna_ : prefixed_unit<"R", mag_power<10, 27>, U{}> {}; template struct quetta_ : prefixed_unit<"Q", mag_power<10, 30>, U{}> {}; +MP_UNITS_EXPORT_BEGIN + template inline constexpr quecto_> quecto; template inline constexpr ronto_> ronto; template inline constexpr yocto_> yocto; @@ -80,4 +84,6 @@ template inline constexpr ronna_ inline constexpr quetta_> quetta; // clang-format on +MP_UNITS_EXPORT_END + } // namespace mp_units::si diff --git a/src/systems/include/mp-units/systems/si/unit_symbols.h b/src/systems/include/mp-units/systems/si/unit_symbols.h index 8ce9de27..fe28311f 100644 --- a/src/systems/include/mp-units/systems/si/unit_symbols.h +++ b/src/systems/include/mp-units/systems/si/unit_symbols.h @@ -22,9 +22,11 @@ #pragma once +#include #include #include +MP_UNITS_EXPORT namespace mp_units { namespace si::unit_symbols { diff --git a/src/systems/include/mp-units/systems/si/units.h b/src/systems/include/mp-units/systems/si/units.h index bd0b9aab..05d2a8b4 100644 --- a/src/systems/include/mp-units/systems/si/units.h +++ b/src/systems/include/mp-units/systems/si/units.h @@ -22,14 +22,16 @@ #pragma once +#include +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #include #endif -// #include -#include -#include +MP_UNITS_EXPORT namespace mp_units { namespace si { @@ -58,20 +60,17 @@ inline constexpr struct radian : named_unit<"rad", metre / metre, kind_of> {} steradian; inline constexpr struct hertz : named_unit<"Hz", one / second, kind_of> {} 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> {} 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> {} 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> {} 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; diff --git a/src/systems/include/mp-units/systems/typographic/typographic.h b/src/systems/include/mp-units/systems/typographic/typographic.h index ede300a1..4f076b8c 100644 --- a/src/systems/include/mp-units/systems/typographic/typographic.h +++ b/src/systems/include/mp-units/systems/typographic/typographic.h @@ -22,11 +22,14 @@ #pragma once +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif -#include +MP_UNITS_EXPORT namespace mp_units::typographic { // clang-format off diff --git a/src/systems/include/mp-units/systems/usc/usc.h b/src/systems/include/mp-units/systems/usc/usc.h index bcd51ccb..e6fd2a2f 100644 --- a/src/systems/include/mp-units/systems/usc/usc.h +++ b/src/systems/include/mp-units/systems/usc/usc.h @@ -22,11 +22,14 @@ #pragma once +#include +#include + #ifndef MP_UNITS_IN_MODULE_INTERFACE #include #endif -#include +MP_UNITS_EXPORT namespace mp_units::usc { using namespace international; diff --git a/src/systems/mp-units-systems.cpp b/src/systems/mp-units-systems.cpp index 81d2732c..aa677604 100644 --- a/src/systems/mp-units-systems.cpp +++ b/src/systems/mp-units-systems.cpp @@ -7,8 +7,6 @@ export module mp_units.systems; export import mp_units.core; -export -{ #define MP_UNITS_IN_MODULE_INTERFACE #include @@ -24,4 +22,3 @@ export #include #include #include -} diff --git a/test/static/CMakeLists.txt b/test/static/CMakeLists.txt index 2f660568..cbfeb9ea 100644 --- a/test/static/CMakeLists.txt +++ b/test/static/CMakeLists.txt @@ -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 $,/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) diff --git a/test/static/angular_test.cpp b/test/static/angular_test.cpp index c0c5a23b..c3010dfe 100644 --- a/test/static/angular_test.cpp +++ b/test/static/angular_test.cpp @@ -20,12 +20,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include -#endif +#include namespace { diff --git a/test/static/cgs_test.cpp b/test/static/cgs_test.cpp index 2d2bbf0c..c58c5885 100644 --- a/test/static/cgs_test.cpp +++ b/test/static/cgs_test.cpp @@ -21,14 +21,10 @@ // SOFTWARE. #include "test_tools.h" -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include #include #include #include -#endif template requires mp_units::is_scalar diff --git a/test/static/chrono_test.cpp b/test/static/chrono_test.cpp index dc807697..ba881fa1 100644 --- a/test/static/chrono_test.cpp +++ b/test/static/chrono_test.cpp @@ -21,15 +21,10 @@ // SOFTWARE. #include "test_tools.h" -#include -#ifdef MP_UNITS_MODULES -#include -import mp_units; -#else #include #include #include -#endif +#include namespace { diff --git a/test/static/compare_test.cpp b/test/static/compare_test.cpp index 6c966f19..5de812d9 100644 --- a/test/static/compare_test.cpp +++ b/test/static/compare_test.cpp @@ -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 #include -#endif namespace { diff --git a/test/static/concepts_test.cpp b/test/static/concepts_test.cpp index 4d443a8d..e97a1df7 100644 --- a/test/static/concepts_test.cpp +++ b/test/static/concepts_test.cpp @@ -20,19 +20,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include -#include -#include -#include -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include #include #include #include #include -#endif +#include +#include +#include +#include template inline constexpr bool mp_units::is_scalar> = true; diff --git a/test/static/custom_rep_test_min_impl.cpp b/test/static/custom_rep_test_min_impl.cpp index 2ebc01a6..ef3ba8db 100644 --- a/test/static/custom_rep_test_min_impl.cpp +++ b/test/static/custom_rep_test_min_impl.cpp @@ -21,13 +21,9 @@ // SOFTWARE. #include +#include #include #include -#ifdef MP_UNITS_MODULES -import mp_units; -#else -#include -#endif namespace { diff --git a/test/static/dimension_test.cpp b/test/static/dimension_test.cpp index 04a95357..808620d7 100644 --- a/test/static/dimension_test.cpp +++ b/test/static/dimension_test.cpp @@ -21,15 +21,11 @@ // SOFTWARE. #include "test_tools.h" -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include #include #include #include #include -#endif namespace { diff --git a/test/static/fixed_string_test.cpp b/test/static/fixed_string_test.cpp index a40677d1..a5d6769c 100644 --- a/test/static/fixed_string_test.cpp +++ b/test/static/fixed_string_test.cpp @@ -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 -#endif using namespace mp_units; diff --git a/test/static/fractional_exponent_quantity.cpp b/test/static/fractional_exponent_quantity.cpp index 3e3c79ca..ce82795d 100644 --- a/test/static/fractional_exponent_quantity.cpp +++ b/test/static/fractional_exponent_quantity.cpp @@ -21,13 +21,9 @@ // SOFTWARE. #include -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include #include #include -#endif namespace { diff --git a/test/static/hep_test.cpp b/test/static/hep_test.cpp index d5e2384a..93a95321 100644 --- a/test/static/hep_test.cpp +++ b/test/static/hep_test.cpp @@ -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 #include #include #include -#endif template requires mp_units::is_scalar diff --git a/test/static/iau_test.cpp b/test/static/iau_test.cpp index 32ccf3c8..d05fc28e 100644 --- a/test/static/iau_test.cpp +++ b/test/static/iau_test.cpp @@ -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 #include #include #include -#endif /* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */ diff --git a/test/static/iec80000_test.cpp b/test/static/iec80000_test.cpp index 1021a6cc..2718758f 100644 --- a/test/static/iec80000_test.cpp +++ b/test/static/iec80000_test.cpp @@ -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 #include #include #include -#endif /* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */ diff --git a/test/static/imperial_test.cpp b/test/static/imperial_test.cpp index 13d1ed26..7b3b3a74 100644 --- a/test/static/imperial_test.cpp +++ b/test/static/imperial_test.cpp @@ -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 #include #include -#endif namespace { diff --git a/test/static/international_test.cpp b/test/static/international_test.cpp index 910c9e26..a5a31219 100644 --- a/test/static/international_test.cpp +++ b/test/static/international_test.cpp @@ -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 #include #include #include #include #include -#endif template requires mp_units::is_scalar diff --git a/test/static/isq_angle_test.cpp b/test/static/isq_angle_test.cpp index fdb32496..ef597076 100644 --- a/test/static/isq_angle_test.cpp +++ b/test/static/isq_angle_test.cpp @@ -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 #include -#endif namespace { diff --git a/test/static/isq_test.cpp b/test/static/isq_test.cpp index 9a67d44e..4d7333f2 100644 --- a/test/static/isq_test.cpp +++ b/test/static/isq_test.cpp @@ -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 #include #include -#endif namespace { diff --git a/test/static/math_test.cpp b/test/static/math_test.cpp index 1f4e10f3..8fa12342 100644 --- a/test/static/math_test.cpp +++ b/test/static/math_test.cpp @@ -21,14 +21,10 @@ // SOFTWARE. #include -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include // IWYU pragma: keep #include #include #include -#endif namespace { diff --git a/test/static/natural_test.cpp b/test/static/natural_test.cpp index f24f31e1..7880642b 100644 --- a/test/static/natural_test.cpp +++ b/test/static/natural_test.cpp @@ -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 #include -#endif template requires mp_units::is_scalar diff --git a/test/static/prime_test.cpp b/test/static/prime_test.cpp index d6647a10..0fd724bd 100644 --- a/test/static/prime_test.cpp +++ b/test/static/prime_test.cpp @@ -20,13 +20,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include #include #include -#ifdef MP_UNITS_MODULES -import mp_units; -#else -#include -#endif using namespace mp_units::detail; diff --git a/test/static/quantity_point_test.cpp b/test/static/quantity_point_test.cpp index 3ffe3615..1d71957f 100644 --- a/test/static/quantity_point_test.cpp +++ b/test/static/quantity_point_test.cpp @@ -24,15 +24,10 @@ #include #include #include -#ifdef MP_UNITS_MODULES -#include -import mp_units; -#else #include #include #include #include -#endif namespace { diff --git a/test/static/quantity_spec_test.cpp b/test/static/quantity_spec_test.cpp index aea63c5c..46c233fa 100644 --- a/test/static/quantity_spec_test.cpp +++ b/test/static/quantity_spec_test.cpp @@ -21,14 +21,10 @@ // SOFTWARE. #include "test_tools.h" -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include #include #include #include -#endif namespace { diff --git a/test/static/quantity_test.cpp b/test/static/quantity_test.cpp index 69386243..dd1152ba 100644 --- a/test/static/quantity_test.cpp +++ b/test/static/quantity_test.cpp @@ -20,19 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include -// #include "test_tools.h" -#include -#include -#ifdef MP_UNITS_MODULES -#include -import mp_units; -#else +#include #include #include #include -#endif +#include +#include template<> inline constexpr bool mp_units::is_vector = true; diff --git a/test/static/ratio_test.cpp b/test/static/ratio_test.cpp index fd2113bc..5bf9bec0 100644 --- a/test/static/ratio_test.cpp +++ b/test/static/ratio_test.cpp @@ -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 -#endif namespace { diff --git a/test/static/reference_test.cpp b/test/static/reference_test.cpp index fc7bb17e..a1045ce3 100644 --- a/test/static/reference_test.cpp +++ b/test/static/reference_test.cpp @@ -21,9 +21,6 @@ // SOFTWARE. #include "test_tools.h" -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include #include #include @@ -31,7 +28,6 @@ import mp_units; #include #include #include -#endif namespace { diff --git a/test/static/si_test.cpp b/test/static/si_test.cpp index 0599469b..c3005c40 100644 --- a/test/static/si_test.cpp +++ b/test/static/si_test.cpp @@ -21,12 +21,8 @@ // SOFTWARE. #include -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include #include -#endif namespace { diff --git a/test/static/symbol_text_test.cpp b/test/static/symbol_text_test.cpp index 17b4c5dd..ea74dfec 100644 --- a/test/static/symbol_text_test.cpp +++ b/test/static/symbol_text_test.cpp @@ -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 -#endif using namespace mp_units; diff --git a/test/static/test_tools.h b/test/static/test_tools.h index 27587442..ff9348ba 100644 --- a/test/static/test_tools.h +++ b/test/static/test_tools.h @@ -23,12 +23,7 @@ #pragma once #include -#ifdef MP_UNITS_MODULES -#include -import mp_units; -#else #include -#endif template inline constexpr bool is_of_type = std::is_same_v, T>; diff --git a/test/static/type_list_test.cpp b/test/static/type_list_test.cpp index c3d61d52..1c994f35 100644 --- a/test/static/type_list_test.cpp +++ b/test/static/type_list_test.cpp @@ -20,13 +20,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include #include -#endif +#include namespace { diff --git a/test/static/typographic_test.cpp b/test/static/typographic_test.cpp index 71c713d1..9a47469c 100644 --- a/test/static/typographic_test.cpp +++ b/test/static/typographic_test.cpp @@ -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 #include #include -#endif namespace { diff --git a/test/static/unit_symbol_test.cpp b/test/static/unit_symbol_test.cpp index d52a2f8f..c168cb14 100644 --- a/test/static/unit_symbol_test.cpp +++ b/test/static/unit_symbol_test.cpp @@ -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 #include #include -#endif namespace { diff --git a/test/static/unit_test.cpp b/test/static/unit_test.cpp index be2ce8bf..eff9b77f 100644 --- a/test/static/unit_test.cpp +++ b/test/static/unit_test.cpp @@ -21,15 +21,11 @@ // SOFTWARE. #include "test_tools.h" -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include #include #include #include #include -#endif namespace { diff --git a/test/static/usc_test.cpp b/test/static/usc_test.cpp index 42c29389..45248d24 100644 --- a/test/static/usc_test.cpp +++ b/test/static/usc_test.cpp @@ -21,14 +21,10 @@ // SOFTWARE. #include -#ifdef MP_UNITS_MODULES -import mp_units; -#else #include #include #include #include -#endif namespace {