diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1490bac7a..a05af6c38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -458,6 +458,7 @@ jobs: git submodule update --init tools/boostdep DEPINST_ARGS+=("$LIBRARY") python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}" + python libs/charconv/tools/setup_boost_with_modules.py # Temporary if [ -z "${{matrix.cmake_tests}}" ] then ./bootstrap.sh @@ -550,6 +551,7 @@ jobs: xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/charconv/tools/setup_boost_with_modules.py # Temporary cmd /c bootstrap b2 -d0 headers @@ -597,6 +599,7 @@ jobs: cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + python libs/charconv/tools/setup_boost_with_modules.py # Temporary - name: Use library with add_subdirectory run: | @@ -644,6 +647,7 @@ jobs: cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + python libs/charconv/tools/setup_boost_with_modules.py # Temporary - name: Configure run: | @@ -701,6 +705,7 @@ jobs: cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + python libs/charconv/tools/setup_boost_with_modules.py # Temporary - name: Configure run: | @@ -764,4 +769,387 @@ jobs: run: ci/github/install.sh - name: Run tests - run: ci/build.sh + run: | + ./ci/build.sh + cd $BOOST_ROOT + python libs/charconv/tools/setup_boost_with_modules.py # Temporary + + posix-cmake-subdir-modules: + strategy: + fail-fast: false + matrix: + include: + - name: "clang-21 Debug" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Debug" + - name: "clang-21 Release" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Release" + - name: "gcc-15 Debug" + packages: "g++-15" + cmake-args: "-DCMAKE_CXX_COMPILER=g++-15 -DCMAKE_BUILD_TYPE=Debug" + + name: CMake subdir modules ${{ matrix.name }} + + + runs-on: ubuntu-latest + container: ubuntu:26.04 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: | + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y --no-install-recommends wget ninja-build git ca-certificates python3 python-is-python3 ${{ matrix.packages }} + ./tools/install-cmake.sh + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py $LIBRARY + python libs/charconv/tools/setup_boost_with_modules.py # Temporary + + - name: Use library with add_subdirectory + run: | + cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test + mkdir __build__ && cd __build__ + cmake \ + -G Ninja \ + -DCMAKE_CXX_STANDARD=23 \ + -DBUILD_TESTING=ON \ + -DBOOST_INCLUDE_LIBRARIES=$LIBRARY \ + -DBOOST_USE_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + ${{ matrix.cmake-args }} \ + .. + cmake --build . + ctest --output-on-failure --no-tests=error + + posix-cmake-install-modules: + strategy: + fail-fast: false + matrix: + include: + - name: "clang-21 Debug" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Debug" + - name: "clang-21 Release" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Release" + - name: "gcc-15 Debug" + packages: "g++-15" + cmake-args: "-DCMAKE_CXX_COMPILER=g++-15 -DCMAKE_BUILD_TYPE=Debug" + + name: CMake install modules ${{ matrix.name }} + + runs-on: ubuntu-latest + container: ubuntu:26.04 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: | + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y --no-install-recommends wget ninja-build git ca-certificates python3 python-is-python3 ${{ matrix.packages }} + ./tools/install-cmake.sh + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py $LIBRARY + python libs/charconv/tools/setup_boost_with_modules.py # Temporary + + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake \ + -G Ninja \ + -DCMAKE_CXX_STANDARD=23 \ + -DBOOST_INCLUDE_LIBRARIES=$LIBRARY \ + -DCMAKE_INSTALL_PREFIX=~/.local \ + -DBOOST_USE_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + ${{ matrix.cmake-args }} \ + .. + + - name: Install + run: | + cd ../boost-root/__build__ + cmake --build . --target install + + - name: Use the installed library + run: | + cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__ + cmake \ + -G Ninja \ + -DCMAKE_CXX_STANDARD=23 \ + -DCMAKE_INSTALL_PREFIX=~/.local \ + -DBOOST_USE_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + ${{ matrix.cmake-args }} \ + .. + cmake --build . + ctest --output-on-failure --no-tests=error + + posix-cmake-test-modules: + strategy: + fail-fast: false + matrix: + include: + - name: "clang-21 Debug" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Debug" + - name: "clang-21 Release" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Release" + - name: "gcc-15 Debug" + packages: "g++-15" + cmake-args: "-DCMAKE_CXX_COMPILER=g++-15 -DCMAKE_BUILD_TYPE=Debug" + + name: CMake test modules ${{ matrix.name }} + + runs-on: ubuntu-latest + container: ubuntu:26.04 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: | + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y --no-install-recommends wget ninja-build git ca-certificates python3 python-is-python3 ${{ matrix.packages }} + ./tools/install-cmake.sh + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py $LIBRARY + python libs/charconv/tools/setup_boost_with_modules.py # Temporary + + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake \ + -G Ninja \ + -DCMAKE_CXX_STANDARD=23 \ + -DBOOST_INCLUDE_LIBRARIES=$LIBRARY \ + -DBUILD_TESTING=ON \ + -DBOOST_USE_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + ${{ matrix.cmake-args }} \ + .. + + - name: Build tests + run: | + cd ../boost-root/__build__ + cmake --build . --target tests + + - name: Run tests + run: | + cd ../boost-root/__build__ + ctest --output-on-failure --no-tests=error + + windows-cmake-subdir-modules: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: choco install --no-progress ninja + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/charconv/tools/setup_boost_with_modules.py # Temporary + + - name: Use library with add_subdirectory + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test + mkdir __build__ && cd __build__ + cmake -DBOOST_USE_MODULES=1 -DCMAKE_CXX_STANDARD=23 -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 -G Ninja .. + cmake --build . + ctest --output-on-failure --no-tests=error + + windows-cmake-install-modules: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: choco install --no-progress ninja + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/charconv/tools/setup_boost_with_modules.py # Temporary + + - name: Configure + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix -DBOOST_USE_MODULES=1 -DCMAKE_CXX_STANDARD=23 -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 -G Ninja .. + + - name: Install + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/__build__ + cmake --build . --target install + + - name: Use the installed library + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__ + cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix -DCMAKE_CXX_STANDARD=23 -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 -G Ninja .. + cmake --build . + ctest --output-on-failure --no-tests=error + + windows-cmake-test-modules: + strategy: + fail-fast: false + matrix: + include: + - cmake-build-type: Debug + - cmake-build-type: Release + + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: choco install --no-progress ninja + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/charconv/tools/setup_boost_with_modules.py # Temporary + + - name: Configure + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON -DBOOST_USE_MODULES=1 -DCMAKE_CXX_STANDARD=23 -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 -DCMAKE_BUILD_TYPE=${{matrix.cmake-build-type}} -G Ninja .. + + - name: Build tests + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/__build__ + cmake --build . --target tests + + - name: Run tests + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/__build__ + ctest --output-on-failure --no-tests=error diff --git a/CMakeLists.txt b/CMakeLists.txt index d4525678d..c780d8658 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,17 +3,40 @@ # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt -cmake_minimum_required(VERSION 3.8...3.20) +cmake_minimum_required(VERSION 3.8...3.31) project(boost_charconv VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) +# We can't make source files conditionally module units. +# In module builds, use cc files that include their respective cpp, plus the module infrastructure +if (BOOST_USE_MODULES) + set(SOURCE_SUFFIX "cc") +else() + set(SOURCE_SUFFIX "cpp") +endif() + add_library(boost_charconv - src/from_chars.cpp - src/to_chars.cpp + src/from_chars.${SOURCE_SUFFIX} + src/to_chars.${SOURCE_SUFFIX} ) add_library(Boost::charconv ALIAS boost_charconv) +if (BOOST_USE_MODULES) + target_sources(boost_charconv + PUBLIC FILE_SET CXX_MODULES BASE_DIRS modules FILES + modules/boost_charconv.cppm + modules/boost_charconv_interface.cppm + PRIVATE FILE_SET helpers TYPE CXX_MODULES BASE_DIRS src FILES + src/helpers.cppm + ) + + # Enable and propagate C++23, import std, and the modules macro + target_compile_features(boost_charconv PUBLIC cxx_std_23) + set_target_properties(boost_charconv PROPERTIES CXX_MODULE_STD 1) + target_compile_definitions(boost_charconv PUBLIC BOOST_USE_MODULES) +endif() + target_include_directories(boost_charconv PUBLIC include) diff --git a/include/boost/charconv/chars_format.hpp b/include/boost/charconv/chars_format.hpp index 0542372bf..2eb4d503a 100644 --- a/include/boost/charconv/chars_format.hpp +++ b/include/boost/charconv/chars_format.hpp @@ -5,11 +5,24 @@ #ifndef BOOST_CHARCONV_CHARS_FORMAT_HPP #define BOOST_CHARCONV_CHARS_FORMAT_HPP +#if defined(BOOST_USE_MODULES) && !defined(BOOST_CHARCONV_INTERFACE_UNIT) + +#ifndef BOOST_IN_MODULE_PURVIEW +import boost.charconv; +#ifndef BOOST_CHARCONV_CONSTEXPR +#define BOOST_CHARCONV_CONSTEXPR constexpr +#endif +#endif + +#else + +#include + namespace boost { namespace charconv { // Floating-point format for primitive numerical conversion // chars_format is a bitmask type (16.3.3.3.3) -enum class chars_format : unsigned +BOOST_CHARCONV_MODULE_EXPORT enum class chars_format : unsigned { scientific = 1 << 0, fixed = 1 << 1, @@ -19,4 +32,6 @@ enum class chars_format : unsigned }} // Namespaces +#endif // defined(BOOST_USE_MODULES) && !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_CHARS_FORMAT_HPP diff --git a/include/boost/charconv/config.hpp b/include/boost/charconv/config.hpp index 0d94ccd4a..a9d85b25e 100644 --- a/include/boost/charconv/config.hpp +++ b/include/boost/charconv/config.hpp @@ -1,3 +1,8 @@ +// Make the header safe to include from libraries supporting modules +#if defined(BOOST_IN_MODULE_PURVIEW) && !defined(BOOST_CHARCONV_CONFIG_HPP_INCLUDED) +# error "Please #include in your module global fragment" +#endif + #ifndef BOOST_CHARCONV_CONFIG_HPP_INCLUDED #define BOOST_CHARCONV_CONFIG_HPP_INCLUDED @@ -7,7 +12,7 @@ // https://www.boost.org/LICENSE_1_0.txt #include -#include +#include // This header implements separate compilation features as described in // http://www.boost.org/more/separate_compilation.html @@ -36,4 +41,11 @@ #endif +// Modules +#ifdef BOOST_USE_MODULES +# define BOOST_CHARCONV_MODULE_EXPORT export +#else +# define BOOST_CHARCONV_MODULE_EXPORT +#endif + #endif // BOOST_CHARCONV_CONFIG_HPP_INCLUDED diff --git a/include/boost/charconv/detail/apply_sign.hpp b/include/boost/charconv/detail/apply_sign.hpp index ef6db7143..fc2eadecc 100644 --- a/include/boost/charconv/detail/apply_sign.hpp +++ b/include/boost/charconv/detail/apply_sign.hpp @@ -5,10 +5,12 @@ #ifndef BOOST_CHARCONV_DETAIL_APPLY_SIGN_HPP #define BOOST_CHARCONV_DETAIL_APPLY_SIGN_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #include #include #include -#include +#include // We are purposefully converting values here #ifdef BOOST_MSVC @@ -47,4 +49,6 @@ constexpr Unsigned_Integer apply_sign(Unsigned_Integer val) noexcept # pragma clang diagnostic pop #endif +#endif // !defined(BOOST_USE_MODULES) || !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_APPLY_SIGN_HPP diff --git a/include/boost/charconv/detail/bit_layouts.hpp b/include/boost/charconv/detail/bit_layouts.hpp index c163ce06a..b21a0050d 100644 --- a/include/boost/charconv/detail/bit_layouts.hpp +++ b/include/boost/charconv/detail/bit_layouts.hpp @@ -5,10 +5,12 @@ #ifndef BOOST_CHARCONV_DETAIL_BIT_LAYOUTS_HPP #define BOOST_CHARCONV_DETAIL_BIT_LAYOUTS_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #include #include -#include -#include +#include +#include // Layouts of floating point types as specified by IEEE 754 // See page 23 of IEEE 754-2008 @@ -56,7 +58,7 @@ struct ieee754_binary64 }; // 80 bit long double (e.g. x86-64) -#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 +#if BOOST_CHARCONV_LDBL_BITS == 80 struct IEEEl2bits { @@ -83,10 +85,8 @@ struct ieee754_binary80 static constexpr int decimal_digits = 18; }; -#define BOOST_CHARCONV_LDBL_BITS 80 - // 128 bit long double (e.g. s390x, ppcle64) -#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 +#elif BOOST_CHARCONV_LDBL_BITS == 128 struct IEEEl2bits { @@ -103,10 +103,8 @@ struct IEEEl2bits #endif }; -#define BOOST_CHARCONV_LDBL_BITS 128 - // 64 bit long double (double == long double on ARM) -#elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +#elif BOOST_CHARCONV_LDBL_BITS == 64 struct IEEEl2bits { @@ -123,11 +121,6 @@ struct IEEEl2bits #endif }; -#define BOOST_CHARCONV_LDBL_BITS 64 - -#else // Unsupported long double representation -# define BOOST_CHARCONV_UNSUPPORTED_LONG_DOUBLE -# define BOOST_CHARCONV_LDBL_BITS -1 #endif struct IEEEbinary128 @@ -157,4 +150,6 @@ struct ieee754_binary128 }}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_BIT_LAYOUTS_HPP diff --git a/include/boost/charconv/detail/buffer_sizing.hpp b/include/boost/charconv/detail/buffer_sizing.hpp index 3115ee39e..f3f756dca 100644 --- a/include/boost/charconv/detail/buffer_sizing.hpp +++ b/include/boost/charconv/detail/buffer_sizing.hpp @@ -5,9 +5,11 @@ #ifndef BOOST_CHARCONV_DETAIL_BUFFER_SIZING_HPP #define BOOST_CHARCONV_DETAIL_BUFFER_SIZING_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include -#include +#include namespace boost { namespace charconv { @@ -69,4 +71,6 @@ inline int total_buffer_length(int real_precision, Int exp, bool signed_value) } //namespace charconv } //namespace boost +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif //BOOST_CHARCONV_DETAIL_BUFFER_SIZING_HPP diff --git a/include/boost/charconv/detail/compute_float32.hpp b/include/boost/charconv/detail/compute_float32.hpp index 85ece7f8c..fcd03743d 100644 --- a/include/boost/charconv/detail/compute_float32.hpp +++ b/include/boost/charconv/detail/compute_float32.hpp @@ -5,10 +5,12 @@ #ifndef BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT32_HPP #define BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT32_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include -#include -#include -#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { @@ -52,4 +54,6 @@ inline float compute_float32(std::int64_t power, std::uint64_t i, bool negative, }}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT32_HPP diff --git a/include/boost/charconv/detail/compute_float64.hpp b/include/boost/charconv/detail/compute_float64.hpp index 3cb83537f..9ab7d0421 100644 --- a/include/boost/charconv/detail/compute_float64.hpp +++ b/include/boost/charconv/detail/compute_float64.hpp @@ -6,18 +6,20 @@ #ifndef BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT64_HPP #define BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT64_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { -static constexpr double powers_of_ten[] = { +BOOST_INLINE_CONSTEXPR double powers_of_ten[] = { 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22 }; @@ -198,4 +200,6 @@ inline double compute_float64(std::int64_t power, std::uint64_t i, bool negative }}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT64_HPP diff --git a/include/boost/charconv/detail/compute_float80.hpp b/include/boost/charconv/detail/compute_float80.hpp index ad1e51486..7132dba5d 100644 --- a/include/boost/charconv/detail/compute_float80.hpp +++ b/include/boost/charconv/detail/compute_float80.hpp @@ -5,20 +5,22 @@ #ifndef BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT80_HPP #define BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT80_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef BOOST_CHARCONV_DEBUG_FLOAT128 -#include -#include +#include +#include #include #endif @@ -26,7 +28,7 @@ namespace boost { namespace charconv { namespace detail { #if BOOST_CHARCONV_LDBL_BITS > 64 -static constexpr long double powers_of_ten_ld[] = { +BOOST_INLINE_CONSTEXPR long double powers_of_ten_ld[] = { 1e0L, 1e1L, 1e2L, 1e3L, 1e4L, 1e5L, 1e6L, 1e7L, 1e8L, 1e9L, 1e10L, 1e11L, 1e12L, 1e13L, 1e14L, 1e15L, 1e16L, 1e17L, 1e18L, 1e19L, 1e20L, @@ -111,4 +113,6 @@ inline ResultType compute_float80(std::int64_t q, Unsigned_Integer w, bool negat }}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_COMPUTE_FLOAT80_HPP diff --git a/include/boost/charconv/detail/config.hpp b/include/boost/charconv/detail/config.hpp index 9feb609fe..463d40331 100644 --- a/include/boost/charconv/detail/config.hpp +++ b/include/boost/charconv/detail/config.hpp @@ -2,13 +2,39 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +// Make this header safe to include in our purview +#if defined(BOOST_IN_MODULE_PURVIEW) && !defined(BOOST_CHARCONV_DETAIL_CONFIG_HPP) +# error "Please #include in your module global fragment" +#endif + #ifndef BOOST_CHARCONV_DETAIL_CONFIG_HPP #define BOOST_CHARCONV_DETAIL_CONFIG_HPP #include -#include +#include #include +// Long double characteristics + +// 80 bit long double (e.g. x86-64) +#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 +# define BOOST_CHARCONV_LDBL_BITS 80 + +// 128 bit long double (e.g. s390x, ppcle64) +#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 +# define BOOST_CHARCONV_LDBL_BITS 128 + +// 64 bit long double (double == long double on ARM) +#elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +# define BOOST_CHARCONV_LDBL_BITS 64 + +// Unsupported long double representation +#else +# define BOOST_CHARCONV_UNSUPPORTED_LONG_DOUBLE +# define BOOST_CHARCONV_LDBL_BITS -1 + +#endif // long double feature detection + #include #define BOOST_CHARCONV_ASSERT(expr) BOOST_ASSERT(expr) #define BOOST_CHARCONV_ASSERT_MSG(expr, msg) BOOST_ASSERT_MSG(expr, msg) @@ -169,7 +195,7 @@ static_assert((BOOST_CHARCONV_ENDIAN_BIG_BYTE || BOOST_CHARCONV_ENDIAN_LITTLE_BY // All of these types are optional so check for each of them individually #if (defined(_MSVC_LANG) && _MSVC_LANG > 202002L) || __cplusplus > 202002L # if __has_include() -# include +# include # endif #endif #ifdef __STDCPP_FLOAT16_T__ diff --git a/include/boost/charconv/detail/dragonbox/dragonbox.hpp b/include/boost/charconv/detail/dragonbox/dragonbox.hpp index f2d3449ac..389d31315 100644 --- a/include/boost/charconv/detail/dragonbox/dragonbox.hpp +++ b/include/boost/charconv/detail/dragonbox/dragonbox.hpp @@ -22,6 +22,8 @@ #ifndef BOOST_CHARCONV_DETAIL_DRAGONBOX_HPP #define BOOST_CHARCONV_DETAIL_DRAGONBOX_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include @@ -30,10 +32,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #ifdef BOOST_MSVC # pragma warning(push) @@ -2749,4 +2751,6 @@ to_chars_result dragonbox_to_chars(Float x, char* first, char* last, chars_forma # pragma warning(pop) #endif +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_DRAGONBOX_HPP diff --git a/include/boost/charconv/detail/dragonbox/dragonbox_common.hpp b/include/boost/charconv/detail/dragonbox/dragonbox_common.hpp index 0bee7d091..cef506002 100644 --- a/include/boost/charconv/detail/dragonbox/dragonbox_common.hpp +++ b/include/boost/charconv/detail/dragonbox/dragonbox_common.hpp @@ -24,17 +24,19 @@ #ifndef BOOST_CHARCONV_DETAIL_DRAGONBOX_COMMON_HPP #define BOOST_CHARCONV_DETAIL_DRAGONBOX_COMMON_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { @@ -321,7 +323,7 @@ BOOST_CHARCONV_CXX14_CONSTEXPR Int compute_power(Int a, Int2 exp) noexcept return res; } -static constexpr std::uint64_t power_of_10[] = { +BOOST_INLINE_CONSTEXPR std::uint64_t power_of_10[] = { UINT64_C(1), UINT64_C(10), UINT64_C(100), UINT64_C(1000), UINT64_C(10000), UINT64_C(100000), UINT64_C(1000000), UINT64_C(10000000), UINT64_C(100000000), UINT64_C(1000000000), UINT64_C(10000000000), UINT64_C(100000000000), UINT64_C(1000000000000), @@ -381,9 +383,9 @@ BOOST_CHARCONV_CXX14_CONSTEXPR int floor_log2(UInt n) noexcept return count; } -static constexpr int floor_log10_pow2_min_exponent = -2620; +BOOST_INLINE_CONSTEXPR int floor_log10_pow2_min_exponent = -2620; -static constexpr int floor_log10_pow2_max_exponent = 2620; +BOOST_INLINE_CONSTEXPR int floor_log10_pow2_max_exponent = 2620; constexpr int floor_log10_pow2(int e) noexcept { @@ -393,9 +395,9 @@ constexpr int floor_log10_pow2(int e) noexcept max_exponent(floor_log10_pow2_max_exponent)>(e); } -static constexpr int floor_log2_pow10_min_exponent = -1233; +BOOST_INLINE_CONSTEXPR int floor_log2_pow10_min_exponent = -1233; -static constexpr int floor_log2_pow10_max_exponent = 1233; +BOOST_INLINE_CONSTEXPR int floor_log2_pow10_max_exponent = 1233; constexpr int floor_log2_pow10(int e) noexcept { @@ -405,9 +407,9 @@ constexpr int floor_log2_pow10(int e) noexcept max_exponent(floor_log2_pow10_max_exponent)>(e); } -static constexpr int floor_log10_pow2_minus_log10_4_over_3_min_exponent = -2985; +BOOST_INLINE_CONSTEXPR int floor_log10_pow2_minus_log10_4_over_3_min_exponent = -2985; -static constexpr int floor_log10_pow2_minus_log10_4_over_3_max_exponent = 2936; +BOOST_INLINE_CONSTEXPR int floor_log10_pow2_minus_log10_4_over_3_max_exponent = 2936; constexpr int floor_log10_pow2_minus_log10_4_over_3(int e) noexcept { @@ -417,9 +419,9 @@ constexpr int floor_log10_pow2_minus_log10_4_over_3(int e) noexcept max_exponent(floor_log10_pow2_minus_log10_4_over_3_max_exponent)>(e); } -static constexpr int floor_log5_pow2_min_exponent = -1831; +BOOST_INLINE_CONSTEXPR int floor_log5_pow2_min_exponent = -1831; -static constexpr int floor_log5_pow2_max_exponent = 1831; +BOOST_INLINE_CONSTEXPR int floor_log5_pow2_max_exponent = 1831; constexpr int floor_log5_pow2(int e) noexcept { @@ -429,9 +431,9 @@ constexpr int floor_log5_pow2(int e) noexcept max_exponent(floor_log5_pow2_max_exponent)>(e); } -static constexpr int floor_log5_pow2_minus_log5_3_min_exponent = -3543; +BOOST_INLINE_CONSTEXPR int floor_log5_pow2_minus_log5_3_min_exponent = -3543; -static constexpr int floor_log5_pow2_minus_log5_3_max_exponent = 2427; +BOOST_INLINE_CONSTEXPR int floor_log5_pow2_minus_log5_3_max_exponent = 2427; constexpr int floor_log5_pow2_minus_log5_3(int e) noexcept { @@ -826,4 +828,6 @@ struct compressed_cache_detail }}} +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_DRAGONBOX_COMMON_HPP diff --git a/include/boost/charconv/detail/dragonbox/floff.hpp b/include/boost/charconv/detail/dragonbox/floff.hpp index 8eaaffd80..f79a25bfe 100644 --- a/include/boost/charconv/detail/dragonbox/floff.hpp +++ b/include/boost/charconv/detail/dragonbox/floff.hpp @@ -24,6 +24,8 @@ #ifndef BOOST_CHARCONV_DETAIL_FLOFF #define BOOST_CHARCONV_DETAIL_FLOFF +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include @@ -31,12 +33,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef BOOST_MSVC # pragma warning(push) @@ -575,7 +577,7 @@ struct uint_with_known_number_of_digits }; template ::value, bool>::type = true> -static BOOST_FORCEINLINE bool check_rounding_condition_inside_subsegment( +BOOST_FORCEINLINE bool check_rounding_condition_inside_subsegment( std::uint32_t current_digits, std::uint32_t fractional_part, int remaining_digits_in_the_current_subsegment, HasFurtherDigits has_further_digits, Args...) noexcept @@ -590,7 +592,7 @@ static BOOST_FORCEINLINE bool check_rounding_condition_inside_subsegment( template ::value, bool>::type = true> -static BOOST_FORCEINLINE bool check_rounding_condition_inside_subsegment( +BOOST_FORCEINLINE bool check_rounding_condition_inside_subsegment( std::uint32_t current_digits, std::uint32_t fractional_part, int remaining_digits_in_the_current_subsegment, HasFurtherDigits has_further_digits, Args... args) noexcept @@ -605,7 +607,7 @@ static BOOST_FORCEINLINE bool check_rounding_condition_inside_subsegment( template ::value, bool>::type = true> -static BOOST_FORCEINLINE bool check_rounding_condition_with_next_bit(std::uint32_t current_digits, bool next_bit, +BOOST_FORCEINLINE bool check_rounding_condition_with_next_bit(std::uint32_t current_digits, bool next_bit, HasFurtherDigits has_further_digits, Args...) noexcept { if (!next_bit) @@ -618,7 +620,7 @@ static BOOST_FORCEINLINE bool check_rounding_condition_with_next_bit(std::uint32 template ::value, bool>::type = true> -static BOOST_FORCEINLINE bool check_rounding_condition_with_next_bit(std::uint32_t current_digits, bool next_bit, +BOOST_FORCEINLINE bool check_rounding_condition_with_next_bit(std::uint32_t current_digits, bool next_bit, HasFurtherDigits has_further_digits, Args... args) noexcept { if (!next_bit) @@ -631,7 +633,7 @@ static BOOST_FORCEINLINE bool check_rounding_condition_with_next_bit(std::uint32 template ::value, bool>::type = true> -static BOOST_FORCEINLINE bool check_rounding_condition_subsegment_boundary_with_next_subsegment( +BOOST_FORCEINLINE bool check_rounding_condition_subsegment_boundary_with_next_subsegment( std::uint32_t current_digits, UintWithKnownDigits next_subsegment, HasFurtherDigits has_further_digits, Args...) noexcept { @@ -646,7 +648,7 @@ static BOOST_FORCEINLINE bool check_rounding_condition_subsegment_boundary_with_ template ::value, bool>::type = true> -static BOOST_FORCEINLINE bool check_rounding_condition_subsegment_boundary_with_next_subsegment( +BOOST_FORCEINLINE bool check_rounding_condition_subsegment_boundary_with_next_subsegment( std::uint32_t current_digits, UintWithKnownDigits next_subsegment, HasFurtherDigits has_further_digits, Args... args) noexcept { @@ -4053,4 +4055,6 @@ BOOST_CHARCONV_SAFEBUFFERS to_chars_result floff(const double x, int precision, # pragma warning(pop) #endif +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_FLOFF diff --git a/include/boost/charconv/detail/emulated128.hpp b/include/boost/charconv/detail/emulated128.hpp index 281b031cb..9dcbd6beb 100644 --- a/include/boost/charconv/detail/emulated128.hpp +++ b/include/boost/charconv/detail/emulated128.hpp @@ -8,14 +8,16 @@ #ifndef BOOST_CHARCONV_DETAIL_EMULATED128_HPP #define BOOST_CHARCONV_DETAIL_EMULATED128_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { @@ -825,7 +827,7 @@ BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &uint128::operator%=(uint128 v) noexcept return *this; } -static inline std::uint64_t umul64(std::uint32_t x, std::uint32_t y) noexcept +inline std::uint64_t umul64(std::uint32_t x, std::uint32_t y) noexcept { // __emulu is not available on ARM https://learn.microsoft.com/en-us/cpp/intrinsics/emul-emulu?view=msvc-170 #if defined(BOOST_CHARCONV_HAS_MSVC_32BIT_INTRINSICS) && !defined(_M_ARM) @@ -1002,4 +1004,6 @@ struct numeric_limits } // Namespace std +#endif // !defined(BOOST_USE_MODULES) || !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_EMULATED128_HPP diff --git a/include/boost/charconv/detail/fallback_routines.hpp b/include/boost/charconv/detail/fallback_routines.hpp index 94f87b82b..321ffaee5 100644 --- a/include/boost/charconv/detail/fallback_routines.hpp +++ b/include/boost/charconv/detail/fallback_routines.hpp @@ -5,17 +5,19 @@ #ifndef BOOST_FALLBACK_ROUTINES_HPP #define BOOST_FALLBACK_ROUTINES_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace boost { namespace charconv { @@ -242,4 +244,6 @@ inline from_chars_result from_chars_strtod(const char* first, const char* last, } //namespace charconv } //namespace boost +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif //BOOST_FALLBACK_ROUTINES_HPP diff --git a/include/boost/charconv/detail/fast_float/ascii_number.hpp b/include/boost/charconv/detail/fast_float/ascii_number.hpp index 159a7661d..36a4f07e1 100644 --- a/include/boost/charconv/detail/fast_float/ascii_number.hpp +++ b/include/boost/charconv/detail/fast_float/ascii_number.hpp @@ -8,11 +8,13 @@ #ifndef BOOST_CHARCONV_DETAIL_FASTFLOAT_ASCII_NUMBER_HPP #define BOOST_CHARCONV_DETAIL_FASTFLOAT_ASCII_NUMBER_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include -#include -#include -#include -#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { namespace fast_float { @@ -285,4 +287,6 @@ parsed_number_string_t parse_number_string(UC const *p, UC const * pend, par }}}} // namespace s +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif diff --git a/include/boost/charconv/detail/fast_float/bigint.hpp b/include/boost/charconv/detail/fast_float/bigint.hpp index fd98590cd..9397bfded 100644 --- a/include/boost/charconv/detail/fast_float/bigint.hpp +++ b/include/boost/charconv/detail/fast_float/bigint.hpp @@ -8,11 +8,13 @@ #ifndef BOOST_CHARCONV_DETAIL_FASTFLOAT_BIGINT_HPP #define BOOST_CHARCONV_DETAIL_FASTFLOAT_BIGINT_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include -#include -#include -#include -#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { namespace fast_float { @@ -620,4 +622,6 @@ struct bigint : pow5_tables<> { }}}} // namespace fast_float +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif diff --git a/include/boost/charconv/detail/fast_float/constexpr_feature_detect.hpp b/include/boost/charconv/detail/fast_float/constexpr_feature_detect.hpp index 1ac1e4aab..ba6f18562 100644 --- a/include/boost/charconv/detail/fast_float/constexpr_feature_detect.hpp +++ b/include/boost/charconv/detail/fast_float/constexpr_feature_detect.hpp @@ -5,6 +5,11 @@ // // Derivative of: https://github.com/fastfloat/fast_float +// Make the header safe to include from libraries supporting modules +#if defined(BOOST_IN_MODULE_PURVIEW) && !defined(BOOST_CHARCONV_DETAIL_FASTFLOAT_CONSTEXPR_FEATURE_DETECT_HPP) +# error "Please #include in your module global fragment" +#endif + #ifndef BOOST_CHARCONV_DETAIL_FASTFLOAT_CONSTEXPR_FEATURE_DETECT_HPP #define BOOST_CHARCONV_DETAIL_FASTFLOAT_CONSTEXPR_FEATURE_DETECT_HPP diff --git a/include/boost/charconv/detail/fast_float/decimal_to_binary.hpp b/include/boost/charconv/detail/fast_float/decimal_to_binary.hpp index 4a76a6eeb..5e63d8daa 100644 --- a/include/boost/charconv/detail/fast_float/decimal_to_binary.hpp +++ b/include/boost/charconv/detail/fast_float/decimal_to_binary.hpp @@ -8,14 +8,16 @@ #ifndef BOOST_CHARCONV_DETAIL_FASTFLOAT_DECIMAL_TO_BINARY_HPP #define BOOST_CHARCONV_DETAIL_FASTFLOAT_DECIMAL_TO_BINARY_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { namespace fast_float { @@ -193,4 +195,6 @@ adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept { }}}} // namespace fast_float +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif diff --git a/include/boost/charconv/detail/fast_float/digit_comparison.hpp b/include/boost/charconv/detail/fast_float/digit_comparison.hpp index 231279410..9cb6569ea 100644 --- a/include/boost/charconv/detail/fast_float/digit_comparison.hpp +++ b/include/boost/charconv/detail/fast_float/digit_comparison.hpp @@ -8,18 +8,20 @@ #ifndef BOOST_CHARCONV_DETAIL_FASTFLOAT_DIGIT_COMPARISON_HPP #define BOOST_CHARCONV_DETAIL_FASTFLOAT_DIGIT_COMPARISON_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { namespace fast_float { // 1e0 to 1e19 -constexpr static uint64_t powers_of_ten_uint64[] = { +BOOST_INLINE_CONSTEXPR uint64_t powers_of_ten_uint64[] = { 1UL, 10UL, 100UL, 1000UL, 10000UL, 100000UL, 1000000UL, 10000000UL, 100000000UL, 1000000000UL, 10000000000UL, 100000000000UL, 1000000000000UL, 10000000000000UL, 100000000000000UL, 1000000000000000UL, 10000000000000000UL, 100000000000000000UL, @@ -439,4 +441,6 @@ adjusted_mantissa digit_comp(parsed_number_string_t& num, adjusted_mantissa }}}} // namespace fast_float +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif diff --git a/include/boost/charconv/detail/fast_float/fast_float.hpp b/include/boost/charconv/detail/fast_float/fast_float.hpp index 00bb6c523..aba1daecb 100644 --- a/include/boost/charconv/detail/fast_float/fast_float.hpp +++ b/include/boost/charconv/detail/fast_float/fast_float.hpp @@ -8,6 +8,8 @@ #ifndef BOOST_CHARCONV_DETAIL_FASTFLOAT_FAST_FLOAT_HPP #define BOOST_CHARCONV_DETAIL_FASTFLOAT_FAST_FLOAT_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include namespace boost { namespace charconv { namespace detail { namespace fast_float { @@ -45,4 +47,7 @@ from_chars_result_t from_chars_advanced(UC const * first, UC const * last, }}}} // namespace fast_float #include + +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_FASTFLOAT_FAST_FLOAT_H diff --git a/include/boost/charconv/detail/fast_float/fast_table.hpp b/include/boost/charconv/detail/fast_float/fast_table.hpp index e08eb3145..5f5cebd68 100644 --- a/include/boost/charconv/detail/fast_float/fast_table.hpp +++ b/include/boost/charconv/detail/fast_float/fast_table.hpp @@ -8,8 +8,10 @@ #ifndef BOOST_CHARCONV_DETAIL_FASTFLOAT_FAST_TABLE_HPP #define BOOST_CHARCONV_DETAIL_FASTFLOAT_FAST_TABLE_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include -#include +#include namespace boost { namespace charconv { namespace detail { namespace fast_float { @@ -705,4 +707,6 @@ using powers = powers_template<>; }}}} // namespace fast_float +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif diff --git a/include/boost/charconv/detail/fast_float/float_common.hpp b/include/boost/charconv/detail/fast_float/float_common.hpp index 0b9d3aee5..33148512b 100644 --- a/include/boost/charconv/detail/fast_float/float_common.hpp +++ b/include/boost/charconv/detail/fast_float/float_common.hpp @@ -8,16 +8,18 @@ #ifndef BOOST_CHARCONV_DETAIL_FASTFLOAT_FLOAT_COMMON_HPP #define BOOST_CHARCONV_DETAIL_FASTFLOAT_FLOAT_COMMON_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { namespace fast_float { @@ -38,7 +40,7 @@ using parse_options = parse_options_t; }}}} #if BOOST_CHARCONV_FASTFLOAT_HAS_BIT_CAST -#include +#include #endif #if (defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) \ @@ -277,7 +279,7 @@ struct adjusted_mantissa { }; // Bias so we can get the real exponent with an invalid adjusted_mantissa. -constexpr static int32_t invalid_am_bias = -0x8000; +BOOST_INLINE_CONSTEXPR int32_t invalid_am_bias = -0x8000; // used for binary_format_lookup_tables::max_mantissa constexpr uint64_t constant_55555 = 5 * 5 * 5 * 5 * 5; @@ -288,23 +290,23 @@ struct binary_format_lookup_tables; template struct binary_format : binary_format_lookup_tables { using equiv_uint = typename std::conditional::type; - static inline constexpr int mantissa_explicit_bits(); - static inline constexpr int minimum_exponent(); - static inline constexpr int infinite_power(); - static inline constexpr int sign_index(); - static inline constexpr int min_exponent_fast_path(); // used when fegetround() == FE_TONEAREST - static inline constexpr int max_exponent_fast_path(); - static inline constexpr int max_exponent_round_to_even(); - static inline constexpr int min_exponent_round_to_even(); - static inline constexpr uint64_t max_mantissa_fast_path(int64_t power); - static inline constexpr uint64_t max_mantissa_fast_path(); // used when fegetround() == FE_TONEAREST - static inline constexpr int largest_power_of_ten(); - static inline constexpr int smallest_power_of_ten(); - static inline constexpr T exact_power_of_ten(int64_t power); - static inline constexpr size_t max_digits(); - static inline constexpr equiv_uint exponent_mask(); - static inline constexpr equiv_uint mantissa_mask(); - static inline constexpr equiv_uint hidden_bit_mask(); + static inline constexpr int mantissa_explicit_bits(){return {};} + static inline constexpr int minimum_exponent(){return {};} + static inline constexpr int infinite_power(){return {};} + static inline constexpr int sign_index(){return {};} + static inline constexpr int min_exponent_fast_path(){return {};} // used when fegetround() == FE_TONEARES{} + static inline constexpr int max_exponent_fast_path(){return {};} + static inline constexpr int max_exponent_round_to_even(){return {};} + static inline constexpr int min_exponent_round_to_even(){return {};} + static inline constexpr uint64_t max_mantissa_fast_path(int64_t /*power*/){return {};} + static inline constexpr uint64_t max_mantissa_fast_path(){return {};} // used when fegetround() == FE_TONEARES{} + static inline constexpr int largest_power_of_ten(){return {};} + static inline constexpr int smallest_power_of_ten(){return {};} + static inline constexpr T exact_power_of_ten(int64_t /*power*/){return {};} + static inline constexpr size_t max_digits(){return {};} + static inline constexpr equiv_uint exponent_mask(){return {};} + static inline constexpr equiv_uint mantissa_mask(){return {};} + static inline constexpr equiv_uint hidden_bit_mask(){return {};} }; template @@ -562,18 +564,18 @@ inline constexpr bool is_space(uint8_t c) { return space_lut<>::value[c]; } #endif template -static constexpr uint64_t int_cmp_zeros() +constexpr uint64_t int_cmp_zeros() { static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4), "Unsupported character size"); return (sizeof(UC) == 1) ? 0x3030303030303030 : (sizeof(UC) == 2) ? (uint64_t(UC('0')) << 48 | uint64_t(UC('0')) << 32 | uint64_t(UC('0')) << 16 | UC('0')) : (uint64_t(UC('0')) << 32 | UC('0')); } template -static constexpr int int_cmp_len() +constexpr int int_cmp_len() { return sizeof(uint64_t) / sizeof(UC); } template -static constexpr UC const * str_const_nan() +constexpr UC const * str_const_nan() { return nullptr; } @@ -598,7 +600,7 @@ constexpr char32_t const * str_const_nan() return U"nan"; } template -static constexpr UC const * str_const_inf() +constexpr UC const * str_const_inf() { return nullptr; } @@ -625,4 +627,6 @@ constexpr char32_t const * str_const_inf() }}}} // namespaces +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif diff --git a/include/boost/charconv/detail/fast_float/parse_number.hpp b/include/boost/charconv/detail/fast_float/parse_number.hpp index 9f71d45c2..8b4de59a8 100644 --- a/include/boost/charconv/detail/fast_float/parse_number.hpp +++ b/include/boost/charconv/detail/fast_float/parse_number.hpp @@ -8,15 +8,17 @@ #ifndef BOOST_CHARCONV_DETAIL_FASTFLOAT_PARSE_NUMBER_HPP #define BOOST_CHARCONV_DETAIL_FASTFLOAT_PARSE_NUMBER_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { namespace fast_float { @@ -244,4 +246,6 @@ from_chars_result_t from_chars_advanced(UC const * first, UC const * last, }}}} // namespace fast_float +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif diff --git a/include/boost/charconv/detail/from_chars_integer_impl.hpp b/include/boost/charconv/detail/from_chars_integer_impl.hpp index 69d5e5f95..bbb1888d7 100644 --- a/include/boost/charconv/detail/from_chars_integer_impl.hpp +++ b/include/boost/charconv/detail/from_chars_integer_impl.hpp @@ -5,6 +5,8 @@ #ifndef BOOST_CHARCONV_DETAIL_FROM_CHARS_INTEGER_IMPL_HPP #define BOOST_CHARCONV_DETAIL_FROM_CHARS_INTEGER_IMPL_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #include #include #include @@ -12,17 +14,17 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { -static constexpr unsigned char uchar_values[] = +BOOST_INLINE_CONSTEXPR unsigned char uchar_values[] = {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, @@ -42,7 +44,7 @@ static constexpr unsigned char uchar_values[] = static_assert(sizeof(uchar_values) == 256, "uchar_values should represent all 256 values of unsigned char"); -static constexpr double log_2_table[] = +BOOST_INLINE_CONSTEXPR double log_2_table[] = { 0.0, 0.0, @@ -332,4 +334,6 @@ BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars128(const char* first, }}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_FROM_CHARS_INTEGER_IMPL_HPP diff --git a/include/boost/charconv/detail/from_chars_result.hpp b/include/boost/charconv/detail/from_chars_result.hpp index e4302cfab..96d603b32 100644 --- a/include/boost/charconv/detail/from_chars_result.hpp +++ b/include/boost/charconv/detail/from_chars_result.hpp @@ -5,13 +5,16 @@ #ifndef BOOST_CHARCONV_DETAIL_FROM_CHARS_RESULT_HPP #define BOOST_CHARCONV_DETAIL_FROM_CHARS_RESULT_HPP -#include +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + +#include +#include namespace boost { namespace charconv { // 22.13.3, Primitive numerical input conversion -template +BOOST_CHARCONV_MODULE_EXPORT template struct from_chars_result_t { const UC* ptr; @@ -34,8 +37,10 @@ struct from_chars_result_t constexpr explicit operator bool() const noexcept { return ec == std::errc{}; } }; -using from_chars_result = from_chars_result_t; +BOOST_CHARCONV_MODULE_EXPORT using from_chars_result = from_chars_result_t; }} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_FROM_CHARS_RESULT_HPP diff --git a/include/boost/charconv/detail/integer_search_trees.hpp b/include/boost/charconv/detail/integer_search_trees.hpp index 52e8ec12d..1308c3539 100644 --- a/include/boost/charconv/detail/integer_search_trees.hpp +++ b/include/boost/charconv/detail/integer_search_trees.hpp @@ -5,14 +5,16 @@ #ifndef BOOST_CHARCONV_DETAIL_INTEGER_SEARCH_TREES_HPP #define BOOST_CHARCONV_DETAIL_INTEGER_SEARCH_TREES_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + // https://stackoverflow.com/questions/1489830/efficient-way-to-determine-number-of-digits-in-an-integer?page=1&tab=scoredesc#tab-top // https://graphics.stanford.edu/~seander/bithacks.html #include #include -#include -#include -#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { @@ -191,7 +193,7 @@ BOOST_CHARCONV_CXX14_CONSTEXPR int num_digits(uint128 x) noexcept #endif #ifdef BOOST_CHARCONV_HAS_INT128 -static constexpr std::array powers_of_10 = +BOOST_INLINE_CONSTEXPR std::array powers_of_10 = {{ UINT64_C(1), UINT64_C(10), UINT64_C(100), UINT64_C(1000), UINT64_C(10000), UINT64_C(100000), UINT64_C(1000000), UINT64_C(10000000), UINT64_C(100000000), UINT64_C(1000000000), UINT64_C(10000000000), UINT64_C(100000000000), @@ -271,4 +273,6 @@ BOOST_CHARCONV_CXX14_CONSTEXPR int num_digits(boost::uint128_type x) noexcept }}} // Namespace boost::charconv::detail +#endif // !defined(BOOST_USE_MODULES) || !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_INTEGER_SEARCH_TREES_HPP diff --git a/include/boost/charconv/detail/issignaling.hpp b/include/boost/charconv/detail/issignaling.hpp index 0780c2e89..4c010615e 100644 --- a/include/boost/charconv/detail/issignaling.hpp +++ b/include/boost/charconv/detail/issignaling.hpp @@ -5,16 +5,15 @@ #ifndef BOOST_CHARCONV_DETAIL_ISSIGNALING_HPP #define BOOST_CHARCONV_DETAIL_ISSIGNALING_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include -#include -#include +#include +#include namespace boost { namespace charconv { namespace detail { -template -inline bool issignaling BOOST_PREVENT_MACRO_SUBSTITUTION (T x) noexcept; - #if BOOST_CHARCONV_LDBL_BITS == 128 || defined(BOOST_CHARCONV_HAS_QUADMATH) struct words128 @@ -58,8 +57,7 @@ inline bool issignaling BOOST_PREVENT_MACRO_SUBSTITUTION (T x) noexcept #ifdef BOOST_CHARCONV_HAS_FLOAT16 -template <> -inline bool issignaling BOOST_PREVENT_MACRO_SUBSTITUTION (std::float16_t x) noexcept +inline bool issignaling BOOST_PREVENT_MACRO_SUBSTITUTION (std::float16_t x) noexcept { std::uint16_t bits; std::memcpy(&bits, &x, sizeof(std::uint16_t)); @@ -70,8 +68,7 @@ inline bool issignaling BOOST_PREVENT_MACRO_SUBSTITUTION (std::f #ifdef BOOST_CHARCONV_HAS_BRAINFLOAT16 -template <> -inline bool issignaling BOOST_PREVENT_MACRO_SUBSTITUTION (std::bfloat16_t x) noexcept +inline bool issignaling BOOST_PREVENT_MACRO_SUBSTITUTION (std::bfloat16_t x) noexcept { std::uint16_t bits; std::memcpy(&bits, &x, sizeof(std::uint16_t)); @@ -82,4 +79,6 @@ inline bool issignaling BOOST_PREVENT_MACRO_SUBSTITUTION (std:: }}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_ISSIGNALING_HPP diff --git a/include/boost/charconv/detail/memcpy.hpp b/include/boost/charconv/detail/memcpy.hpp index 1e68315f4..4023db55f 100644 --- a/include/boost/charconv/detail/memcpy.hpp +++ b/include/boost/charconv/detail/memcpy.hpp @@ -5,9 +5,11 @@ #ifndef BOOST_CHARCONV_DETAIL_MEMCPY_HPP #define BOOST_CHARCONV_DETAIL_MEMCPY_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #include -#include -#include +#include +#include // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89689 // GCC 10 added checks for length of memcpy which yields the following warning (converted to error with -Werror) @@ -75,4 +77,6 @@ inline void* memcpy(void* dest, const void* src, std::size_t count) # pragma GCC diagnostic pop #endif +#endif // !defined(BOOST_USE_MODULES) || !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_MEMCPY_HPP diff --git a/include/boost/charconv/detail/parser.hpp b/include/boost/charconv/detail/parser.hpp index 660de6884..c851a62d2 100644 --- a/include/boost/charconv/detail/parser.hpp +++ b/include/boost/charconv/detail/parser.hpp @@ -11,12 +11,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) # pragma GCC diagnostic push diff --git a/include/boost/charconv/detail/ryu/generic_128.hpp b/include/boost/charconv/detail/ryu/generic_128.hpp index 23c5234dd..96ae08154 100644 --- a/include/boost/charconv/detail/ryu/generic_128.hpp +++ b/include/boost/charconv/detail/ryu/generic_128.hpp @@ -6,10 +6,12 @@ #ifndef BOOST_CHARCONV_DETAIL_RYU_GENERIC_128_HPP #define BOOST_CHARCONV_DETAIL_RYU_GENERIC_128_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include -#include +#include #define BOOST_CHARCONV_POW5_TABLE_SIZE 56 #define BOOST_CHARCONV_POW5_BITCOUNT 249 @@ -383,13 +385,13 @@ using ryu_tables = ryu_tables_template; #endif // Returns e == 0 ? 1 : ceil(log_2(5^e)); requires 0 <= e <= 32768. -static BOOST_CHARCONV_CXX14_CONSTEXPR uint32_t pow5bits(const uint32_t e) noexcept +BOOST_CHARCONV_CXX14_CONSTEXPR uint32_t pow5bits(const uint32_t e) noexcept { BOOST_CHARCONV_ASSERT(e <= 1 << 15); return static_cast(((e * UINT64_C(163391164108059)) >> 46) + 1); } -static BOOST_CHARCONV_CXX14_CONSTEXPR +BOOST_CHARCONV_CXX14_CONSTEXPR void mul_128_256_shift( const uint64_t* const a, const uint64_t* const b, const uint32_t shift, const uint32_t corr, @@ -452,7 +454,7 @@ void mul_128_256_shift( } // Computes 5^i in the form required by Ryu, and stores it in the given pointer. -static BOOST_CXX14_CONSTEXPR void generic_computePow5(const uint32_t i, uint64_t* const result) noexcept +BOOST_CXX14_CONSTEXPR void generic_computePow5(const uint32_t i, uint64_t* const result) noexcept { const uint32_t base = i / BOOST_CHARCONV_POW5_TABLE_SIZE; const uint32_t base2 = base * BOOST_CHARCONV_POW5_TABLE_SIZE; @@ -475,7 +477,7 @@ static BOOST_CXX14_CONSTEXPR void generic_computePow5(const uint32_t i, uint64_t } // Computes 5^-i in the form required by Ryu, and stores it in the given pointer. -static BOOST_CXX14_CONSTEXPR void generic_computeInvPow5(const uint32_t i, uint64_t* const result) noexcept +BOOST_CXX14_CONSTEXPR void generic_computeInvPow5(const uint32_t i, uint64_t* const result) noexcept { const uint32_t base = (i + BOOST_CHARCONV_POW5_TABLE_SIZE - 1) / BOOST_CHARCONV_POW5_TABLE_SIZE; const uint32_t base2 = base * BOOST_CHARCONV_POW5_TABLE_SIZE; @@ -497,7 +499,7 @@ static BOOST_CXX14_CONSTEXPR void generic_computeInvPow5(const uint32_t i, uint6 } } -static BOOST_CXX14_CONSTEXPR uint32_t pow5Factor(unsigned_128_type value) noexcept +BOOST_CXX14_CONSTEXPR uint32_t pow5Factor(unsigned_128_type value) noexcept { for (uint32_t count = 0; value > 0; ++count) { @@ -511,19 +513,19 @@ static BOOST_CXX14_CONSTEXPR uint32_t pow5Factor(unsigned_128_type value) noexce } // Returns true if value is divisible by 5^p. -static BOOST_CHARCONV_CXX14_CONSTEXPR bool multipleOfPowerOf5(const unsigned_128_type value, const uint32_t p) noexcept +BOOST_CHARCONV_CXX14_CONSTEXPR bool multipleOfPowerOf5(const unsigned_128_type value, const uint32_t p) noexcept { // I tried a case distinction on p, but there was no performance difference. return pow5Factor(value) >= p; } // Returns true if value is divisible by 2^p. -static BOOST_CHARCONV_CXX14_CONSTEXPR bool multipleOfPowerOf2(const unsigned_128_type value, const uint32_t p) noexcept +BOOST_CHARCONV_CXX14_CONSTEXPR bool multipleOfPowerOf2(const unsigned_128_type value, const uint32_t p) noexcept { return (value & ((static_cast(1) << p) - 1)) == 0; } -static BOOST_CHARCONV_CXX14_CONSTEXPR +BOOST_CHARCONV_CXX14_CONSTEXPR unsigned_128_type mulShift(const unsigned_128_type m, const uint64_t* const mul, const int32_t j) noexcept { BOOST_CHARCONV_ASSERT(j > 128); @@ -536,7 +538,7 @@ unsigned_128_type mulShift(const unsigned_128_type m, const uint64_t* const mul, } // Returns floor(log_10(2^e)). -static BOOST_CHARCONV_CXX14_CONSTEXPR uint32_t log10Pow2(const int32_t e) noexcept +BOOST_CHARCONV_CXX14_CONSTEXPR uint32_t log10Pow2(const int32_t e) noexcept { // The first value this approximation fails for is 2^1651 which is just greater than 10^297. BOOST_CHARCONV_ASSERT(e >= 0); @@ -545,7 +547,7 @@ static BOOST_CHARCONV_CXX14_CONSTEXPR uint32_t log10Pow2(const int32_t e) noexce } // Returns floor(log_10(5^e)). -static BOOST_CHARCONV_CXX14_CONSTEXPR uint32_t log10Pow5(const int32_t e) noexcept +BOOST_CHARCONV_CXX14_CONSTEXPR uint32_t log10Pow5(const int32_t e) noexcept { // The first value this approximation fails for is 5^2621 which is just greater than 10^1832. assert(e >= 0); @@ -555,4 +557,6 @@ static BOOST_CHARCONV_CXX14_CONSTEXPR uint32_t log10Pow5(const int32_t e) noexce }}}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_RYU_GENERIC_128_HPP diff --git a/include/boost/charconv/detail/ryu/ryu_generic_128.hpp b/include/boost/charconv/detail/ryu/ryu_generic_128.hpp index 2047d9a70..1541fbed6 100644 --- a/include/boost/charconv/detail/ryu/ryu_generic_128.hpp +++ b/include/boost/charconv/detail/ryu/ryu_generic_128.hpp @@ -6,23 +6,25 @@ #ifndef BOOST_CHARCONV_DETAIL_RYU_RYU_GENERIC_128_HPP #define BOOST_CHARCONV_DETAIL_RYU_RYU_GENERIC_128_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include #include #include -#include -#include -#include +#include +#include +#include #ifdef BOOST_CHARCONV_DEBUG -# include +# include #endif namespace boost { namespace charconv { namespace detail { namespace ryu { -static constexpr int32_t fd128_exceptional_exponent = 0x7FFFFFFF; -static constexpr unsigned_128_type one = 1; +BOOST_INLINE_CONSTEXPR int32_t fd128_exceptional_exponent = 0x7FFFFFFF; +BOOST_INLINE_CONSTEXPR unsigned_128_type one = 1; struct floating_decimal_128 { @@ -32,7 +34,7 @@ struct floating_decimal_128 }; #ifdef BOOST_CHARCONV_DEBUG -static char* s(unsigned_128_type v) { +inline char* s(unsigned_128_type v) { int len = num_digits(v); char* b = static_cast(malloc((len + 1) * sizeof(char))); for (int i = 0; i < len; i++) { @@ -45,7 +47,7 @@ static char* s(unsigned_128_type v) { } #endif -static inline struct floating_decimal_128 generic_binary_to_decimal( +inline struct floating_decimal_128 generic_binary_to_decimal( const unsigned_128_type bits, const uint32_t mantissaBits, const uint32_t exponentBits, const bool explicitLeadingBit) noexcept { @@ -282,7 +284,7 @@ static inline struct floating_decimal_128 generic_binary_to_decimal( return {output, exp, ieeeSign}; } -static inline int copy_special_str(char* result, const std::ptrdiff_t result_size, const struct floating_decimal_128 fd) noexcept +inline int copy_special_str(char* result, const std::ptrdiff_t result_size, const struct floating_decimal_128 fd) noexcept { if (fd.sign) { @@ -361,7 +363,7 @@ static inline int copy_special_str(char* result, const std::ptrdiff_t result_siz return -1; } -static inline int generic_to_chars_fixed(const struct floating_decimal_128 v, char* result, const ptrdiff_t result_size, int precision) noexcept +inline int generic_to_chars_fixed(const struct floating_decimal_128 v, char* result, const ptrdiff_t result_size, int precision) noexcept { if (v.exponent == fd128_exceptional_exponent) { @@ -509,7 +511,7 @@ static inline int generic_to_chars_fixed(const struct floating_decimal_128 v, ch // Maximal char buffer requirement: // sign + mantissa digits + decimal dot + 'E' + exponent sign + exponent digits // = 1 + 39 + 1 + 1 + 1 + 10 = 53 -static inline int generic_to_chars(const struct floating_decimal_128 v, char* result, const ptrdiff_t result_size, +inline int generic_to_chars(const struct floating_decimal_128 v, char* result, const ptrdiff_t result_size, chars_format fmt = chars_format::general, int precision = -1) noexcept { if (v.exponent == fd128_exceptional_exponent) @@ -678,7 +680,7 @@ static inline int generic_to_chars(const struct floating_decimal_128 v, char* re return static_cast(index); } -static inline struct floating_decimal_128 float_to_fd128(float f) noexcept +inline struct floating_decimal_128 float_to_fd128(float f) noexcept { static_assert(sizeof(float) == sizeof(uint32_t), "Float is not 32 bits"); uint32_t bits = 0; @@ -686,7 +688,7 @@ static inline struct floating_decimal_128 float_to_fd128(float f) noexcept return generic_binary_to_decimal(bits, 23, 8, false); } -static inline struct floating_decimal_128 double_to_fd128(double d) noexcept +inline struct floating_decimal_128 double_to_fd128(double d) noexcept { static_assert(sizeof(double) == sizeof(uint64_t), "Double is not 64 bits"); uint64_t bits = 0; @@ -698,7 +700,7 @@ static inline struct floating_decimal_128 double_to_fd128(double d) noexcept #ifdef BOOST_CHARCONV_HAS_FLOAT16 -static inline struct floating_decimal_128 float16_t_to_fd128(std::float16_t f) noexcept +inline struct floating_decimal_128 float16_t_to_fd128(std::float16_t f) noexcept { uint16_t bits = 0; std::memcpy(&bits, &f, sizeof(std::float16_t)); @@ -709,7 +711,7 @@ static inline struct floating_decimal_128 float16_t_to_fd128(std::float16_t f) n #ifdef BOOST_CHARCONV_HAS_BRAINFLOAT16 -static inline struct floating_decimal_128 float16_t_to_fd128(std::bfloat16_t f) noexcept +inline struct floating_decimal_128 float16_t_to_fd128(std::bfloat16_t f) noexcept { uint16_t bits = 0; std::memcpy(&bits, &f, sizeof(std::bfloat16_t)); @@ -720,7 +722,7 @@ static inline struct floating_decimal_128 float16_t_to_fd128(std::bfloat16_t f) #if BOOST_CHARCONV_LDBL_BITS == 80 -static inline struct floating_decimal_128 long_double_to_fd128(long double d) noexcept +inline struct floating_decimal_128 long_double_to_fd128(long double d) noexcept { #ifdef BOOST_CHARCONV_HAS_INT128 unsigned_128_type bits = 0; @@ -744,7 +746,7 @@ static inline struct floating_decimal_128 long_double_to_fd128(long double d) no #elif BOOST_CHARCONV_LDBL_BITS == 128 -static inline struct floating_decimal_128 long_double_to_fd128(long double d) noexcept +inline struct floating_decimal_128 long_double_to_fd128(long double d) noexcept { unsigned_128_type bits = 0; std::memcpy(&bits, &d, sizeof(long double)); @@ -764,4 +766,6 @@ static inline struct floating_decimal_128 long_double_to_fd128(long double d) no }}}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif //BOOST_RYU_GENERIC_128_HPP diff --git a/include/boost/charconv/detail/significand_tables.hpp b/include/boost/charconv/detail/significand_tables.hpp index 51dd71f45..7825046b5 100644 --- a/include/boost/charconv/detail/significand_tables.hpp +++ b/include/boost/charconv/detail/significand_tables.hpp @@ -6,8 +6,10 @@ #ifndef BOOST_CHARCONV_DETAIL_SIGNIFICAND_TABLES_HPP #define BOOST_CHARCONV_DETAIL_SIGNIFICAND_TABLES_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include -#include +#include // The significand of a floating point number is often referred to as the mantissa. // Using the term mantissa is discouraged by IEEE 1516 @@ -688,4 +690,6 @@ using significands_table = significand_template; }}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_DETAIL_SIGNIFICAND_TABLES_HPP diff --git a/include/boost/charconv/detail/to_chars_integer_impl.hpp b/include/boost/charconv/detail/to_chars_integer_impl.hpp index 5b256c26f..6ba99557e 100644 --- a/include/boost/charconv/detail/to_chars_integer_impl.hpp +++ b/include/boost/charconv/detail/to_chars_integer_impl.hpp @@ -7,29 +7,31 @@ #ifndef BOOST_CHARCONV_DETAIL_TO_CHARS_INTEGER_IMPL_HPP #define BOOST_CHARCONV_DETAIL_TO_CHARS_INTEGER_IMPL_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #include #include #include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { -static constexpr char radix_table[] = { +BOOST_INLINE_CONSTEXPR char radix_table[] = { '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', @@ -52,7 +54,7 @@ static constexpr char radix_table[] = { '9', '5', '9', '6', '9', '7', '9', '8', '9', '9' }; -static constexpr char digit_table[] = { +BOOST_INLINE_CONSTEXPR char digit_table[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', @@ -456,4 +458,6 @@ BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars128(char* first, char* last, In }}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif //BOOST_CHARCONV_DETAIL_TO_CHARS_INTEGER_IMPL_HPP diff --git a/include/boost/charconv/detail/to_chars_result.hpp b/include/boost/charconv/detail/to_chars_result.hpp index e564fe6cd..71d3359c6 100644 --- a/include/boost/charconv/detail/to_chars_result.hpp +++ b/include/boost/charconv/detail/to_chars_result.hpp @@ -5,13 +5,15 @@ #ifndef BOOST_CHARCONV_DETAIL_TO_CHARS_RESULT_HPP #define BOOST_CHARCONV_DETAIL_TO_CHARS_RESULT_HPP -#include +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + +#include // 22.13.2, Primitive numerical output conversion namespace boost { namespace charconv { -struct to_chars_result +BOOST_CHARCONV_MODULE_EXPORT struct to_chars_result { char *ptr; std::errc ec; @@ -31,4 +33,6 @@ struct to_chars_result }} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif //BOOST_CHARCONV_DETAIL_TO_CHARS_RESULT_HPP diff --git a/include/boost/charconv/detail/type_traits.hpp b/include/boost/charconv/detail/type_traits.hpp index 416055516..f5377abd6 100644 --- a/include/boost/charconv/detail/type_traits.hpp +++ b/include/boost/charconv/detail/type_traits.hpp @@ -5,8 +5,10 @@ #ifndef BOOST_CHARCONV_DETAIL_TYPE_TRAITS_HPP #define BOOST_CHARCONV_DETAIL_TYPE_TRAITS_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERFACE_UNIT) + #include -#include +#include namespace boost { namespace charconv { namespace detail { @@ -64,4 +66,6 @@ struct make_signed { using type = boost::int128_type; }; }}} // Namespaces +#endif // !defined(BOOST_USE_MODULES) || !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif //BOOST_CHARCONV_DETAIL_TYPE_TRAITS_HPP diff --git a/include/boost/charconv/from_chars.hpp b/include/boost/charconv/from_chars.hpp index 0bef0b5f5..d59faa6b2 100644 --- a/include/boost/charconv/from_chars.hpp +++ b/include/boost/charconv/from_chars.hpp @@ -6,6 +6,17 @@ #ifndef BOOST_CHARCONV_FROM_CHARS_HPP_INCLUDED #define BOOST_CHARCONV_FROM_CHARS_HPP_INCLUDED +#if defined(BOOST_USE_MODULES) && !defined(BOOST_CHARCONV_INTERFACE_UNIT) + +#ifndef BOOST_IN_MODULE_PURVIEW +import boost.charconv; +#ifndef BOOST_CHARCONV_CONSTEXPR +#define BOOST_CHARCONV_CONSTEXPR constexpr +#endif +#endif + +#else + #include #include #include @@ -13,121 +24,121 @@ #include #include #include -#include +#include namespace boost { namespace charconv { // integer overloads -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, bool& value, int base = 10) noexcept = delete; -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, char& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, bool& value, int base = 10) noexcept = delete; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, char& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, signed char& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, signed char& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, unsigned char& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, unsigned char& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, short& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, short& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, unsigned short& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, unsigned short& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, int& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, int& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, unsigned int& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, unsigned int& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, long& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, long& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, unsigned long& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, unsigned long& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, long long& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, long long& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, unsigned long long& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, unsigned long long& value, int base = 10) noexcept { return detail::from_chars(first, last, value, base); } #ifdef BOOST_CHARCONV_HAS_INT128 -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, boost::int128_type& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, boost::int128_type& value, int base = 10) noexcept { return detail::from_chars128(first, last, value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, boost::uint128_type& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(const char* first, const char* last, boost::uint128_type& value, int base = 10) noexcept { return detail::from_chars128(first, last, value, base); } #endif -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, bool& value, int base = 10) noexcept = delete; -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, char& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, bool& value, int base = 10) noexcept = delete; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, char& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, signed char& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, signed char& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, unsigned char& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, unsigned char& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, short& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, short& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, unsigned short& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, unsigned short& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, int& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, int& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, unsigned int& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, unsigned int& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, long& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, long& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, unsigned long& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, unsigned long& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, long long& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, long long& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, unsigned long long& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, unsigned long long& value, int base = 10) noexcept { return detail::from_chars(sv.data(), sv.data() + sv.size(), value, base); } #ifdef BOOST_CHARCONV_HAS_INT128 -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, boost::int128_type& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, boost::int128_type& value, int base = 10) noexcept { return detail::from_chars128(sv.data(), sv.data() + sv.size(), value, base); } -BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, boost::uint128_type& value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_view sv, boost::uint128_type& value, int base = 10) noexcept { return detail::from_chars128(sv.data(), sv.data() + sv.size(), value, base); } @@ -137,119 +148,121 @@ BOOST_CHARCONV_GCC5_CONSTEXPR from_chars_result from_chars(boost::core::string_v // Floating Point //---------------------------------------------------------------------------------------------------------------------- -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, float& value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, double& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, float& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, double& value, chars_format fmt = chars_format::general) noexcept; #ifndef BOOST_CHARCONV_UNSUPPORTED_LONG_DOUBLE -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, long double& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, long double& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_QUADMATH -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, __float128& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, __float128& value, chars_format fmt = chars_format::general) noexcept; #endif // types #ifdef BOOST_CHARCONV_HAS_FLOAT16 -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, std::float16_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, std::float16_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT32 -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, std::float32_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, std::float32_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT64 -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, std::float64_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, std::float64_t& value, chars_format fmt = chars_format::general) noexcept; #endif #if defined(BOOST_CHARCONV_HAS_STDFLOAT128) && defined(BOOST_CHARCONV_HAS_QUADMATH) -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, std::float128_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, std::float128_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_BRAINFLOAT16 -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, std::bfloat16_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(const char* first, const char* last, std::bfloat16_t& value, chars_format fmt = chars_format::general) noexcept; #endif -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, float& value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, double& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, float& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, double& value, chars_format fmt = chars_format::general) noexcept; #ifndef BOOST_CHARCONV_UNSUPPORTED_LONG_DOUBLE -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, long double& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, long double& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_QUADMATH -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, __float128& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, __float128& value, chars_format fmt = chars_format::general) noexcept; #endif // types #ifdef BOOST_CHARCONV_HAS_FLOAT16 -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, std::float16_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, std::float16_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT32 -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, std::float32_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, std::float32_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT64 -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, std::float64_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, std::float64_t& value, chars_format fmt = chars_format::general) noexcept; #endif #if defined(BOOST_CHARCONV_HAS_STDFLOAT128) && defined(BOOST_CHARCONV_HAS_QUADMATH) -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, std::float128_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, std::float128_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_BRAINFLOAT16 -BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, std::bfloat16_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars_erange(boost::core::string_view sv, std::bfloat16_t& value, chars_format fmt = chars_format::general) noexcept; #endif // The following adhere to the standard library definition with std::errc::result_out_of_range // Returns value unmodified // See: https://github.com/cppalliance/charconv/issues/110 -BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, float& value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, double& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, float& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, double& value, chars_format fmt = chars_format::general) noexcept; #ifndef BOOST_CHARCONV_UNSUPPORTED_LONG_DOUBLE -BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, long double& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, long double& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_QUADMATH -BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, __float128& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, __float128& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT16 -BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, std::float16_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, std::float16_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT32 -BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, std::float32_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, std::float32_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT64 -BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, std::float64_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, std::float64_t& value, chars_format fmt = chars_format::general) noexcept; #endif #if defined(BOOST_CHARCONV_HAS_STDFLOAT128) && defined(BOOST_CHARCONV_HAS_QUADMATH) -BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, std::float128_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, std::float128_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_BRAINFLOAT16 -BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, std::bfloat16_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(const char* first, const char* last, std::bfloat16_t& value, chars_format fmt = chars_format::general) noexcept; #endif -BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, float& value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, double& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, float& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, double& value, chars_format fmt = chars_format::general) noexcept; #ifndef BOOST_CHARCONV_UNSUPPORTED_LONG_DOUBLE -BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, long double& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, long double& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_QUADMATH -BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, __float128& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, __float128& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT16 -BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, std::float16_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, std::float16_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT32 -BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, std::float32_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, std::float32_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT64 -BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, std::float64_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, std::float64_t& value, chars_format fmt = chars_format::general) noexcept; #endif #if defined(BOOST_CHARCONV_HAS_STDFLOAT128) && defined(BOOST_CHARCONV_HAS_QUADMATH) -BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, std::float128_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, std::float128_t& value, chars_format fmt = chars_format::general) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_BRAINFLOAT16 -BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, std::bfloat16_t& value, chars_format fmt = chars_format::general) noexcept; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL from_chars_result from_chars(boost::core::string_view sv, std::bfloat16_t& value, chars_format fmt = chars_format::general) noexcept; #endif } // namespace charconv } // namespace boost +#endif // defined(BOOST_USE_MODULES) && !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // #ifndef BOOST_CHARCONV_FROM_CHARS_HPP_INCLUDED diff --git a/include/boost/charconv/limits.hpp b/include/boost/charconv/limits.hpp index f62809f30..4568b23a8 100644 --- a/include/boost/charconv/limits.hpp +++ b/include/boost/charconv/limits.hpp @@ -5,9 +5,21 @@ #ifndef BOOST_CHARCONV_LIMITS_HPP #define BOOST_CHARCONV_LIMITS_HPP +#if defined(BOOST_USE_MODULES) && !defined(BOOST_CHARCONV_INTERFACE_UNIT) + +#ifndef BOOST_IN_MODULE_PURVIEW +import boost.charconv; +#ifndef BOOST_CHARCONV_CONSTEXPR +#define BOOST_CHARCONV_CONSTEXPR constexpr +#endif +#endif + +#else + #include -#include -#include +#include +#include +#include namespace boost { namespace charconv { @@ -41,7 +53,7 @@ template struct is_uint128: std::false_type {}; } // namespace detail -template struct limits +BOOST_CHARCONV_MODULE_EXPORT template struct limits { BOOST_ATTRIBUTE_UNUSED static constexpr int max_chars10 = @@ -93,4 +105,6 @@ template BOOST_ATTRIBUTE_UNUSED constexpr int limits::max_chars; }} // namespace boost::charconv +#endif // defined(BOOST_USE_MODULES) && !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // BOOST_CHARCONV_LIMITS_HPP diff --git a/include/boost/charconv/to_chars.hpp b/include/boost/charconv/to_chars.hpp index 7192fda57..7e6cd0f23 100644 --- a/include/boost/charconv/to_chars.hpp +++ b/include/boost/charconv/to_chars.hpp @@ -7,6 +7,17 @@ #ifndef BOOST_CHARCONV_TO_CHARS_HPP_INCLUDED #define BOOST_CHARCONV_TO_CHARS_HPP_INCLUDED +#if defined(BOOST_USE_MODULES) && !defined(BOOST_CHARCONV_INTERFACE_UNIT) + +#ifndef BOOST_IN_MODULE_PURVIEW +import boost.charconv; +#ifndef BOOST_CHARCONV_CONSTEXPR +#define BOOST_CHARCONV_CONSTEXPR constexpr +#endif +#endif + +#else + #include #include #include @@ -16,58 +27,58 @@ namespace boost { namespace charconv { // integer overloads -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, bool value, int base) noexcept = delete; -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, char value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, bool value, int base) noexcept = delete; +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, char value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, signed char value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, signed char value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned char value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned char value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, short value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, short value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned short value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned short value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, int value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, int value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned int value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned int value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, long value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, long value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned long value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned long value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, long long value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, long long value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned long long value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned long long value, int base = 10) noexcept { return detail::to_chars_int(first, last, value, base); } #ifdef BOOST_CHARCONV_HAS_INT128 -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, boost::int128_type value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, boost::int128_type value, int base = 10) noexcept { return detail::to_chars128(first, last, value, base); } -BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, boost::uint128_type value, int base = 10) noexcept +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, boost::uint128_type value, int base = 10) noexcept { return detail::to_chars128(first, last, value, base); } @@ -77,71 +88,73 @@ BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, boost // Floating Point //---------------------------------------------------------------------------------------------------------------------- -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, float value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, float value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, double value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, double value, chars_format fmt = chars_format::general) noexcept; #ifndef BOOST_CHARCONV_UNSUPPORTED_LONG_DOUBLE -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, long double value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, long double value, chars_format fmt = chars_format::general) noexcept; #endif -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, float value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, float value, chars_format fmt, int precision) noexcept; -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, double value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, double value, chars_format fmt, int precision) noexcept; #ifndef BOOST_CHARCONV_UNSUPPORTED_LONG_DOUBLE -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, long double value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, long double value, chars_format fmt, int precision) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_QUADMATH -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, __float128 value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, __float128 value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, __float128 value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, __float128 value, chars_format fmt, int precision) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT16 -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float16_t value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float16_t value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float16_t value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float16_t value, chars_format fmt, int precision) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT32 -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float32_t value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float32_t value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float32_t value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float32_t value, chars_format fmt, int precision) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_FLOAT64 -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float64_t value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float64_t value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float64_t value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float64_t value, chars_format fmt, int precision) noexcept; #endif #if defined(BOOST_CHARCONV_HAS_STDFLOAT128) && defined(BOOST_CHARCONV_HAS_QUADMATH) -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float128_t value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float128_t value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float128_t value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float128_t value, chars_format fmt, int precision) noexcept; #endif #ifdef BOOST_CHARCONV_HAS_BRAINFLOAT16 -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::bfloat16_t value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::bfloat16_t value, chars_format fmt = chars_format::general) noexcept; -BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::bfloat16_t value, +BOOST_CHARCONV_MODULE_EXPORT BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::bfloat16_t value, chars_format fmt, int precision) noexcept; #endif } // namespace charconv } // namespace boost +#endif // defined(BOOST_USE_MODULES) && !defined(BOOST_CHARCONV_INTERFACE_UNIT) + #endif // #ifndef BOOST_CHARCONV_TO_CHARS_HPP_INCLUDED diff --git a/modules/boost_charconv.cppm b/modules/boost_charconv.cppm new file mode 100644 index 000000000..661629b13 --- /dev/null +++ b/modules/boost_charconv.cppm @@ -0,0 +1,9 @@ +// Copyright 2026 Ruben Perez +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +// Having the interface in a separate file works around this gcc bug: +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124309 + +export module boost.charconv; +export import :interface; diff --git a/modules/boost_charconv_interface.cppm b/modules/boost_charconv_interface.cppm new file mode 100644 index 000000000..08303e19a --- /dev/null +++ b/modules/boost_charconv_interface.cppm @@ -0,0 +1,26 @@ +// Copyright 2026 Ruben Perez +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +module; + +#include // floating-point macros +#include // stdfloat macros are pulled by this header, too +#include // int macros +#include // CHAR_BIT and other C limits macros +#include +#include +#include +#include +#include + +export module boost.charconv:interface; + +import std; +import std.compat; +import boost.core; + +#define BOOST_CHARCONV_INTERFACE_UNIT +#define BOOST_IN_MODULE_PURVIEW + +#include diff --git a/src/float128_impl.hpp b/src/float128_impl.hpp index 3b9e44ab6..b6cb136e4 100644 --- a/src/float128_impl.hpp +++ b/src/float128_impl.hpp @@ -5,20 +5,22 @@ #ifndef BOOST_CHARCONV_FLOAT128_IMPL_HPP #define BOOST_CHARCONV_FLOAT128_IMPL_HPP +#if !defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #include #include #include #include #include #include -#include -#include -#include +#include +#include +#include // Only add in float128 support if the build system says it can #ifdef BOOST_CHARCONV_HAS_QUADMATH -#include +#include "quadmath_wrapper.hpp" namespace boost { namespace charconv { @@ -70,7 +72,7 @@ inline struct floating_decimal_128 stdfloat128_to_fd128(std::float128_t d) noexc // fast_float // -------------------------------------------------------------------------------------------------------------------- -static constexpr __float128 powers_of_tenq[] = { +BOOST_INLINE_CONSTEXPR __float128 powers_of_tenq[] = { 1e0Q, 1e1Q, 1e2Q, 1e3Q, 1e4Q, 1e5Q, 1e6Q, 1e7Q, 1e8Q, 1e9Q, 1e10Q, 1e11Q, 1e12Q, 1e13Q, 1e14Q, 1e15Q, 1e16Q, 1e17Q, 1e18Q, 1e19Q, 1e20Q, @@ -354,4 +356,6 @@ inline bool issignaling<__float128> BOOST_PREVENT_MACRO_SUBSTITUTION (__float128 #endif //BOOST_CHARCONV_HAS_QUADMATH +#endif //!defined(BOOST_USE_MODULES) || defined(BOOST_CHARCONV_INTERNAL_PARTITION_UNIT) + #endif //BOOST_CHARCONV_FLOAT128_IMPL_HPP diff --git a/src/from_chars.cc b/src/from_chars.cc new file mode 100644 index 000000000..99a525535 --- /dev/null +++ b/src/from_chars.cc @@ -0,0 +1,25 @@ +// Copyright 2026 Ruben Perez +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt +module; + +#include +#include +#include +#include "quadmath_wrapper.hpp" +#include +#include +#include +#include + + +module boost.charconv; + +import :helpers; +import std; +import std.compat; +import boost.core; + +#define BOOST_IN_MODULE_PURVIEW + +#include "from_chars.cpp" diff --git a/src/from_chars.cpp b/src/from_chars.cpp index 0c313fad4..6bcc6d83c 100644 --- a/src/from_chars.cpp +++ b/src/from_chars.cpp @@ -16,12 +16,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #if BOOST_CHARCONV_LDBL_BITS > 64 # include diff --git a/src/from_chars_float_impl.hpp b/src/from_chars_float_impl.hpp index b0ed68d6b..6063af931 100644 --- a/src/from_chars_float_impl.hpp +++ b/src/from_chars_float_impl.hpp @@ -14,9 +14,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { diff --git a/src/helpers.cppm b/src/helpers.cppm new file mode 100644 index 000000000..584293107 --- /dev/null +++ b/src/helpers.cppm @@ -0,0 +1,34 @@ +// Copyright 2026 Ruben Perez +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt +module; + +#include // printf format constants +#include // math macros +#include // CHAR_BIT and other C limits macros +#include +#include "quadmath_wrapper.hpp" + +#include +#include +#include + +module boost.charconv:helpers; + +import :interface; + +#define BOOST_IN_MODULE_PURVIEW +#define BOOST_CHARCONV_INTERNAL_PARTITION_UNIT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "float128_impl.hpp" diff --git a/src/quadmath_wrapper.hpp b/src/quadmath_wrapper.hpp new file mode 100644 index 000000000..d3231c911 --- /dev/null +++ b/src/quadmath_wrapper.hpp @@ -0,0 +1,10 @@ +// Module-safe wrapper for quadmath +#if defined(BOOST_IN_MODULE_PURVIEW) && !defined(BOOST_CHARCONV_QUADMATH_INCLUDED) +# error "Please #include "quadmath_wrapper.hpp" in your module global fragment" +#endif + +#define BOOST_CHARCONV_QUADMATH_INCLUDED + +#ifdef BOOST_CHARCONV_HAS_QUADMATH +#include +#endif diff --git a/src/to_chars.cc b/src/to_chars.cc new file mode 100644 index 000000000..cb7e7ec69 --- /dev/null +++ b/src/to_chars.cc @@ -0,0 +1,24 @@ +// Copyright 2026 Ruben Perez +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt +module; + +#include +#include +#include +#include +#include "quadmath_wrapper.hpp" +#include +#include +#include +#include + +module boost.charconv; + +import :helpers; +import std; +import boost.core; + +#define BOOST_IN_MODULE_PURVIEW + +#include "to_chars.cpp" diff --git a/src/to_chars.cpp b/src/to_chars.cpp index 0bdde32ea..dba1b5692 100644 --- a/src/to_chars.cpp +++ b/src/to_chars.cpp @@ -8,11 +8,11 @@ #include "to_chars_float_impl.hpp" #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace boost { namespace charconv { namespace detail { namespace to_chars_detail { diff --git a/src/to_chars_float_impl.hpp b/src/to_chars_float_impl.hpp index 916d0c4e8..3b5f83220 100644 --- a/src/to_chars_float_impl.hpp +++ b/src/to_chars_float_impl.hpp @@ -22,21 +22,21 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef BOOST_CHARCONV_DEBUG_FIXED -#include -#include +#include +#include #endif #if (BOOST_CHARCONV_LDBL_BITS == 80 || BOOST_CHARCONV_LDBL_BITS == 128) @@ -48,9 +48,6 @@ namespace boost { namespace charconv { namespace detail { -template -inline to_chars_result to_chars_nonfinite(char* first, char* last, Real value, int classification) noexcept; - #if BOOST_CHARCONV_LDBL_BITS == 128 || defined(BOOST_CHARCONV_HAS_STDFLOAT128) || defined(BOOST_CHARCONV_HAS_FLOAT16) || defined(BOOST_CHARCONV_HAS_BRAINFLOAT16) template @@ -129,8 +126,7 @@ inline to_chars_result to_chars_nonfinite(char* first, char* last, Real value, i # pragma GCC diagnostic ignored "-Wfloat-conversion" #endif -template <> -inline to_chars_result to_chars_nonfinite<__float128>(char* first, char* last, __float128 value, int classification) noexcept +inline to_chars_result to_chars_nonfinite(char* first, char* last, __float128 value, int classification) noexcept { std::ptrdiff_t offset {}; std::ptrdiff_t buffer_size = last - first; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7bf0e6e09..6a81d450b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,8 +6,10 @@ include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) if(HAVE_BOOST_TEST) -# https://crascit.com/2015/03/28/enabling-cxx11-in-cmake/ -set(CMAKE_CXX_EXTENSIONS OFF) +if(BOOST_USE_MODULES) + set(CMAKE_CXX_MODULE_STD ON) +endif() + boost_test_jamfile(FILE Jamfile LINK_LIBRARIES Boost::charconv Boost::core Boost::assert) endif() diff --git a/test/P2497.cpp b/test/P2497.cpp index 9359f9c03..5218439b5 100644 --- a/test/P2497.cpp +++ b/test/P2497.cpp @@ -2,15 +2,16 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include // No overflows, negative numbers, locales, etc. template diff --git a/test/cmake_install_test/CMakeLists.txt b/test/cmake_install_test/CMakeLists.txt index a2531dec8..5242651da 100644 --- a/test/cmake_install_test/CMakeLists.txt +++ b/test/cmake_install_test/CMakeLists.txt @@ -2,7 +2,7 @@ # Distributed under the Boost Software License, Version 1.0. # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt -cmake_minimum_required(VERSION 3.5...3.16) +cmake_minimum_required(VERSION 3.5...4.2) project(cmake_install_test LANGUAGES CXX) diff --git a/test/cmake_subdir_test/CMakeLists.txt b/test/cmake_subdir_test/CMakeLists.txt index 57a044253..0c5d2cdd8 100644 --- a/test/cmake_subdir_test/CMakeLists.txt +++ b/test/cmake_subdir_test/CMakeLists.txt @@ -2,7 +2,7 @@ # Distributed under the Boost Software License, Version 1.0. # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt -cmake_minimum_required(VERSION 3.5...3.20) +cmake_minimum_required(VERSION 3.5...4.2) project(cmake_subdir_test LANGUAGES CXX) diff --git a/test/from_chars.cpp b/test/from_chars.cpp index 091091e66..76c5000e3 100644 --- a/test/from_chars.cpp +++ b/test/from_chars.cpp @@ -3,19 +3,20 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #if defined(__has_include) # if __has_include() -# include +# include # endif #endif diff --git a/test/from_chars_STL_comp.cpp b/test/from_chars_STL_comp.cpp index 7823a34c0..59dd31f2a 100644 --- a/test/from_chars_STL_comp.cpp +++ b/test/from_chars_STL_comp.cpp @@ -6,15 +6,16 @@ #if !defined(BOOST_NO_CXX17_HDR_CHARCONV) && (!defined(__clang_major__) || (defined(__clang_major__) && __clang_major__ > 7)) +#include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include template void test() diff --git a/test/from_chars_float.cpp b/test/from_chars_float.cpp index cf810b559..401470db4 100644 --- a/test/from_chars_float.cpp +++ b/test/from_chars_float.cpp @@ -2,6 +2,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include "../src/from_chars_float_impl.hpp" #include #include @@ -1930,3 +1938,5 @@ int main() return boost::report_errors(); } + +#endif diff --git a/test/from_chars_float2.cpp b/test/from_chars_float2.cpp index 8e0e64260..65d2ae03e 100644 --- a/test/from_chars_float2.cpp +++ b/test/from_chars_float2.cpp @@ -2,10 +2,11 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include #include +#include #include #include -#include static boost::detail::splitmix64 rng; diff --git a/test/from_chars_string_view.cpp b/test/from_chars_string_view.cpp index 358894281..c9b2c8134 100644 --- a/test/from_chars_string_view.cpp +++ b/test/from_chars_string_view.cpp @@ -2,17 +2,18 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include #include #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW) -# include +# include #endif static std::mt19937_64 rng(42); diff --git a/test/github_issue_122.cpp b/test/github_issue_122.cpp index c8495b285..93c943571 100644 --- a/test/github_issue_122.cpp +++ b/test/github_issue_122.cpp @@ -3,6 +3,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include #include #include @@ -68,3 +76,5 @@ int main() } #endif + +#endif diff --git a/test/github_issue_152.cpp b/test/github_issue_152.cpp index 51c188df9..6182be591 100644 --- a/test/github_issue_152.cpp +++ b/test/github_issue_152.cpp @@ -2,14 +2,15 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include constexpr std::size_t N = 1024; static std::mt19937_64 rng(42); diff --git a/test/github_issue_152_float128.cpp b/test/github_issue_152_float128.cpp index 6c64ea4d8..0ffb2a663 100644 --- a/test/github_issue_152_float128.cpp +++ b/test/github_issue_152_float128.cpp @@ -2,12 +2,12 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt -#include -#include - #ifdef BOOST_CHARCONV_HAS_QUADMATH #include +#include +#include +#include std::ostream& operator<<( std::ostream& os, __float128 v ) { @@ -27,11 +27,11 @@ std::ostream& operator<<( std::ostream& os, std::float128_t v ) #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include constexpr std::size_t N = 1024; static std::mt19937_64 rng(42); diff --git a/test/github_issue_156.cpp b/test/github_issue_156.cpp index 95398be1e..ba67ab967 100644 --- a/test/github_issue_156.cpp +++ b/test/github_issue_156.cpp @@ -4,10 +4,11 @@ // // See: https://github.com/cppalliance/charconv/issues/156 +#include #include #include -#include -#include +#include +#include #ifdef BOOST_CHARCONV_HAS_BRAINFLOAT16 diff --git a/test/github_issue_166_float128.cpp b/test/github_issue_166_float128.cpp index 9812bdb71..409d398ab 100644 --- a/test/github_issue_166_float128.cpp +++ b/test/github_issue_166_float128.cpp @@ -4,9 +4,10 @@ // // See: https://github.com/boostorg/charconv/issues/166 +#include #include #include -#include +#include template void test() diff --git a/test/github_issue_186.cpp b/test/github_issue_186.cpp index 628da1e7f..ed19e97a6 100644 --- a/test/github_issue_186.cpp +++ b/test/github_issue_186.cpp @@ -4,10 +4,11 @@ // // See: https://github.com/boostorg/charconv/issues/186 +#include #include #include -#include -#include +#include +#include template void force_overflow(T value) diff --git a/test/github_issue_212.cpp b/test/github_issue_212.cpp index 110774e2d..beafd2c06 100644 --- a/test/github_issue_212.cpp +++ b/test/github_issue_212.cpp @@ -2,11 +2,12 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include +#include #include #include -#include -#include -#include +#include +#include template void test() diff --git a/test/github_issue_280.cpp b/test/github_issue_280.cpp index 5dafef9f7..f6e371877 100644 --- a/test/github_issue_280.cpp +++ b/test/github_issue_280.cpp @@ -4,9 +4,10 @@ // // See: https://github.com/boostorg/charconv/issues/280 +#include #include #include -#include +#include template void test(const char* result_string) diff --git a/test/github_issue_int128_320.cpp b/test/github_issue_int128_320.cpp index 4d4842da4..f2b6fe467 100644 --- a/test/github_issue_int128_320.cpp +++ b/test/github_issue_int128_320.cpp @@ -4,6 +4,7 @@ // // See: https://github.com/cppalliance/int128/issues/320 +#include #include #ifdef BOOST_CHARCONV_HAS_INT128 @@ -14,8 +15,8 @@ #endif #include -#include -#include +#include +#include void toChars(char* ptr, char* ptrEnd, boost::int128_type i128) { diff --git a/test/limits.cpp b/test/limits.cpp index 7fe02ca76..4d489654b 100644 --- a/test/limits.cpp +++ b/test/limits.cpp @@ -3,6 +3,7 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include #include #ifdef BOOST_HAS_INT128 @@ -12,7 +13,7 @@ // won't be visible to BOOST_TEST_EQ // LCOV_EXCL_START -#include +#include static char* mini_to_chars( char (&buffer)[ 64 ], boost::uint128_type v ) { @@ -64,9 +65,9 @@ std::ostream& operator<<( std::ostream& os, boost::int128_type v ) #include #include #include -#include -#include -#include +#include +#include +#include void test_odr_use( int const* ); diff --git a/test/limits_link_1.cpp b/test/limits_link_1.cpp index a7b2eaf9b..7030438e2 100644 --- a/test/limits_link_1.cpp +++ b/test/limits_link_1.cpp @@ -2,8 +2,8 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include #include -#include void test_odr_use( int const* ); diff --git a/test/limits_link_2.cpp b/test/limits_link_2.cpp index b45c627fd..c619a23b9 100644 --- a/test/limits_link_2.cpp +++ b/test/limits_link_2.cpp @@ -2,8 +2,8 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include #include -#include void test_odr_use( int const* ); diff --git a/test/roundtrip.cpp b/test/roundtrip.cpp index 6c16cb65e..76cbaedba 100644 --- a/test/roundtrip.cpp +++ b/test/roundtrip.cpp @@ -2,6 +2,8 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include +#include #include #ifdef BOOST_HAS_INT128 @@ -11,7 +13,7 @@ // won't be visible to BOOST_TEST_EQ // LCOV_EXCL_START -#include +#include static char* mini_to_chars( char (&buffer)[ 64 ], boost::uint128_type v ) { @@ -62,14 +64,15 @@ std::ostream& operator<<( std::ostream& os, boost::int128_type v ) #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include int const N = 1024; @@ -296,7 +299,7 @@ int64_t ToOrdinal(FPType x) // Number of normal representable numbers for each exponent. static const auto - NumbersPerExponent = static_cast(scalbn(Radix-1, SignificandDigits-1)); + NumbersPerExponent = static_cast(std::scalbn(Radix-1, SignificandDigits-1)); if (x == 0) return 0; diff --git a/test/test_128bit_emulation.cpp b/test/test_128bit_emulation.cpp index 570e764c6..c9d50248c 100644 --- a/test/test_128bit_emulation.cpp +++ b/test/test_128bit_emulation.cpp @@ -2,6 +2,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include #ifdef BOOST_HAS_INT128 @@ -249,3 +257,5 @@ int main() return boost::report_errors(); } + +#endif diff --git a/test/test_128bit_native.cpp b/test/test_128bit_native.cpp index cd96a8eb8..dce619c48 100644 --- a/test/test_128bit_native.cpp +++ b/test/test_128bit_native.cpp @@ -2,6 +2,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include #include #include @@ -27,3 +35,5 @@ int main() test128(); return boost::report_errors(); } + +#endif diff --git a/test/test_boost_json_values.cpp b/test/test_boost_json_values.cpp index fb3e5963c..735485c95 100644 --- a/test/test_boost_json_values.cpp +++ b/test/test_boost_json_values.cpp @@ -7,18 +7,20 @@ // See: https://github.com/boostorg/json/issues/599 // See: https://github.com/boostorg/json/blob/develop/test/double.cpp +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include template void grind(const std::string& str, const T expected_value) diff --git a/test/test_compute_float32.cpp b/test/test_compute_float32.cpp index d3fa83465..1e7ed4b30 100644 --- a/test/test_compute_float32.cpp +++ b/test/test_compute_float32.cpp @@ -2,6 +2,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include #include #include @@ -34,3 +42,5 @@ int main() return boost::report_errors(); } + +#endif diff --git a/test/test_compute_float64.cpp b/test/test_compute_float64.cpp index 945276281..bbb95e051 100644 --- a/test/test_compute_float64.cpp +++ b/test/test_compute_float64.cpp @@ -2,6 +2,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include #include #include @@ -35,3 +43,5 @@ int main(void) return boost::report_errors(); } + +#endif diff --git a/test/test_compute_float80.cpp b/test/test_compute_float80.cpp index a800f9572..8af7ed479 100644 --- a/test/test_compute_float80.cpp +++ b/test/test_compute_float80.cpp @@ -2,6 +2,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include #include #include @@ -48,3 +56,5 @@ int main() return 0; } #endif + +#endif diff --git a/test/test_float128.cpp b/test/test_float128.cpp index 823666c7c..6b34aa79c 100644 --- a/test/test_float128.cpp +++ b/test/test_float128.cpp @@ -2,6 +2,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include #if defined(BOOST_CHARCONV_HAS_QUADMATH) && defined(BOOST_HAS_INT128) @@ -87,11 +95,11 @@ std::ostream& operator<<( std::ostream& os, boost::int128_type v ) #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "../src/float128_impl.hpp" constexpr int N = 1024; @@ -843,3 +851,5 @@ int main() } #endif + +#endif diff --git a/test/test_num_digits.cpp b/test/test_num_digits.cpp index fde6d28d5..0024206a5 100644 --- a/test/test_num_digits.cpp +++ b/test/test_num_digits.cpp @@ -2,6 +2,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include #include #include @@ -106,3 +114,5 @@ int main() return boost::report_errors(); } + +#endif diff --git a/test/test_parser.cpp b/test/test_parser.cpp index c1fef8468..3b1de97d3 100644 --- a/test/test_parser.cpp +++ b/test/test_parser.cpp @@ -2,6 +2,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include #include #include @@ -240,3 +248,5 @@ int main() test_zeroes(); return boost::report_errors(); } + +#endif diff --git a/test/to_chars.cpp b/test/to_chars.cpp index 91a605f15..839bf4b2f 100644 --- a/test/to_chars.cpp +++ b/test/to_chars.cpp @@ -3,14 +3,17 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef BOOST_CHARCONV_HAS_INT128 template diff --git a/test/to_chars_float.cpp b/test/to_chars_float.cpp index 301c0df7f..a0da2c90d 100644 --- a/test/to_chars_float.cpp +++ b/test/to_chars_float.cpp @@ -3,6 +3,14 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +#include +BOOST_PRAGMA_MESSAGE("This test targets an implementation detail, and is skipped when building with modules") +int main() {} + +#else + #include #include #include @@ -1099,3 +1107,5 @@ int main() return boost::report_errors(); } + +#endif diff --git a/test/to_chars_float_STL_comp.cpp b/test/to_chars_float_STL_comp.cpp index dec006b75..b250260e5 100644 --- a/test/to_chars_float_STL_comp.cpp +++ b/test/to_chars_float_STL_comp.cpp @@ -9,19 +9,20 @@ ((defined(__clang__) && __clang_major__ >= 14 && !defined(__APPLE__)) || (defined(__clang__) && defined(__APPLE__) && __clang_major__ >= 16)) || \ (defined(_MSC_VER) && _MSC_VER >= 1924) +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include template void test_spot(T val, boost::charconv::chars_format fmt = boost::charconv::chars_format::general, int precision = -1) diff --git a/test/to_chars_integer_STL_comp.cpp b/test/to_chars_integer_STL_comp.cpp index 89cdc1191..b0a245f7a 100644 --- a/test/to_chars_integer_STL_comp.cpp +++ b/test/to_chars_integer_STL_comp.cpp @@ -6,19 +6,20 @@ #if !defined(BOOST_NO_CXX17_HDR_CHARCONV) && (!defined(__clang_major__) || (defined(__clang_major__) && __clang_major__ > 7)) +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include template void stress_test_worker() diff --git a/test/to_chars_sprintf.cpp b/test/to_chars_sprintf.cpp index 3b1d73ab8..9d21a5539 100644 --- a/test/to_chars_sprintf.cpp +++ b/test/to_chars_sprintf.cpp @@ -3,18 +3,19 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include int const N = 1024; diff --git a/tools/install-cmake.sh b/tools/install-cmake.sh new file mode 100755 index 000000000..d2fd0bbab --- /dev/null +++ b/tools/install-cmake.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# +# Copyright (c) 2026 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# + +set -e + +wget https://github.com/Kitware/CMake/releases/download/v4.2.3/cmake-4.2.3-linux-x86_64.tar.gz +tar -xf cmake-4.2.3-linux-x86_64.tar.gz +mv cmake-4.2.3-linux-x86_64 /opt/cmake +update-alternatives --install /usr/bin/cmake cmake /opt/cmake/bin/cmake 100 +update-alternatives --install /usr/bin/ctest ctest /opt/cmake/bin/ctest 100 diff --git a/tools/setup_boost_with_modules.py b/tools/setup_boost_with_modules.py new file mode 100644 index 000000000..c4eab8797 --- /dev/null +++ b/tools/setup_boost_with_modules.py @@ -0,0 +1,29 @@ +#!/usr/bin/python + +# This is a temporary workaround to make CIs use the +# "Boost with C++20 modules" proposal, instead of the regular develop branch +# Call it instead of depinst + +from subprocess import check_call +import os + +def main(): + + submodules = [ + ('tools/cmake', 'https://github.com/anarthal/boost-cmake'), + ('libs/core', 'https://github.com/anarthal/core'), + ('libs/assert', 'https://github.com/anarthal/assert'), + ('libs/throw_exception','https://github.com/anarthal/throw_exception'), + ('libs/config', 'https://github.com/anarthal/config'), + ] + + for submodule, url in submodules: + os.chdir(submodule) + check_call(['git', 'remote', 'add', 'modules', url]) + check_call(['git', 'fetch', '--depth', '1', 'modules', 'feature/cxx20-modules']) + check_call(['git', 'checkout', 'modules/feature/cxx20-modules']) + os.chdir('../..') + + +if __name__ == '__main__': + main()