feat: import std; support added

Resolves #595
This commit is contained in:
Mateusz Pusz
2024-07-16 17:36:00 +02:00
parent a4691825ee
commit b870b85c25
93 changed files with 425 additions and 9 deletions

View File

@ -56,6 +56,7 @@ class MPUnitsConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
options = {
"cxx_modules": [True, False],
"import_std": [True, False],
"std_format": [True, False],
"string_view_ret": [True, False],
"no_crtp": [True, False],
@ -64,6 +65,7 @@ class MPUnitsConan(ConanFile):
}
default_options = {
# "cxx_modules" default set in config_options()
# "import_std" default set in config_options()
# "std_format" default set in config_options()
# "string_view_ret" default set in config_options()
# "no_crtp" default set in config_options()
@ -108,6 +110,10 @@ class MPUnitsConan(ConanFile):
"min_cppstd": "20",
"compiler": {"gcc": "", "clang": "17", "apple-clang": "", "msvc": ""},
},
"import_std": {
"min_cppstd": "23",
"compiler": {"gcc": "", "clang": "18", "apple-clang": "", "msvc": ""},
},
"static_constexpr_vars_in_constexpr_func": {
"min_cppstd": "23",
"compiler": {"gcc": "13", "clang": "17", "apple-clang": "", "msvc": ""},
@ -128,6 +134,7 @@ class MPUnitsConan(ConanFile):
return {
"std_format": "std_format",
"cxx_modules": "cxx_modules",
"import_std": "import_std",
"string_view_ret": "static_constexpr_vars_in_constexpr_func",
"no_crtp": "explicit_this",
}
@ -210,7 +217,7 @@ class MPUnitsConan(ConanFile):
self.requires("fmt/11.0.1")
def build_requirements(self):
self.tool_requires("cmake/[>=3.29 <4]")
self.tool_requires("cmake/[>=3.30 <4]")
if self._build_all:
if not self.options.freestanding:
self.test_requires("catch2/3.6.0")
@ -226,6 +233,16 @@ class MPUnitsConan(ConanFile):
raise ConanInvalidConfiguration(
"'contracts' should be set to 'none' for a freestanding build"
)
# mixing of `import std;` and regular header files includes does not work for now
if self.options.import_std:
if self.options.contracts != "none":
raise ConanInvalidConfiguration(
"'contracts' should be set to 'none' to use `import std;`"
)
if not self.options.std_format:
raise ConanInvalidConfiguration(
"'std_format' should be enabled to use `import std;`"
)
def layout(self):
cmake_layout(self)
@ -242,6 +259,12 @@ class MPUnitsConan(ConanFile):
if self.options.cxx_modules:
tc.cache_variables["CMAKE_CXX_SCAN_FOR_MODULES"] = True
tc.cache_variables["MP_UNITS_BUILD_CXX_MODULES"] = True
if self.options.import_std:
tc.cache_variables["CMAKE_CXX_MODULE_STD"] = True
# Current experimental support according to `Help/dev/experimental.rst`
tc.cache_variables[
"CMAKE_EXPERIMENTAL_CXX_IMPORT_STD"
] = "0e5b6991-d74f-4b3d-a41c-cf096e0b2508"
if self.options.freestanding:
tc.cache_variables["MP_UNITS_API_FREESTANDING"] = True
else:

View File

@ -237,6 +237,14 @@ tools.build:compiler_executables={"c": "gcc-12", "cpp": "g++-12"}
[conan C++ modules support]: https://github.com/mpusz/mp-units/releases/tag/v2.2.0
[`import_std`](#import_std){ #import_std }
: [:octicons-tag-24: 2.3.0][conan import std support] · :octicons-milestone-24: `True`/`False` (Default: automatically determined from settings)
Enables `import std;` usage.
[conan import std support]: https://github.com/mpusz/mp-units/releases/tag/v2.3.0
[`std_format`](#std_format){ #std_format }
: [:octicons-tag-24: 2.2.0][conan std::format support] · :octicons-milestone-24: `True`/`False` (Default: automatically determined from settings)
@ -338,7 +346,14 @@ tools.build:compiler_executables={"c": "gcc-12", "cpp": "g++-12"}
Adds C++ modules to the list of default targets.
[build_cxx_modules support]: https://github.com/mpusz/mp-units/releases/tag/v2.2.0
[`MP_UNITS_BUILD_IMPORT_STD`](#MP_UNITS_BUILD_IMPORT_STD){ #MP_UNITS_BUILD_IMPORT_STD }
: [:octicons-tag-24: 2.3.0][cmake import std support] · :octicons-milestone-24: `ON`/`OFF` (Default: `OFF`)
Enables `import std;` usage.
[cmake import std support]: https://github.com/mpusz/mp-units/releases/tag/v2.3.0
[`MP_UNITS_API_STD_FORMAT`](#MP_UNITS_API_STD_FORMAT){ #MP_UNITS_API_STD_FORMAT }

View File

@ -25,8 +25,12 @@
// !!! renders correctly in the documentation "Examples" section. !!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <exception>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -20,7 +20,11 @@
physical_quantities
*/
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -17,7 +17,11 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -17,9 +17,13 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <concepts>
#include <iostream>
#include <string>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -21,11 +21,15 @@
// SOFTWARE.
#include <mp-units/compat_macros.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <concepts>
#include <iostream>
#include <map>
#include <string_view>
#include <utility>
#endif
#ifdef MP_UNITS_MODULES
import mp_units.core;
#else

View File

@ -22,9 +22,13 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <iostream>
#include <string>
#include <string_view>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -25,6 +25,9 @@
#include <mp-units/bits/hacks.h>
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <chrono>
#include <concepts>
@ -33,6 +36,7 @@
#include <ranges>
#include <string>
#include <utility>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,10 +22,14 @@
#include "glide_computer_lib.h"
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <functional>
#include <iostream>
#include <numeric>
#include <string_view>
#endif
#ifdef MP_UNITS_MODULES
import mp_units.core;
#else

View File

@ -25,6 +25,9 @@
#include <mp-units/compat_macros.h>
//
#include "geographic.h"
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <algorithm>
#include <array>
#include <chrono>
@ -35,6 +38,7 @@
#include <ranges>
#include <string> // IWYU pragma: keep
#include <vector>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -27,8 +27,12 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <iomanip>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -25,10 +25,14 @@
#include "ranged_representation.h"
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <compare>
#include <limits>
#include <numbers>
#include <ostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -26,9 +26,13 @@
#include <mp-units/bits/hacks.h>
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <algorithm>
#include <concepts>
#include <type_traits>
#endif
#ifdef MP_UNITS_MODULES
import mp_units.core;
#else

View File

@ -26,9 +26,13 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/contracts.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <compare> // IWYU pragma: export
#include <ostream>
#include <utility>
#endif
#ifdef MP_UNITS_MODULES
import mp_units.core;
#else

View File

@ -24,9 +24,13 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <algorithm>
#include <locale>
#include <tuple>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,8 +22,12 @@
#include "kalman.h"
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,8 +22,12 @@
#include "kalman.h"
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,8 +22,12 @@
#include "kalman.h"
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,8 +22,12 @@
#include "kalman.h"
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,8 +22,12 @@
#include "kalman.h"
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,8 +22,12 @@
#include "kalman.h"
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,8 +22,12 @@
#include "kalman.h"
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,8 +22,12 @@
#include "kalman.h"
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,11 +22,15 @@
#include <mp-units/bits/hacks.h>
#include <mp-units/compat_macros.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cmath>
#include <compare> // IWYU pragma: export
#include <exception>
#include <iostream>
#include <utility>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -27,7 +27,11 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -22,8 +22,12 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <iostream>
#include <tuple>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -23,10 +23,14 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#include <cassert>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <chrono>
#include <iostream>
#include <numbers>
#include <string>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

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_IMPORT_STD
import std;
#else
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

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_IMPORT_STD
import std;
#else
#include <exception>
#include <iostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -25,9 +25,13 @@
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#include <cassert>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cstdint>
#include <iostream>
#include <string>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -38,9 +38,11 @@ check_libcxx_in_use(${projectPrefix}LIBCXX)
# project build options
option(${projectPrefix}BUILD_AS_SYSTEM_HEADERS "Exports library as system headers" OFF)
option(${projectPrefix}BUILD_CXX_MODULES "Add C++ modules to the list of default targets" OFF)
option(${projectPrefix}BUILD_IMPORT_STD "Enable `import std;` usage" OFF)
message(STATUS "${projectPrefix}BUILD_AS_SYSTEM_HEADERS: ${${projectPrefix}BUILD_AS_SYSTEM_HEADERS}")
message(STATUS "${projectPrefix}BUILD_CXX_MODULES: ${${projectPrefix}BUILD_CXX_MODULES}")
message(STATUS "${projectPrefix}BUILD_IMPORT_STD: ${${projectPrefix}BUILD_IMPORT_STD}")
if(${projectPrefix}BUILD_AS_SYSTEM_HEADERS)
set(${projectPrefix}_AS_SYSTEM SYSTEM)
@ -124,6 +126,15 @@ else()
set(${projectPrefix}TARGET_SCOPE "INTERFACE")
endif()
if(${projectPrefix}BUILD_CXX_MODULES)
if(CMAKE_VERSION VERSION_LESS "3.30")
message(FATAL_ERROR "CMake versions before 3.30 do not support `import std;` properly")
endif()
if(CMAKE_CXX_STANDARD LESS 23)
message(FATAL_ERROR "`import std;` requires at lease C++23")
endif()
endif()
# components/modules
include(MPUnitsContracts)
add_subdirectory(core)

View File

@ -125,6 +125,14 @@ if(${projectPrefix}BUILD_CXX_MODULES)
endif()
endif()
if(${projectPrefix}BUILD_IMPORT_STD)
target_compile_definitions(mp-units-core PUBLIC ${projectPrefix}IMPORT_STD)
# https://github.com/llvm/llvm-project/issues/75057
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
target_compile_options(mp-units-core PUBLIC "-Wno-deprecated-declarations")
endif()
endif()
# UTF-8 source and execution character set
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(

View File

@ -43,6 +43,9 @@
#include <tuple>
#include <type_traits>
#include <utility>
#if __cpp_lib_text_encoding
#include <text_encoding>
#endif
#if MP_UNITS_HOSTED
#include <mp-units/ext/format.h>
@ -53,7 +56,3 @@
#include <sstream>
#include <string>
#endif
#if __cpp_lib_text_encoding
#include <text_encoding>
#endif

View File

@ -37,12 +37,16 @@
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/ext/contracts.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <concepts>
#include <cstdint>
#include <limits>
#include <string_view>
#endif
#endif
// most of the below code is based on/copied from fmtlib

View File

@ -28,10 +28,14 @@
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/ext/contracts.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <compare> // IWYU pragma: export
#include <cstdint>
#include <numeric>
#endif
#endif
namespace mp_units::detail {

View File

@ -29,8 +29,12 @@
#include <mp-units/framework/symbol_text.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cstdint>
#endif
#endif
namespace mp_units::detail {

View File

@ -25,10 +25,14 @@
#include <mp-units/bits/hacks.h> // IWYU pragma: keep
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cstddef>
#include <type_traits>
#include <utility>
#endif
#endif
MP_UNITS_DIAGNOSTIC_PUSH
MP_UNITS_DIAGNOSTIC_IGNORE_EXPR_ALWAYS_TF

View File

@ -29,10 +29,14 @@
#include <mp-units/bits/hacks.h> // IWYU pragma: keep
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <compare>
#include <initializer_list>
#include <iterator>
#endif
#endif
namespace mp_units::detail {

View File

@ -33,17 +33,24 @@
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/ext/contracts.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <compare> // IWYU pragma: export
#include <concepts>
#include <cstddef>
#include <cstdlib>
#include <ranges>
#include <string_view>
#endif // MP_UNITS_IMPORT_STD
#if MP_UNITS_HOSTED
#include <mp-units/ext/format.h>
#ifndef MP_UNITS_IMPORT_STD
#include <ostream>
#endif
#endif
#endif // MP_UNITS_HOSTED
#endif // MP_UNITS_IN_MODULE_INTERFACE
MP_UNITS_EXPORT
namespace mp_units {

View File

@ -36,7 +36,11 @@ MP_UNITS_DIAGNOSTIC_IGNORE_SHADOW
#include <fmt/format.h>
MP_UNITS_DIAGNOSTIC_POP
#else
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <format>
#endif
#endif
#endif

View File

@ -28,10 +28,14 @@
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/ext/contracts.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <concepts>
#include <cstddef>
#include <ranges>
#endif
#endif
// NOLINTBEGIN(*-avoid-c-arrays)
#pragma once

View File

@ -28,6 +28,9 @@
#include <mp-units/ext/algorithm.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <cstddef>
#include <cstdint>
@ -35,6 +38,7 @@
#include <optional>
#include <tuple>
#endif
#endif
namespace mp_units::detail {

View File

@ -6,8 +6,12 @@
#pragma once
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <string_view>
#endif
#endif
namespace mp_units::detail {

View File

@ -26,9 +26,13 @@
#include <mp-units/bits/module_macros.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <type_traits>
#include <utility>
#endif
#endif
namespace mp_units {

View File

@ -35,8 +35,12 @@
#include <mp-units/framework/unit.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <locale>
#endif
#endif
namespace mp_units::detail {

View File

@ -26,8 +26,12 @@
#include <mp-units/bits/module_macros.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <compare>
#endif
#endif
MP_UNITS_EXPORT
namespace mp_units {

View File

@ -28,8 +28,12 @@
#include <mp-units/framework/representation_concepts.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <type_traits>
#endif
#endif
namespace mp_units {

View File

@ -27,10 +27,14 @@
#include <mp-units/ext/type_traits.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <concepts>
#include <limits>
#include <type_traits>
#endif
#endif
namespace mp_units {

View File

@ -37,6 +37,9 @@
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/ext/contracts.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <cstdint>
#include <iterator>
@ -44,7 +47,8 @@
#if MP_UNITS_HOSTED
#include <string>
#endif
#endif
#endif // MP_UNITS_IMPORT_STD
#endif // MP_UNITS_IN_MODULE_INTERFACE
namespace mp_units {

View File

@ -28,9 +28,13 @@
#include <mp-units/ext/type_traits.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cstdint>
#include <functional>
#endif
#endif
namespace mp_units {

View File

@ -36,12 +36,16 @@
#include <mp-units/framework/symbol_text.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <concepts>
#include <cstdint>
#include <cstdlib>
#include <numbers>
#include <optional>
#endif
#endif
namespace mp_units {

View File

@ -39,9 +39,13 @@
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/ext/contracts.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <compare> // IWYU pragma: export
#include <utility>
#endif
#endif
namespace mp_units {

View File

@ -29,8 +29,12 @@
#include <mp-units/framework/reference.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <type_traits>
#endif
#endif
MP_UNITS_EXPORT
namespace mp_units {

View File

@ -31,8 +31,12 @@
#include <mp-units/framework/quantity_point_concepts.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <compare> // IWYU pragma: export
#endif
#endif
namespace mp_units {

View File

@ -38,11 +38,15 @@
#include <mp-units/framework/representation_concepts.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <concepts>
#include <cstdint>
#include <tuple>
#include <type_traits>
#endif
#endif
namespace mp_units {

View File

@ -31,8 +31,12 @@
#include <mp-units/framework/representation_concepts.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cstdint>
#endif
#endif
namespace mp_units {

View File

@ -27,11 +27,15 @@
#include <mp-units/framework/customization_points.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <concepts>
#include <cstdint>
#include <functional>
#include <type_traits>
#endif
#endif
namespace mp_units {

View File

@ -32,15 +32,23 @@
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/ext/contracts.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <compare> // IWYU pragma: export
#include <cstddef>
#include <cstdint>
#endif
#endif
#if __cpp_lib_text_encoding
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <text_encoding>
#endif
#endif
static_assert(std::text_encoding::literal().mib() == std::text_encoding::id::UTF8);
#endif

View File

@ -43,6 +43,9 @@
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/ext/contracts.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <cstdint>
#include <iterator>
@ -50,7 +53,8 @@
#if MP_UNITS_HOSTED
#include <string>
#endif
#endif
#endif // MP_UNITS_IMPORT_STD
#endif // MP_UNITS_IN_MODULE_INTERFACE
namespace mp_units {

View File

@ -32,10 +32,14 @@
#include <mp-units/framework/value_cast.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cmath>
#include <cstdint>
#include <limits>
#endif
#endif
MP_UNITS_EXPORT
namespace mp_units {

View File

@ -30,9 +30,13 @@
#include <mp-units/framework/unit.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cstdint>
#include <sstream>
#endif
#endif
namespace mp_units {

View File

@ -26,9 +26,11 @@
#include <mp-units/framework/quantity.h>
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#ifndef MP_UNITS_IMPORT_STD
#include <functional>
#include <random>
#endif
#endif
namespace mp_units {

View File

@ -22,10 +22,16 @@
module;
#ifndef MP_UNITS_IMPORT_STD
#include <mp-units/bits/core_gmf.h>
#endif
export module mp_units.core;
#ifdef MP_UNITS_IMPORT_STD
import std;
#endif
#define MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/compat_macros.h>

View File

@ -32,8 +32,12 @@
#include <mp-units/framework/quantity.h>
#include <mp-units/framework/unit.h>
#include <mp-units/framework/value_cast.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cmath>
#endif
#endif
MP_UNITS_EXPORT

View File

@ -32,8 +32,12 @@
#ifndef MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/framework/customization_points.h>
#include <mp-units/framework/quantity_point.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <chrono>
#endif
#endif
namespace mp_units {

View File

@ -33,8 +33,12 @@
#include <mp-units/framework/quantity.h>
#include <mp-units/framework/unit.h>
#include <mp-units/framework/value_cast.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cmath>
#endif
#endif
MP_UNITS_EXPORT

View File

@ -22,12 +22,17 @@
module;
#ifndef MP_UNITS_IMPORT_STD
#include <mp-units/bits/core_gmf.h>
#include <chrono>
#endif
export module mp_units.systems;
export import mp_units.core;
#ifdef MP_UNITS_IMPORT_STD
import std;
#endif
#define MP_UNITS_IN_MODULE_INTERFACE

View File

@ -21,7 +21,11 @@
// SOFTWARE.
#include <catch2/catch_test_macros.hpp>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <atomic>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -21,12 +21,16 @@
// SOFTWARE.
#include <catch2/catch_test_macros.hpp>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <cstddef>
#include <cstdint>
#include <initializer_list>
#include <random>
#include <vector>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -24,8 +24,12 @@
#include <catch2/matchers/catch_matchers_exception.hpp>
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <sstream>
#include <string_view>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -25,6 +25,9 @@
#include <catch2/matchers/catch_matchers_exception.hpp>
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cstdint>
#include <iomanip>
#include <limits>
@ -32,6 +35,7 @@
#include <sstream>
#include <string>
#include <string_view>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -23,8 +23,12 @@
#include <catch2/catch_test_macros.hpp>
#include <mp-units/compat_macros.h>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <matrix>
#include <ostream>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -23,7 +23,11 @@
#include "almost_equals.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <limits>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -25,8 +25,12 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <mp-units/ext/format.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <limits>
#include <numbers>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -21,7 +21,11 @@
// SOFTWARE.
#include <mp-units/systems/isq_angle.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <numbers>
#endif
namespace {

View File

@ -25,9 +25,13 @@
#include <mp-units/framework/quantity_point.h> // IWYU pragma: keep
#include <mp-units/systems/isq/si_quantities.h>
#include <mp-units/systems/si.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <chrono>
#include <concepts>
#include <ratio>
#endif
namespace {

View File

@ -23,6 +23,9 @@
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/natural.h>
#include <mp-units/systems/si.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <optional>
#include <type_traits>
#if MP_UNITS_HOSTED
@ -30,6 +33,7 @@
#include <complex>
#include <string>
#endif
#endif
#if MP_UNITS_HOSTED
template<typename 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_IMPORT_STD
import std;
#else
#include <ostream>
#include <type_traits>
#endif
#ifdef MP_UNITS_MODULES
import mp_units;
#else

View File

@ -24,8 +24,12 @@
#include <mp-units/framework.h>
#include <mp-units/systems/si/prefixes.h>
#include <mp-units/systems/si/units.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <concepts>
#include <type_traits>
#endif
namespace {

View File

@ -22,7 +22,11 @@
#include <mp-units/framework.h>
#include <mp-units/systems/isq.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <string_view>
#endif
namespace {

View File

@ -23,7 +23,11 @@
#include "test_tools.h"
#include <mp-units/ext/type_traits.h>
#include <mp-units/framework.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <type_traits>
#endif
namespace {

View File

@ -21,8 +21,12 @@
// SOFTWARE.
#include <mp-units/ext/fixed_string.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <string_view>
#endif
using namespace mp_units;

View File

@ -21,9 +21,13 @@
// SOFTWARE.
#include <mp-units/ext/prime.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <array>
#include <cstddef>
#include <utility>
#endif
using namespace mp_units::detail;

View File

@ -26,6 +26,9 @@
#include <mp-units/systems/isq.h>
#include <mp-units/systems/si.h>
#include <mp-units/systems/usc.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <concepts>
#include <cstdint>
#include <limits>
@ -34,6 +37,7 @@
#if MP_UNITS_HOSTED
#include <chrono>
#endif
#endif
namespace {

View File

@ -23,7 +23,11 @@
#include "test_tools.h"
#include <mp-units/ext/type_traits.h>
#include <mp-units/framework.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <type_traits>
#endif
namespace {

View File

@ -27,6 +27,9 @@
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <concepts>
#include <cstdint>
#include <limits>
@ -35,6 +38,7 @@
#if MP_UNITS_HOSTED
#include <chrono>
#endif
#endif
template<>
inline constexpr bool mp_units::is_vector<int> = true;

View File

@ -23,8 +23,12 @@
#include "test_tools.h"
#include <mp-units/framework.h>
#include <mp-units/systems/si/prefixes.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <cstdint>
#include <type_traits>
#endif
namespace {

View File

@ -21,7 +21,11 @@
// SOFTWARE.
#include <mp-units/systems/si.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <type_traits>
#endif
namespace {

View File

@ -24,7 +24,11 @@
#include <mp-units/bits/hacks.h>
#include <mp-units/framework/quantity_spec.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <type_traits>
#endif
template<auto V, typename T>
inline constexpr bool is_of_type = std::is_same_v<MP_UNITS_REMOVE_CONST(decltype(V)), T>;

View File

@ -22,7 +22,11 @@
#include <mp-units/bits/type_list.h>
#include <mp-units/ext/type_traits.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <type_traits>
#endif
namespace {

View File

@ -23,7 +23,11 @@
#include <mp-units/systems/iau.h>
#include <mp-units/systems/iec80000.h>
#include <mp-units/systems/si.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <string_view>
#endif
namespace {

View File

@ -24,7 +24,11 @@
#include <mp-units/ext/type_traits.h>
#include <mp-units/framework.h>
#include <mp-units/systems/si/prefixes.h>
#ifdef MP_UNITS_IMPORT_STD
import std;
#else
#include <type_traits>
#endif
namespace {