feat: add module mp_units

This commit is contained in:
Johel Ernesto Guerrero Peña
2024-01-06 08:51:00 +01:00
committed by Mateusz Pusz
parent f3ad392123
commit 7cb2099af5
92 changed files with 754 additions and 141 deletions

View File

@ -104,7 +104,7 @@ class MPUnitsConan(ConanFile):
def requirements(self):
self.requires("gsl-lite/0.40.0")
if self._use_libfmt:
self.requires("fmt/10.1.0")
self.requires("fmt/10.1.1")
def build_requirements(self):
if self._build_all:

View File

@ -22,15 +22,25 @@
cmake_minimum_required(VERSION 3.5)
# find dependencies
if(NOT TARGET gsl::gsl-lite)
find_package(gsl-lite CONFIG REQUIRED)
endif()
add_library(example_utils INTERFACE)
target_include_directories(example_utils INTERFACE include)
target_link_libraries(example_utils INTERFACE gsl::gsl-lite)
#
# add_example(target <depependencies>...)
# add_example(target <mp-units-depependencies>...)
#
function(add_example target)
add_executable(${target} ${target}.cpp)
target_link_libraries(${target} PRIVATE ${ARGN})
if(TARGET mp-units::modules)
target_link_libraries(${target} PRIVATE mp-units::modules)
else()
target_link_libraries(${target} PRIVATE ${ARGN})
endif()
endfunction()
add_example(avg_speed mp-units::core-io mp-units::si mp-units::cgs mp-units::usc)
@ -49,7 +59,8 @@ add_example(
add_example(conversion_factor mp-units::core-fmt mp-units::core-io mp-units::si)
add_example(currency mp-units::core-io)
add_example(foot_pound_second mp-units::core-fmt mp-units::international mp-units::imperial)
add_example(glide_computer mp-units::core-fmt mp-units::international mp-units::utility glide_computer_lib)
add_example(glide_computer mp-units::core-fmt mp-units::international mp-units::utility)
target_link_libraries(glide_computer PRIVATE glide_computer_lib)
add_example(hello_units mp-units::core-fmt mp-units::core-io mp-units::si mp-units::usc)
add_example(measurement mp-units::core-io mp-units::si)
add_example(si_constants mp-units::core-fmt mp-units::si)
@ -60,14 +71,9 @@ add_example(
)
add_example(total_energy mp-units::core-io mp-units::si mp-units::natural mp-units::utility)
add_example(
unmanned_aerial_vehicle
mp-units::core-fmt
mp-units::core-io
mp-units::si
mp-units::international
mp-units::utility
example_utils
unmanned_aerial_vehicle mp-units::core-fmt mp-units::core-io mp-units::si mp-units::international mp-units::utility
)
target_link_libraries(unmanned_aerial_vehicle PRIVATE example_utils)
add_subdirectory(glide_computer_lib)
add_subdirectory(kalman_filter)

View File

@ -25,13 +25,17 @@
// !!! renders correctly in the documentation "Examples" section. !!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <exception>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/ostream.h>
#include <mp-units/systems/cgs/cgs.h>
#include <mp-units/systems/international/international.h>
#include <mp-units/systems/isq/isq.h>
#include <mp-units/systems/si/si.h>
#include <exception>
#include <iostream>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#endif
namespace {

View File

@ -20,11 +20,15 @@
physical_quantities
*/
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/math.h> // IWYU pragma: keep
#include <mp-units/ostream.h>
#include <mp-units/systems/isq/electromagnetism.h>
#include <mp-units/systems/si/si.h>
#include <iostream>
#endif
int main()
{

View File

@ -15,6 +15,11 @@
along with this program. If not, see http://www.gnu.org/licenses./
*/
#include <mp-units/bits/fmt_hacks.h>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/ostream.h>
#include <mp-units/systems/iau/iau.h>
@ -24,7 +29,7 @@
#include <mp-units/systems/si/si.h>
#include <mp-units/systems/typographic/typographic.h>
#include <mp-units/systems/usc/usc.h>
#include <iostream>
#endif
namespace {

View File

@ -15,12 +15,17 @@
along with this program. If not, see http://www.gnu.org/licenses./
*/
#include <mp-units/bits/fmt_hacks.h>
#include <iostream>
#include <type_traits>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <mp-units/systems/si/units.h>
#include <iostream>
#include <type_traits>
#endif
/*
get conversion factor from one dimensionally equivalent

View File

@ -20,11 +20,16 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/quantity_spec_macro.h>
#include <iostream>
#include <map>
#ifdef MP_UNITS_MODULES
import mp_units.core_io;
#else
#include <mp-units/ostream.h>
#include <mp-units/quantity.h>
#include <mp-units/quantity_point.h>
#include <iostream>
#include <map>
#endif
using namespace mp_units;

View File

@ -20,14 +20,19 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/bits/fmt_hacks.h>
#include <iostream>
#include <string_view>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/systems/imperial/imperial.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/unit_symbols.h>
#include <iostream>
#include <string_view>
#endif
using namespace mp_units;
using namespace mp_units::international::unit_symbols;

View File

@ -22,10 +22,6 @@
#include "glide_computer_lib.h"
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/chrono.h>
#include <mp-units/math.h>
#include <mp-units/systems/international/international.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <array>
#include <exception>
#include <iostream>
@ -33,6 +29,14 @@
#include <string>
#include <utility>
#include <vector>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/chrono.h>
#include <mp-units/math.h>
#include <mp-units/systems/international/international.h>
#include <mp-units/systems/si/unit_symbols.h>
#endif
namespace {

View File

@ -23,5 +23,10 @@
cmake_minimum_required(VERSION 3.5)
add_library(glide_computer_lib STATIC glide_computer_lib.cpp include/glide_computer_lib.h)
target_link_libraries(glide_computer_lib PRIVATE mp-units::core-fmt PUBLIC mp-units::si mp-units::utility example_utils)
if(TARGET mp-units::modules)
target_link_libraries(glide_computer_lib PUBLIC gsl::gsl-lite mp-units::modules)
else()
target_link_libraries(glide_computer_lib PRIVATE mp-units::core-fmt PUBLIC mp-units::si mp-units::utility)
endif()
target_link_libraries(glide_computer_lib PUBLIC example_utils)
target_include_directories(glide_computer_lib PUBLIC include)

View File

@ -21,10 +21,14 @@
// SOFTWARE.
#include "glide_computer_lib.h"
#include <mp-units/format.h>
#include <iostream>
#include <numeric>
#include <string_view>
#ifdef MP_UNITS_MODULES
import mp_units.core_fmt;
#else
#include <mp-units/format.h>
#endif
namespace glide_computer {

View File

@ -22,11 +22,9 @@
#pragma once
#include <mp-units/quantity_spec_macro.h>
//
#include "geographic.h"
#include <mp-units/chrono.h>
#include <mp-units/math.h> // IWYU pragma: keep
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <algorithm>
#include <array>
#include <initializer_list>
@ -35,6 +33,14 @@
#include <ranges>
#include <string> // IWYU pragma: keep
#include <vector>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/chrono.h>
#include <mp-units/math.h> // IWYU pragma: keep
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/space_and_time.h>
#endif
// An example of a really simplified tactical glide computer
// Simplifications:

View File

@ -25,12 +25,17 @@
// !!! renders correctly in the documentation "Examples" section. !!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <mp-units/bits/fmt_hacks.h>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/ostream.h>
#include <mp-units/systems/international/international.h>
#include <mp-units/systems/isq/isq.h>
#include <mp-units/systems/si/si.h>
#include <iostream>
#endif
using namespace mp_units;

View File

@ -24,6 +24,13 @@
#include "ranged_representation.h"
#include <mp-units/bits/fmt_hacks.h>
#include <compare>
#include <limits>
#include <numbers>
#include <ostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/compare.h>
#include <mp-units/format.h>
#include <mp-units/math.h>
@ -31,10 +38,7 @@
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/units.h>
#include <compare>
#include <limits>
#include <numbers>
#include <ostream>
#endif
namespace geographic {

View File

@ -24,11 +24,15 @@
#include "validated_type.h"
#include <mp-units/bits/external/hacks.h>
#include <mp-units/bits/fmt.h>
#include <mp-units/customization_points.h>
#include <algorithm>
#include <concepts>
#include <type_traits>
#ifdef MP_UNITS_MODULES
import mp_units.core;
#else
#include <mp-units/bits/fmt.h>
#include <mp-units/customization_points.h>
#endif
template<std::movable T, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min,
MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Max>

View File

@ -23,11 +23,16 @@
#pragma once
#include <gsl/gsl-lite.hpp>
#include <mp-units/bits/fmt_hacks.h>
#include <ostream>
#include <utility>
#ifdef MP_UNITS_MODULES
import mp_units.core_fmt;
#else
#include <mp-units/bits/external/hacks.h>
#include <mp-units/bits/fmt.h>
#include <mp-units/customization_points.h>
#include <ostream>
#include <utility>
#endif
inline constexpr struct validated_tag {
} validated;

View File

@ -27,7 +27,11 @@ cmake_minimum_required(VERSION 3.5)
#
function(add_example target)
add_executable(${target} ${target}.cpp)
target_link_libraries(${target} PRIVATE ${ARGN})
if(TARGET mp-units::modules)
target_link_libraries(${target} PRIVATE mp-units::modules)
else()
target_link_libraries(${target} PRIVATE ${ARGN})
endif()
endfunction()
add_example(kalman_filter-example_1 mp-units::core-fmt mp-units::si mp-units::utility)

View File

@ -23,12 +23,16 @@
#pragma once
#include <mp-units/bits/fmt_hacks.h>
#include <tuple>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/math.h>
#include <mp-units/quantity.h>
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <tuple>
#endif
namespace kalman {

View File

@ -21,11 +21,15 @@
// SOFTWARE.
#include "kalman.h"
#include <array>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <array>
#include <iostream>
#endif
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex1

View File

@ -21,11 +21,15 @@
// SOFTWARE.
#include "kalman.h"
#include <array>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <array>
#include <iostream>
#endif
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex2

View File

@ -21,11 +21,15 @@
// SOFTWARE.
#include "kalman.h"
#include <array>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <array>
#include <iostream>
#endif
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex3

View File

@ -21,11 +21,15 @@
// SOFTWARE.
#include "kalman.h"
#include <array>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <array>
#include <iostream>
#endif
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex4

View File

@ -21,12 +21,16 @@
// SOFTWARE.
#include "kalman.h"
#include <array>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/math.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <array>
#include <iostream>
#endif
// Based on: https://www.kalmanfilter.net/kalman1d.html#ex5

View File

@ -21,13 +21,17 @@
// SOFTWARE.
#include "kalman.h"
#include <array>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/math.h>
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/thermodynamics.h>
#include <mp-units/systems/si/si.h>
#include <array>
#include <iostream>
#endif
// Based on: https://www.kalmanfilter.net/kalman1d.html#ex6

View File

@ -21,13 +21,17 @@
// SOFTWARE.
#include "kalman.h"
#include <array>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/math.h>
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/thermodynamics.h>
#include <mp-units/systems/si/si.h>
#include <array>
#include <iostream>
#endif
// Based on: https://www.kalmanfilter.net/kalman1d.html#ex7

View File

@ -21,13 +21,17 @@
// SOFTWARE.
#include "kalman.h"
#include <array>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/math.h>
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/thermodynamics.h>
#include <mp-units/systems/si/si.h>
#include <array>
#include <iostream>
#endif
// Based on: https://www.kalmanfilter.net/kalman1d.html#ex8

View File

@ -20,13 +20,17 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <cmath>
#include <exception>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/ostream.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <mp-units/systems/si/units.h>
#include <cmath>
#include <exception>
#include <iostream>
#endif
namespace {

View File

@ -25,9 +25,14 @@
// !!! renders correctly in the documentation "Examples" section. !!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <mp-units/bits/fmt_hacks.h>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/systems/si/si.h>
#include <iostream>
#endif
template<class T>
requires mp_units::is_scalar<T>

View File

@ -20,11 +20,16 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/bits/fmt_hacks.h>
#include <iostream>
#include <tuple>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/systems/isq/isq.h>
#include <mp-units/systems/si/si.h>
#include <iostream>
#include <tuple>
#endif
// This example implements a table of units provided in the following article
// http://cds.cern.ch/record/1481609/files/978-3-642-18018-7_BookBackMatter.pdf

View File

@ -20,6 +20,16 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/quantity_spec_macro.h>
#include <cassert>
#include <chrono>
#include <iostream>
#include <numbers>
#include <utility>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/chrono.h>
#include <mp-units/format.h>
#include <mp-units/math.h>
@ -28,11 +38,7 @@
#include <mp-units/systems/si/constants.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <mp-units/systems/si/units.h>
#include <cassert>
#include <chrono>
#include <iostream>
#include <numbers>
#include <utility>
#endif
// allows standard gravity (acceleration) and weight (force) to be expressed with scalar representation
// types instead of requiring the usage of Linear Algebra library for this simple example

View File

@ -20,11 +20,15 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/math.h>
#include <mp-units/ostream.h>
#include <mp-units/systems/isq_angle/isq_angle.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <iostream>
#endif
template<class T>
requires mp_units::is_scalar<T>

View File

@ -20,14 +20,18 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <exception>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/math.h>
#include <mp-units/ostream.h>
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/natural/natural.h>
#include <mp-units/systems/si/constants.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <exception>
#include <iostream>
#endif
template<class T>
requires mp_units::is_scalar<T>
@ -56,31 +60,21 @@ void si_example()
std::cout << "\n*** SI units (c = " << c << " = " << c.in(si::metre / s) << ") ***\n";
std::cout << "\n[in `GeV` and `c`]\n"
<< "p = " << p1 << "\n"
<< "m = " << m1 << "\n"
<< "E = " << E << "\n";
std::cout << "\n[in `GeV` and `c`]\n" << "p = " << p1 << "\n" << "m = " << m1 << "\n" << "E = " << E << "\n";
const auto p2 = p1.in(GeV / (m / s));
const auto m2 = m1.in(GeV / pow<2>(m / s));
const auto E2 = total_energy(p2, m2, c).in(GeV);
std::cout << "\n[in `GeV`]\n"
<< "p = " << p2 << "\n"
<< "m = " << m2 << "\n"
<< "E = " << E2 << "\n";
std::cout << "\n[in `GeV`]\n" << "p = " << p2 << "\n" << "m = " << m2 << "\n" << "E = " << E2 << "\n";
const auto p3 = p1.in(kg * m / s);
const auto m3 = m1.in(kg);
const auto E3 = total_energy(p3, m3, c).in(J);
std::cout << "\n[in SI base units]\n"
<< "p = " << p3 << "\n"
<< "m = " << m3 << "\n"
<< "E = " << E3 << "\n";
std::cout << "\n[in SI base units]\n" << "p = " << p3 << "\n" << "m = " << m3 << "\n" << "E = " << E3 << "\n";
std::cout << "\n[converted from SI units back to GeV]\n"
<< "E = " << E3.force_in(GeV) << "\n";
std::cout << "\n[converted from SI units back to GeV]\n" << "E = " << E3.force_in(GeV) << "\n";
}
void natural_example()

View File

@ -21,13 +21,18 @@
// SOFTWARE.
#include "geographic.h"
#include <mp-units/bits/fmt_hacks.h>
#include <cassert>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/ostream.h>
#include <mp-units/quantity_point.h>
#include <mp-units/systems/international/international.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <cassert>
#include <iostream>
#endif
using namespace mp_units;
using namespace geographic;

View File

@ -28,6 +28,9 @@ set(projectPrefix MP_UNITS_)
option(${projectPrefix}AS_SYSTEM_HEADERS "Exports library as system headers" OFF)
message(STATUS "${projectPrefix}AS_SYSTEM_HEADERS: ${${projectPrefix}AS_SYSTEM_HEADERS}")
option(${projectPrefix}BUILD_CXX_MODULES "Add C++ modules to the list of default targets" OFF)
message(STATUS "${projectPrefix}BUILD_CXX_MODULES: ${${projectPrefix}BUILD_CXX_MODULES}")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(AddUnitsModule)
@ -37,7 +40,9 @@ if(${projectPrefix}AS_SYSTEM_HEADERS)
set(unitsAsSystem SYSTEM)
endif()
add_subdirectory(core-macros)
add_subdirectory(core)
add_subdirectory(core-fmt-macros)
add_subdirectory(core-fmt)
add_subdirectory(core-io)
add_subdirectory(systems)
@ -51,6 +56,59 @@ target_link_libraries(
add_library(mp-units::mp-units ALIAS mp-units)
install(TARGETS mp-units EXPORT mp-unitsTargets)
# C++ modules
if(${projectPrefix}BUILD_CXX_MODULES)
add_library(mp-units-core-module)
add_library(mp-units::core-module ALIAS mp-units-core-module)
target_sources(
mp-units-core-module PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES
"mp-units-core.cpp"
)
target_compile_definitions(mp-units-core-module INTERFACE MP_UNITS_MODULES)
target_link_libraries(mp-units-core-module PRIVATE mp-units::core PUBLIC mp-units::core-macros)
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
target_compile_options(mp-units-core-module PUBLIC "-Wno-include-angled-in-module-purview")
endif()
add_library(mp-units-core-fmt-module)
add_library(mp-units::core-fmt-module ALIAS mp-units-core-fmt-module)
target_sources(
mp-units-core-fmt-module PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES
"mp-units-core-fmt.cpp"
)
target_link_libraries(
mp-units-core-fmt-module PRIVATE mp-units::core-fmt PUBLIC mp-units::core-fmt-macros mp-units::core-module
)
add_library(mp-units-core-io-module)
add_library(mp-units::core-io-module ALIAS mp-units-core-io-module)
target_sources(
mp-units-core-io-module PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES
"mp-units-core-io.cpp"
)
target_link_libraries(mp-units-core-io-module PRIVATE mp-units::core-io PUBLIC mp-units::core-module)
add_library(mp-units-systems-module)
add_library(mp-units::systems-module ALIAS mp-units-systems-module)
target_sources(
mp-units-systems-module PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES
"mp-units-systems.cpp"
)
target_link_libraries(
mp-units-systems-module PRIVATE mp-units::systems mp-units::utility PUBLIC mp-units::core-module
)
add_library(mp-units-modules)
add_library(mp-units::modules ALIAS mp-units-modules)
target_sources(
mp-units-modules PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES "mp-units.cpp"
)
target_link_libraries(
mp-units-modules PUBLIC mp-units::core-module mp-units::core-fmt-module mp-units::core-io-module
mp-units::systems-module
)
endif()
# local build
export(EXPORT mp-unitsTargets NAMESPACE mp-units::)
configure_file("mp-unitsConfig.cmake" "." COPYONLY)

View File

@ -0,0 +1,45 @@
# 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.
cmake_minimum_required(VERSION 3.19)
# core-fmt-macros library definition
add_library(mp-units-core-fmt-macros INTERFACE include/mp-units/bits/fmt_hacks.h)
target_include_directories(
mp-units-core-fmt-macros ${unitsAsSystem} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(mp-units-core-fmt-macros INTERFACE mp-units::core-macros)
if(${projectPrefix}USE_LIBFMT)
if(NOT TARGET fmt::fmt)
find_package(fmt CONFIG REQUIRED)
endif()
target_link_libraries(mp-units-core-fmt-macros INTERFACE fmt::fmt)
endif()
set_target_properties(mp-units-core-fmt-macros PROPERTIES EXPORT_NAME core-fmt-macros)
add_library(mp-units::core-fmt-macros ALIAS mp-units-core-fmt-macros)
# installation
install(TARGETS mp-units-core-fmt-macros EXPORT mp-unitsTargets)
install(DIRECTORY include/mp-units TYPE INCLUDE)

View File

@ -27,6 +27,8 @@
//
// For the license information refer to format.h.
#pragma once
#include <mp-units/bits/external/hacks.h>
#ifndef MP_UNITS_USE_LIBFMT

View File

@ -27,6 +27,7 @@ message(STATUS "${projectPrefix}USE_LIBFMT: ${${projectPrefix}USE_LIBFMT}")
add_units_module(core-fmt DEPENDENCIES mp-units::core HEADERS include/mp-units/format.h)
target_compile_definitions(mp-units-core-fmt INTERFACE ${projectPrefix}USE_LIBFMT=$<BOOL:${${projectPrefix}USE_LIBFMT}>)
target_link_libraries(mp-units-core-fmt INTERFACE mp-units::core-fmt-macros)
if(${projectPrefix}USE_LIBFMT)
if(NOT TARGET fmt::fmt)

View 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.
cmake_minimum_required(VERSION 3.19)
# core-macros library definition
add_library(
mp-units-core-macros INTERFACE include/mp-units/bits/external/hacks.h include/mp-units/quantity_spec_macro.h
)
target_compile_features(mp-units-core-macros INTERFACE cxx_std_20)
target_include_directories(
mp-units-core-macros ${unitsAsSystem} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
set_target_properties(mp-units-core-macros PROPERTIES EXPORT_NAME core-macros)
add_library(mp-units::core-macros ALIAS mp-units-core-macros)
# installation
install(TARGETS mp-units-core-macros EXPORT mp-unitsTargets)
install(DIRECTORY include/mp-units TYPE INCLUDE)

View File

@ -0,0 +1,50 @@
// 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.
#pragma once
// core
#include <gsl/gsl-lite.hpp>
#include <mp-units/bits/external/hacks.h>
#include <array>
#include <compare>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <numbers>
#include <numeric>
#include <optional>
#include <ranges>
#include <string>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <utility>
// utility
#include <chrono>
#include <cmath>
#include <random>

View File

@ -0,0 +1,37 @@
// 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.
#pragma once
#ifdef __cpp_explicit_this_parameter
#define QUANTITY_SPEC(name, ...) \
inline constexpr struct name : ::mp_units::quantity_spec<__VA_ARGS__> { \
} name
#else
#define QUANTITY_SPEC(name, ...) \
inline constexpr struct name : ::mp_units::quantity_spec<name, __VA_ARGS__> { \
} name
#endif

View File

@ -33,7 +33,6 @@ add_library(
INTERFACE
include/mp-units/bits/external/algorithm.h
include/mp-units/bits/external/fixed_string.h
include/mp-units/bits/external/hacks.h
include/mp-units/bits/external/math_concepts.h
include/mp-units/bits/external/prime.h
include/mp-units/bits/external/type_list.h
@ -44,6 +43,7 @@ add_library(
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/math_core.h
include/mp-units/bits/quantity_cast.h
include/mp-units/bits/quantity_concepts.h
include/mp-units/bits/quantity_point_concepts.h
@ -67,8 +67,7 @@ add_library(
include/mp-units/system_reference.h
include/mp-units/unit.h
)
target_compile_features(mp-units-core INTERFACE cxx_std_20)
target_link_libraries(mp-units-core INTERFACE gsl::gsl-lite)
target_link_libraries(mp-units-core INTERFACE gsl::gsl-lite mp-units::core-macros)
target_include_directories(
mp-units-core ${unitsAsSystem} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>

View File

@ -22,6 +22,7 @@
#pragma once
#include <mp-units/bits/math_core.h>
#include <mp-units/concepts.h>
#include <mp-units/customization_points.h>
#include <mp-units/dimension.h>

View File

@ -32,6 +32,7 @@
#include <mp-units/bits/reference_concepts.h>
#include <mp-units/bits/representation_concepts.h>
#include <mp-units/dimension.h>
#include <mp-units/quantity_spec_macro.h>
#include <tuple>
namespace mp_units {
@ -364,20 +365,6 @@ struct quantity_spec<Self, QS, Eq, Args...> : quantity_spec<Self, QS, Args...> {
static constexpr quantity_character character = detail::quantity_character_init<Args...>(Eq.character);
};
#ifdef __cpp_explicit_this_parameter
#define QUANTITY_SPEC(name, ...) \
inline constexpr struct name : ::mp_units::quantity_spec<__VA_ARGS__> { \
} name
#else
#define QUANTITY_SPEC(name, ...) \
inline constexpr struct name : ::mp_units::quantity_spec<name, __VA_ARGS__> { \
} name
#endif
/**
* @brief A specification of a derived quantity

13
src/mp-units-core-fmt.cpp Normal file
View File

@ -0,0 +1,13 @@
module;
#include <mp-units/bits/core-gmf.h>
#include <mp-units/bits/fmt_hacks.h>
export module mp_units.core_fmt;
export import mp_units.core;
export
{
#include <mp-units/format.h>
}

13
src/mp-units-core-io.cpp Normal file
View File

@ -0,0 +1,13 @@
module;
#include <mp-units/bits/core-gmf.h>
#include <sstream>
export module mp_units.core_io;
export import mp_units.core;
export
{
#include <mp-units/ostream.h>
}

11
src/mp-units-core.cpp Normal file
View File

@ -0,0 +1,11 @@
module;
#include <mp-units/bits/core-gmf.h>
export module mp_units.core;
export
{
// core
#include <mp-units/core.h>
}

32
src/mp-units-systems.cpp Normal file
View File

@ -0,0 +1,32 @@
module;
#include <mp-units/bits/core-gmf.h>
#include <mp-units/quantity_spec_macro.h>
export module mp_units.systems;
export import mp_units.core;
export
{
// systems
#include <mp-units/systems/angular/angular.h>
#include <mp-units/systems/cgs/cgs.h>
#include <mp-units/systems/hep/hep.h>
#include <mp-units/systems/iau/iau.h>
#include <mp-units/systems/iec80000/iec80000.h>
#include <mp-units/systems/imperial/imperial.h>
#include <mp-units/systems/international/international.h>
#include <mp-units/systems/isq/isq.h>
#include <mp-units/systems/isq_angle/isq_angle.h>
#include <mp-units/systems/natural/natural.h>
#include <mp-units/systems/si/si.h>
#include <mp-units/systems/typographic/typographic.h>
#include <mp-units/systems/usc/usc.h>
// utility
#include <mp-units/chrono.h>
#include <mp-units/compare.h>
#include <mp-units/math.h>
#include <mp-units/random.h>
}

8
src/mp-units.cpp Normal file
View File

@ -0,0 +1,8 @@
module;
export module mp_units;
export import mp_units.core;
export import mp_units.core_fmt;
export import mp_units.core_io;
export import mp_units.systems;

View File

@ -29,5 +29,5 @@
// This header is intentionally empty and just include other headers
// `math.h` is just a convenience wrapper for not modular code
// With C++20 modules:
// - math_core will be a part of the mp_units.core module
// - math_si and math_angular will be provided with the mp_units.systems module
// - math_core is be a part of the mp_units.core module
// - math_si and math_angular is provided with the mp_units.systems module

View File

@ -25,7 +25,12 @@ cmake_minimum_required(VERSION 3.5)
find_package(Catch2 3 CONFIG REQUIRED)
add_executable(unit_tests_runtime distribution_test.cpp fmt_test.cpp math_test.cpp)
target_link_libraries(unit_tests_runtime PRIVATE mp-units::mp-units Catch2::Catch2WithMain)
if(TARGET mp-units::modules)
target_link_libraries(unit_tests_runtime PRIVATE mp-units::modules)
else()
target_link_libraries(unit_tests_runtime PRIVATE mp-units::mp-units)
endif()
target_link_libraries(unit_tests_runtime PRIVATE Catch2::Catch2WithMain)
if(${projectPrefix}BUILD_LA)
find_package(wg21_linear_algebra CONFIG REQUIRED)

View File

@ -21,9 +21,14 @@
// SOFTWARE.
#include <catch2/matchers/catch_matchers_templated.hpp>
#include <mp-units/bits/fmt_hacks.h>
#include <algorithm>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/format.h>
#include <mp-units/quantity.h>
#include <algorithm>
#endif
namespace mp_units {

View File

@ -21,14 +21,18 @@
// SOFTWARE.
#include <catch2/catch_test_macros.hpp>
#include <mp-units/ostream.h>
#include <mp-units/random.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <mp-units/systems/si/units.h>
#include <array>
#include <initializer_list>
#include <random>
#include <vector>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/ostream.h>
#include <mp-units/random.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <mp-units/systems/si/units.h>
#endif
using namespace mp_units;

View File

@ -22,6 +22,13 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_exception.hpp>
#include <mp-units/bits/fmt_hacks.h>
#include <iomanip>
#include <limits>
#include <locale>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/customization_points.h>
#include <mp-units/format.h>
#include <mp-units/ostream.h>
@ -29,9 +36,7 @@
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/si.h>
#include <iomanip>
#include <limits>
#include <locale>
#endif
template<class T>
requires mp_units::is_scalar<T>

View File

@ -21,6 +21,12 @@
// SOFTWARE.
#include <catch2/catch_test_macros.hpp>
#include <mp-units/bits/fmt_hacks.h>
#include <cmath>
#include <matrix>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/customization_points.h>
#include <mp-units/format.h>
#include <mp-units/math.h>
@ -28,8 +34,7 @@
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/si.h>
#include <cmath>
#include <matrix>
#endif
template<typename Rep = double>
using vector = STD_LA::fixed_size_column_vector<Rep, 3>;

View File

@ -22,13 +22,17 @@
#include "almost_equals.h"
#include <catch2/catch_all.hpp>
#include <limits>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/math.h>
#include <mp-units/ostream.h>
#include <mp-units/systems/angular/angular.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <mp-units/systems/si/units.h>
#include <limits>
#endif
using namespace mp_units;
using namespace mp_units::si::unit_symbols;

View File

@ -23,7 +23,11 @@
cmake_minimum_required(VERSION 3.5)
add_library(unit_tests_static_truncating quantity_test.cpp)
target_link_libraries(unit_tests_static_truncating PRIVATE mp-units::mp-units)
if(TARGET mp-units::modules)
target_link_libraries(unit_tests_static_truncating PRIVATE mp-units::modules)
else()
target_link_libraries(unit_tests_static_truncating PRIVATE mp-units::mp-units)
endif()
target_compile_options(
unit_tests_static_truncating PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/wd4242 /wd4244,-Wno-conversion>
)
@ -64,5 +68,9 @@ add_library(
usc_test.cpp
)
target_link_libraries(unit_tests_static PRIVATE mp-units::mp-units)
target_link_libraries(unit_tests_static PRIVATE unit_tests_static_truncating mp-units::mp-units)
if(TARGET mp-units::modules)
target_link_libraries(unit_tests_static PRIVATE mp-units::modules)
else()
target_link_libraries(unit_tests_static PRIVATE mp-units::mp-units)
endif()
target_link_libraries(unit_tests_static PRIVATE unit_tests_static_truncating)

View File

@ -20,8 +20,12 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/systems/isq_angle/isq_angle.h>
#include <numbers>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/systems/isq_angle/isq_angle.h>
#endif
namespace {

View File

@ -21,10 +21,14 @@
// 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>

View File

@ -21,11 +21,16 @@
// 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/chrono.h>
#include <mp-units/quantity_point.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <ratio>
#endif
namespace {

View File

@ -20,8 +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/compare.h>
#include <mp-units/systems/si/si.h>
#endif
namespace {

View File

@ -20,16 +20,20 @@
// 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/chrono.h>
#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>
#include <chrono>
#include <complex>
#include <optional>
#include <string>
#endif
template<typename T>
inline constexpr bool mp_units::is_scalar<std::complex<T>> = true;

View File

@ -20,11 +20,15 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <ostream>
#include <type_traits>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <units/generic/dimensionless.h>
#include <units/isq/si/length.h>
#include <units/isq/si/prefixes.h>
#include <ostream>
#include <type_traits>
#endif
namespace {

View File

@ -20,8 +20,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/systems/si/units.h>
#include <mp-units/bits/external/hacks.h>
#include <concepts>
#include <type_traits>
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/systems/si/units.h>
#endif
namespace {

View File

@ -21,11 +21,15 @@
// 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 {

View File

@ -20,7 +20,11 @@
// 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;

View File

@ -20,9 +20,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/quantity_spec_macro.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 {

View File

@ -20,10 +20,14 @@
// 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>

View File

@ -20,9 +20,13 @@
// 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/si/unit_symbols.h>
#endif
/* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */

View File

@ -20,10 +20,14 @@
// 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 **************** */

View File

@ -20,9 +20,13 @@
// 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 {

View File

@ -20,12 +20,16 @@
// 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>

View File

@ -20,8 +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/systems/isq_angle/isq_angle.h>
#include <mp-units/systems/si/unit_symbols.h>
#endif
namespace {

View File

@ -20,9 +20,13 @@
// 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 {

View File

@ -20,9 +20,13 @@
// 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 <units/bits/magnitude.h>
#include <units/bits/ratio.h>
#include <type_traits>
#endif
using namespace units;
using namespace units::detail;

View File

@ -20,11 +20,15 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// 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>
#include <optional>
#endif
namespace {

View File

@ -20,8 +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/natural/natural.h>
#endif
template<class T>
requires mp_units::is_scalar<T>

View File

@ -20,9 +20,13 @@
// 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;

View File

@ -21,14 +21,19 @@
// SOFTWARE.
#include "test_tools.h"
#include <limits>
#include <type_traits>
#include <utility>
#ifdef MP_UNITS_MODULES
#include <chrono>
import mp_units;
#else
#include <mp-units/chrono.h>
#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>
#include <limits>
#include <type_traits>
#include <utility>
#endif
namespace {

View File

@ -21,10 +21,14 @@
// 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 {

View File

@ -21,12 +21,17 @@
// SOFTWARE.
#include "test_tools.h"
#include <limits>
#include <utility>
#ifdef MP_UNITS_MODULES
#include <chrono>
import mp_units;
#else
#include <mp-units/chrono.h>
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/si.h>
#include <limits>
#include <utility>
#endif
template<>
inline constexpr bool mp_units::is_vector<int> = true;

View File

@ -20,7 +20,11 @@
// 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 {

View File

@ -21,6 +21,9 @@
// 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>
@ -28,6 +31,7 @@
#include <mp-units/system_reference.h>
#include <mp-units/systems/si/prefixes.h>
#include <mp-units/unit.h>
#endif
namespace {

View File

@ -20,8 +20,13 @@
// 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/math.h>
#include <mp-units/systems/si/si.h>
#endif
namespace {

View File

@ -20,7 +20,11 @@
// 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;

View File

@ -22,8 +22,13 @@
#pragma once
#include <mp-units/quantity_spec.h>
#include <type_traits>
#ifdef MP_UNITS_MODULES
#include <mp-units/quantity_spec_macro.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>;

View File

@ -20,8 +20,13 @@
// 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
namespace {

View File

@ -20,9 +20,13 @@
// 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 {

View File

@ -20,9 +20,13 @@
// 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 {

View File

@ -21,11 +21,15 @@
// 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 {

View File

@ -20,10 +20,15 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// 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 {