From 84536c9ac9c4db2e7cf84814d4c45fcad3b97965 Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Wed, 21 Oct 2026 20:49:44 +0330 Subject: [PATCH 01/17] Add optional C++20 module interface (import boost.program_options) Implements #160. Adds a C++20 module interface for the library, so that import boost.program_options; can be used instead of including , with the boost::program_options namespace unchanged. The interface (src/cppm/boost/program_options.cppm) is a thin wrapper: the classic umbrella header is included in the global module fragment and its public declarations are re-exported with exported using-declarations. No header is modified, the compiled library is shared as is, and the classic header-based interface remains the default, so the change is strictly additive. - The module is built only when CMake is configured with BOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON (CMake 3.28+ with Ninja, 3.30+ with the Visual Studio generator), producing the additional Boost::program_options_modules target which links the classic library. - test/module_test.cpp verifies the exported interface without including any Boost header: command line parsing with all option kinds, positional and unregistered options, defaulted and implicit values, config files, the wide-character interface, exceptions, and utilities. - CI jobs build and run the module test with MSVC (Visual Studio generator), GCC 15 and Clang 21 (Ninja). - Documented in README.md and doc/modules.xml. Macros (e.g. BOOST_PROGRAM_OPTIONS_VERSION) are not exported by the module; code needing them keeps including the classic headers. --- .github/workflows/ci.yml | 113 +++++++++++++++ CMakeLists.txt | 39 +++++ README.md | 32 +++++ doc/modules.xml | 81 +++++++++++ doc/program_options.xml | 1 + src/cppm/boost/program_options.cppm | 177 +++++++++++++++++++++++ test/CMakeLists.txt | 15 ++ test/module_test.cpp | 213 ++++++++++++++++++++++++++++ 8 files changed, 671 insertions(+) create mode 100644 doc/modules.xml create mode 100644 src/cppm/boost/program_options.cppm create mode 100644 test/module_test.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e4f7142c..7685d0282 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -612,3 +612,116 @@ jobs: run: | cd ../boost-root/__build__ ctest --output-on-failure --no-tests=error -C Release + + posix-cmake-modules: + strategy: + fail-fast: false + matrix: + include: + - name: "gcc-15" + packages: "g++-15 ninja-build" + cmake-args: "-DCMAKE_CXX_COMPILER=g++-15" + - name: "clang-21" + packages: "clang-21 ninja-build" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21" + + name: CMake modules ${{ matrix.name }} + + runs-on: ubuntu-latest + container: ubuntu:26.04 + + defaults: + run: + shell: bash + + steps: + - name: Setup container environment + run: | + apt-get update + apt-get -y install sudo python3 git g++ cmake + + - name: Install packages + run: | + sudo apt-get update + sudo apt-get -y install ${{matrix.packages}} + + - uses: actions/checkout@v6 + + - 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 + python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON -DBOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON -DCMAKE_CXX_STANDARD=20 ${{matrix.cmake-args}} -G Ninja .. + + - name: Build and run module test + run: | + cd ../boost-root/__build__ + cmake --build . --target program_options_module_test + ctest --output-on-failure --no-tests=error -R program_options_module_test + + windows-cmake-modules: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v6 + + - 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% + + - name: Configure + shell: cmd + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON -DBOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON -G "Visual Studio 17 2022" .. + + - name: Build and run module test (Debug) + shell: cmd + run: | + cd ../boost-root/__build__ + cmake --build . --config Debug --target program_options_module_test + ctest --output-on-failure --no-tests=error -C Debug -R program_options_module_test + + - name: Build and run module test (Release) + shell: cmd + run: | + cd ../boost-root/__build__ + cmake --build . --config Release --target program_options_module_test + ctest --output-on-failure --no-tests=error -C Release -R program_options_module_test diff --git a/CMakeLists.txt b/CMakeLists.txt index 024966ee2..da87e9a80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,45 @@ else() target_compile_definitions(boost_program_options PUBLIC BOOST_PROGRAM_OPTIONS_STATIC_LINK) endif() +# C++20 module interface for the library ('import boost.program_options;'). +# Entirely optional and off by default: the header-based interface is unchanged. + +option(BOOST_PROGRAM_OPTIONS_BUILD_MODULES "Build the C++20 module interface (boost.program_options)" OFF) + +if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) + + if(CMAKE_GENERATOR MATCHES "Visual Studio") + if(CMAKE_VERSION VERSION_LESS 3.30) + message(FATAL_ERROR "boost_program_options_modules: the ${CMAKE_GENERATOR} generator requires CMake 3.30 or later for C++20 modules.") + endif() + elseif(CMAKE_VERSION VERSION_LESS 3.28) + message(FATAL_ERROR "boost_program_options_modules: building C++20 modules requires CMake 3.28 or later and a Ninja generator.") + endif() + + add_library(boost_program_options_modules) + add_library(Boost::program_options_modules ALIAS boost_program_options_modules) + + target_sources(boost_program_options_modules + PUBLIC FILE_SET CXX_MODULES + BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/cppm" + FILES src/cppm/boost/program_options.cppm + ) + + # The module interface re-exports the declarations of the classic headers, + # whose definitions live in boost_program_options. + target_link_libraries(boost_program_options_modules PUBLIC boost_program_options) + + target_compile_features(boost_program_options_modules PUBLIC cxx_std_20) + + if(NOT BOOST_SKIP_INSTALL_RULES AND NOT CMAKE_SKIP_INSTALL_RULES) + # Install the module interface source next to the headers, so that it is + # available to build systems that do not produce BMIs from installed + # packages (e.g. MSBuild projects adding the .cppm/.ixx directly). + install(FILES src/cppm/boost/program_options.cppm DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost") + endif() + +endif() + if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") add_subdirectory(test) diff --git a/README.md b/README.md index 220d1bfda..259ee6f02 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,38 @@ Distributed under the [Boost Software License, Version 1.0](http://www.boost.org * C++11 * Requires Linking +* Optional C++20 module interface (`import boost.program_options;`) + +### C++20 module support + +The library ships an optional C++20 module interface, so that instead of + +```cpp +#include +``` + +you can write + +```cpp +import boost.program_options; +``` + +and keep using the `boost::program_options` namespace unchanged. The change is +strictly additive: the classic headers are not modified and remain fully +supported. + +The module is not built by default. Enable it by configuring CMake with +`-DBOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON`, which creates the additional +`Boost::program_options_modules` target (it links the classic compiled +library automatically). Building the module requires CMake 3.28+ with the +Ninja generator (CMake 3.30+ with the Visual Studio generator) and a compiler +with C++20 modules support. The `test/module_test.cpp` test verifies that the +exported interface is complete and functional, without including any Boost +header. + +Macros (e.g. `BOOST_PROGRAM_OPTIONS_VERSION`) are not exported by C++20 +modules; include the classic headers where macros are needed. See +`doc/modules.xml` for details. ### Development diff --git a/doc/modules.xml b/doc/modules.xml new file mode 100644 index 000000000..fff9061ed --- /dev/null +++ b/doc/modules.xml @@ -0,0 +1,81 @@ + + + %entities; +]> +
+ + Using C++20 Modules + + modules + import + + For projects compiled with C++20 or later, the library can be + consumed through a C++20 module interface, as an alternative to including + the classic headers: + + + +import boost.program_options; + +int main(int argc, char* argv[]) +{ + namespace po = boost::program_options; + + po::options_description desc("Allowed options"); + desc.add_options() + ("help,h", "produce help message") + ("compression", po::value<int>(), "set compression level") + ; + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc; + } +} + + + + The module, boost.program_options, exports the same + declarations in namespace boost::program_options that are + declared by the umbrella header <boost/program_options.hpp>, + so existing code only needs to replace the + #include with an import. + +
+ Building and Using + + The module interface is entirely optional. It is built by CMake + when the BOOST_PROGRAM_OPTIONS_BUILD_MODULES option is + enabled, producing an additional + Boost::program_options_modules target which also links the + classic compiled library. Building modules requires CMake 3.28 or later + with the Ninja generator, or CMake 3.30 or later with the Visual Studio + generator, and a compiler with C++20 modules support (MSVC 19.28+, + GCC 15+, or Clang 16+). For example: + + + +cmake -DBOOST_INCLUDE_LIBRARIES=program_options \ + -DBOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON \ + -G Ninja .. +cmake --build . --target tests +ctest --output-on-failure + + + + The import statement only makes the library's + declarations available. As usual with modules, macros such as + BOOST_PROGRAM_OPTIONS_VERSION are not exported; code that + needs them must include the classic headers. Such code may combine the + two consumption styles in the same translation unit, since all entities + remain attached to the global module. + +
+ +
diff --git a/doc/program_options.xml b/doc/program_options.xml index c9455683b..704e6a042 100644 --- a/doc/program_options.xml +++ b/doc/program_options.xml @@ -80,6 +80,7 @@ + diff --git a/src/cppm/boost/program_options.cppm b/src/cppm/boost/program_options.cppm new file mode 100644 index 000000000..ba21413fd --- /dev/null +++ b/src/cppm/boost/program_options.cppm @@ -0,0 +1,177 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// C++20 module interface for Boost.ProgramOptions. +// +// Consumers can replace +// #include +// with +// import boost.program_options; +// and keep using the boost::program_options namespace as before. +// +// Implementation notes: +// +// * The classic headers are included in the global module fragment and the +// public declarations are re-exported with exported using-declarations. +// This is a thin wrapper: no declaration is moved, renamed or otherwise +// changed, so the classic header-based interface and the compiled library +// are shared verbatim between the two consumption styles. +// +// * Macros (e.g. BOOST_PROGRAM_OPTIONS_VERSION) are not exported by C++20 +// modules. Code that needs them must keep including the classic headers. +// +// * The module covers everything reachable from . +// The auxiliary iterator headers +// and are generic +// utilities outside of that umbrella header and are not exported here. + +module; + +#include + +export module boost.program_options; + +// Some compilers prune global-module-fragment declarations from the BMI. +// Templates defined by the headers (e.g. boost::any_cast, used by +// variable_value::as()) look up operators such as +// boost::typeindex::operator== by ADL when instantiated in importing +// translation units. Those operators must therefore be exported by the +// module, like the library's own declarations. +export namespace boost { namespace typeindex { +using ::boost::typeindex::operator==; +using ::boost::typeindex::operator!=; +}} + +export namespace boost { + +// Character conversion helpers declared in namespace boost by +// . +#if !defined(BOOST_NO_STD_WSTRING) +using ::boost::from_8_bit; +using ::boost::to_8_bit; +using ::boost::from_utf8; +using ::boost::to_utf8; +using ::boost::from_local_8_bit; +using ::boost::to_local_8_bit; +#endif + +namespace program_options { + +// errors.hpp +using ::boost::program_options::strip_prefixes; +using ::boost::program_options::error; +using ::boost::program_options::too_many_positional_options_error; +using ::boost::program_options::invalid_command_line_style; +using ::boost::program_options::reading_file; +using ::boost::program_options::error_with_option_name; +using ::boost::program_options::multiple_values; +using ::boost::program_options::multiple_occurrences; +using ::boost::program_options::required_option; +using ::boost::program_options::error_with_no_option_name; +using ::boost::program_options::unknown_option; +using ::boost::program_options::ambiguous_option; +using ::boost::program_options::invalid_syntax; +using ::boost::program_options::invalid_config_file_syntax; +using ::boost::program_options::invalid_command_line_syntax; +using ::boost::program_options::validation_error; +using ::boost::program_options::invalid_option_value; +using ::boost::program_options::invalid_bool_value; + +// option.hpp +using ::boost::program_options::basic_option; +using ::boost::program_options::option; +using ::boost::program_options::woption; + +// value_semantic.hpp and detail/value_semantic.hpp +// Note: the explicit specializations (e.g. value_semantic_codecvt_helper) +// are declared by the headers in the global module fragment and are therefore +// reachable by importers of this module; only the primary templates are +// named below, as some compilers reject using-declarations that name +// template specializations. +using ::boost::program_options::value_semantic; +using ::boost::program_options::value_semantic_codecvt_helper; +using ::boost::program_options::untyped_value; +#ifndef BOOST_NO_RTTI +using ::boost::program_options::typed_value_base; +#endif +using ::boost::program_options::typed_value; +using ::boost::program_options::value; +using ::boost::program_options::wvalue; +using ::boost::program_options::bool_switch; +using ::boost::program_options::validate; + +namespace validators { +using ::boost::program_options::validators::get_single_string; +using ::boost::program_options::validators::check_first_occurrence; +} + +// options_description.hpp +using ::boost::program_options::option_description; +using ::boost::program_options::options_description_easy_init; +using ::boost::program_options::options_description; +using ::boost::program_options::duplicate_option_error; + +// positional_options.hpp +using ::boost::program_options::positional_options_description; + +// cmdline.hpp +namespace command_line_style { +using ::boost::program_options::command_line_style::style_t; +using ::boost::program_options::command_line_style::allow_long; +using ::boost::program_options::command_line_style::allow_short; +using ::boost::program_options::command_line_style::allow_dash_for_short; +using ::boost::program_options::command_line_style::allow_slash_for_short; +using ::boost::program_options::command_line_style::long_allow_adjacent; +using ::boost::program_options::command_line_style::long_allow_next; +using ::boost::program_options::command_line_style::short_allow_adjacent; +using ::boost::program_options::command_line_style::short_allow_next; +using ::boost::program_options::command_line_style::allow_sticky; +using ::boost::program_options::command_line_style::allow_guessing; +using ::boost::program_options::command_line_style::long_case_insensitive; +using ::boost::program_options::command_line_style::short_case_insensitive; +using ::boost::program_options::command_line_style::case_insensitive; +using ::boost::program_options::command_line_style::allow_long_disguise; +using ::boost::program_options::command_line_style::unix_style; +using ::boost::program_options::command_line_style::default_style; +} + +// parsers.hpp and detail/parsers.hpp +using ::boost::program_options::basic_parsed_options; +using ::boost::program_options::parsed_options; +using ::boost::program_options::wparsed_options; +using ::boost::program_options::ext_parser; +using ::boost::program_options::basic_command_line_parser; +using ::boost::program_options::command_line_parser; +using ::boost::program_options::wcommand_line_parser; +using ::boost::program_options::parse_command_line; +using ::boost::program_options::parse_config_file; +using ::boost::program_options::collect_unrecognized_mode; +using ::boost::program_options::include_positional; +using ::boost::program_options::exclude_positional; +using ::boost::program_options::collect_unrecognized; +using ::boost::program_options::parse_environment; +using ::boost::program_options::split_unix; +#ifdef _WIN32 +using ::boost::program_options::split_winmain; +#endif + +// detail/convert.hpp +using ::boost::program_options::to_internal; + +// detail/cmdline.hpp, detail/config_file.hpp +namespace detail { +using ::boost::program_options::detail::cmdline; +using ::boost::program_options::detail::arg; +} + +// variables_map.hpp +using ::boost::program_options::store; +using ::boost::program_options::notify; +using ::boost::program_options::variable_value; +using ::boost::program_options::abstract_variables_map; +using ::boost::program_options::variables_map; + +} // namespace program_options +} // namespace boost diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ea8832ec1..14dd14e4a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,6 +4,21 @@ include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) +# C++20 module test. Does not use Boost.Test, and is only built when the +# module interface target exists. + +if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES AND TARGET Boost::program_options_modules) + + add_executable(program_options_module_test module_test.cpp) + target_link_libraries(program_options_module_test PRIVATE Boost::program_options_modules) + set_target_properties(program_options_module_test PROPERTIES + CXX_STANDARD 20 + CXX_STANDARD_REQUIRED ON + CXX_SCAN_FOR_MODULES ON) + add_test(NAME program_options_module_test COMMAND program_options_module_test) + +endif() + if(NOT HAVE_BOOST_TEST) return() endif() diff --git a/test/module_test.cpp b/test/module_test.cpp new file mode 100644 index 000000000..0d14c490a --- /dev/null +++ b/test/module_test.cpp @@ -0,0 +1,213 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Checks that the C++20 module interface exports a usable library. +// No Boost header is included on purpose: everything must come from +// 'import boost.program_options;'. + +#include +#include +#include +#include +#include +#include + +import boost.program_options; + +// The test is built in both Debug and Release configurations, so plain +// assert() would be a no-op in Release. Use an always-active check. +#define CHECK(cond) \ + do { \ + if (!(cond)) { \ + std::fprintf(stderr, "CHECK failed: %s (%s:%d)\n", \ + #cond, __FILE__, __LINE__); \ + std::abort(); \ + } \ + } while (0) + +static void test_command_line() +{ + using namespace boost::program_options; + + options_description desc("Allowed options"); + desc.add_options() + ("help,h", "produce help message") + ("compression", value()->default_value(5), "set compression level") + ("email", value >()->composing(), "email address") + ("output,o", value()->implicit_value("default"), "output file") + ("verbose", bool_switch(), "verbose output") + ("input", value >(), "input file") + ; + + positional_options_description positional; + positional.add("input", 2); + + char arg0[] = "program"; + char arg1[] = "--compression"; + char arg2[] = "7"; + char arg3[] = "--email"; + char arg4[] = "a@example.com"; + char arg5[] = "-ovalue"; + char arg6[] = "file1"; + char arg7[] = "file2"; + char* argv[] = { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 }; + + variables_map vm; + store( + command_line_parser(sizeof(argv) / sizeof(argv[0]), argv) + .options(desc) + .positional(positional) + .style(command_line_style::unix_style) + .run(), + vm); + notify(vm); + + CHECK(vm.count("compression") == 1); + CHECK(vm["compression"].as() == 7); + CHECK(!vm["compression"].defaulted()); + + CHECK(vm.count("email") == 1); + CHECK(vm["email"].as >().size() == 1); + + CHECK(vm.count("output") == 1); + CHECK(vm["output"].as() == "value"); + + // bool_switch registers a default value of false, which store() applies. + CHECK(vm.count("verbose") == 1); + CHECK(vm["verbose"].defaulted()); + CHECK(!vm["verbose"].as()); + CHECK(vm.count("input") == 1); + CHECK(vm["input"].as >().size() == 2); + CHECK(vm.count("help") == 0); + + // Description printing exercises the ADL-found operator<<. + std::ostringstream os; + os << desc; + CHECK(os.str().find("Allowed options") != std::string::npos); + CHECK(os.str().find("compression") != std::string::npos); + + // parse_command_line and defaulted values. + char* argv2[] = { arg0 }; + variables_map vm2; + store(parse_command_line(1, argv2, desc), vm2); + notify(vm2); + CHECK(vm2["compression"].as() == 5); + CHECK(vm2["compression"].defaulted()); + + // Unregistered options. + char unknown[] = "--no-such-option"; + char* argv3[] = { arg0, unknown }; + parsed_options parsed + = command_line_parser(2, argv3).options(desc).allow_unregistered().run(); + std::vector tokens + = collect_unrecognized(parsed.options, exclude_positional); + CHECK(tokens.size() == 1 && tokens[0] == unknown); + + // Exceptions. + bool caught = false; + try + { + store(parse_command_line(2, argv3, desc), vm2); + } + catch (const unknown_option& e) + { + caught = true; + std::string message = e.what(); + CHECK(message.find("no-such-option") != std::string::npos); + } + CHECK(caught); + + char badValue[] = "--compression"; + char notANumber[] = "not-a-number"; + char* argv4[] = { arg0, badValue, notANumber }; + caught = false; + try + { + store(parse_command_line(3, argv4, desc), vm2); + } + catch (const invalid_option_value& e) + { + caught = true; + // Reachability of the error hierarchy. + const error_with_option_name& base = e; + CHECK(base.what() != 0); + } + CHECK(caught); +} + +static void test_config_file() +{ + using namespace boost::program_options; + + const char* configPath = "program_options_module_test.cfg"; + { + std::ofstream config(configPath); + config << "# a comment\n" + << "compression = 9\n" + << "email = x@example.com\n" + << "email = y@example.com\n"; + } + + options_description desc("Allowed options"); + desc.add_options() + ("compression", value(), "set compression level") + ("email", value >()->composing(), "email address") + ; + + variables_map vm; + store(parse_config_file(configPath, desc), vm); + notify(vm); + + CHECK(vm.count("compression") == 1); + CHECK(vm["compression"].as() == 9); + CHECK(vm.count("email") == 1); + CHECK(vm["email"].as >().size() == 2); + + std::remove(configPath); +} + +// Every toolchain with C++20 modules support provides std::wstring, so the +// wide-character interface (including the basic_parsed_options +// specialization) is tested unconditionally. +static void test_wide_command_line() +{ + using namespace boost::program_options; + + options_description desc("Allowed options"); + desc.add_options() + ("compression", value(), "set compression level") + ; + + wchar_t arg0[] = L"program"; + wchar_t arg1[] = L"--compression"; + wchar_t arg2[] = L"3"; + wchar_t* argv[] = { arg0, arg1, arg2 }; + + // Uses basic_parsed_options, an explicit specialization that + // must be exported by the module. + variables_map vm; + store(wcommand_line_parser(3, argv).options(desc).run(), vm); + notify(vm); + + CHECK(vm.count("compression") == 1); + CHECK(vm["compression"].as() == 3); +} + +int main() +{ + test_command_line(); + test_config_file(); + test_wide_command_line(); + + // Small namespace-level utilities. + using boost::program_options::strip_prefixes; + CHECK(strip_prefixes("--foo-bar") == "foo-bar"); + CHECK(strip_prefixes("foo") == "foo"); + + CHECK(boost::program_options::split_unix("a b c").size() == 3); + + std::cout << "program_options module test: PASS\n"; + return 0; +} From f061e244737d256f9128b2593b6112d619415f84 Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Wed, 21 Oct 2026 21:13:54 +0330 Subject: [PATCH 02/17] Move the module interface to modules/boost_program_options.cppm Place the C++20 module interface in a root-level modules/ directory, naming it boost_program_options.cppm, following the layout used by other Boost libraries (e.g. Boost.Any). No functional changes. --- CMakeLists.txt | 6 +++--- README.md | 19 ++++++++++--------- .../boost_program_options.cppm | 0 3 files changed, 13 insertions(+), 12 deletions(-) rename src/cppm/boost/program_options.cppm => modules/boost_program_options.cppm (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index da87e9a80..eaf089d9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,8 +75,8 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) target_sources(boost_program_options_modules PUBLIC FILE_SET CXX_MODULES - BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/cppm" - FILES src/cppm/boost/program_options.cppm + BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/modules" + FILES modules/boost_program_options.cppm ) # The module interface re-exports the declarations of the classic headers, @@ -89,7 +89,7 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) # Install the module interface source next to the headers, so that it is # available to build systems that do not produce BMIs from installed # packages (e.g. MSBuild projects adding the .cppm/.ixx directly). - install(FILES src/cppm/boost/program_options.cppm DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost") + install(FILES modules/boost_program_options.cppm DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost") endif() endif() diff --git a/README.md b/README.md index 259ee6f02..02eecebd0 100644 --- a/README.md +++ b/README.md @@ -61,15 +61,16 @@ changes to re-align with the evolution of Boost C++ Libraries and C++. ### Directories -| Name | Purpose | -| --------- | ------------------------------ | -| `build` | build script for link library | -| `ci` | continuous integration scripts | -| `doc` | documentation | -| `example` | use case examples | -| `include` | headers | -| `src` | source code for link library | -| `test` | unit tests | +| Name | Purpose | +| --------- | -------------------------------- | +| `build` | build script for link library | +| `ci` | continuous integration scripts | +| `doc` | documentation | +| `example` | use case examples | +| `include` | headers | +| `modules` | C++20 module interface | +| `src` | source code for link library | +| `test` | unit tests | ### More information diff --git a/src/cppm/boost/program_options.cppm b/modules/boost_program_options.cppm similarity index 100% rename from src/cppm/boost/program_options.cppm rename to modules/boost_program_options.cppm From 6c34fd3497bf4ff50cf33a388965bf6c72f9cd5a Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Wed, 21 Oct 2026 21:22:34 +0330 Subject: [PATCH 03/17] Add modules/usage_sample.cpp and document the wrapper design Adds a minimal, compilable example of importing boost.program_options in modules/usage_sample.cpp, following the layout of other Boost libraries (e.g. Boost.Any), and references it from the documentation. Also expands the comment in the module interface explaining why the exported using-declaration list is needed: unlike libraries whose public headers carry export macros and are included in the module purview, this module keeps every header untouched and therefore must re-export each public name explicitly from the global module fragment. --- doc/modules.xml | 3 ++- modules/boost_program_options.cppm | 13 ++++++--- modules/usage_sample.cpp | 43 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 modules/usage_sample.cpp diff --git a/doc/modules.xml b/doc/modules.xml index fff9061ed..d983e43de 100644 --- a/doc/modules.xml +++ b/doc/modules.xml @@ -45,7 +45,8 @@ int main(int argc, char* argv[]) declarations in namespace boost::program_options that are declared by the umbrella header <boost/program_options.hpp>, so existing code only needs to replace the - #include with an import. + #include with an import. A minimal, compilable + example is provided in modules/usage_sample.cpp.
Building and Using diff --git a/modules/boost_program_options.cppm b/modules/boost_program_options.cppm index ba21413fd..a5eec0303 100644 --- a/modules/boost_program_options.cppm +++ b/modules/boost_program_options.cppm @@ -15,9 +15,16 @@ // // * The classic headers are included in the global module fragment and the // public declarations are re-exported with exported using-declarations. -// This is a thin wrapper: no declaration is moved, renamed or otherwise -// changed, so the classic header-based interface and the compiled library -// are shared verbatim between the two consumption styles. +// The using-declaration list is the price of not modifying any header: +// declarations from the global module fragment are not exported +// automatically, so each public name must be re-exported explicitly. +// Libraries that annotate their headers with export macros (e.g. +// Boost.Any) instead include them in the module purview and need no +// using-declarations, but that style requires changing every public +// header and modularizing all dependencies first. Keeping the headers +// untouched makes this change strictly additive: the header-based +// interface, the compiled library and its ABI are shared verbatim +// between the two consumption styles. // // * Macros (e.g. BOOST_PROGRAM_OPTIONS_VERSION) are not exported by C++20 // modules. Code that needs them must keep including the classic headers. diff --git a/modules/usage_sample.cpp b/modules/usage_sample.cpp new file mode 100644 index 000000000..904ab61e0 --- /dev/null +++ b/modules/usage_sample.cpp @@ -0,0 +1,43 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// A minimal sample of consuming the library through the C++20 module +// interface. To compile it manually, build the module interface first +// (e.g. with CMake and BOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON), then use +// a command like the following: +// +// MSVC: +// cl /std:c++20 /EHsc ^ +// /reference boost.program_options=/boost.program_options.ifc ^ +// usage_sample.cpp /link /libboost_program_options*.lib +// +// Clang: +// clang++ -std=c++20 -fprebuilt-module-path=. usage_sample.cpp \ +// -lboost_program_options + +#include + +import boost.program_options; + +int main(int argc, char* argv[]) +{ + namespace po = boost::program_options; + + po::options_description desc("Allowed options"); + desc.add_options() + ("help,h", "produce help message") + ("compression", po::value(), "set compression level") + ; + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + if (vm.count("help")) + { + std::cout << desc; + return 0; + } +} From e41ab9a0d960a28cbc1d312a1e4c1a958ab1e3de Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Thu, 22 Oct 2026 11:31:01 +0330 Subject: [PATCH 04/17] Switch module interface to the export-block style (like Boost.Any/PFR) Replace the exported using-declaration wrapper with the design used by other Boost libraries that ship a module (Boost.Any, Boost.PFR): - defines BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT, which expand to 'export { ... }' while the module interface unit is compiled (BOOST_PROGRAM_OPTIONS_INTERFACE_UNIT) and to nothing otherwise. It also turns any library header into 'import boost.program_options;' when BOOST_USE_MODULES is defined, as Boost.PFR does. - The public declarations in every umbrella-reachable header are wrapped in those export blocks; header builds are unchanged. - modules/boost_program_options.cppm now preloads the dependency and standard headers used by the public headers in the global module fragment (so the purview includes are no-ops for them and nothing foreign gets attached to the module) and includes the umbrella header in the purview. The long list of using-declarations is gone. Unlike Boost.Any/PFR, this library is compiled and depends on Boost libraries that are not modularized yet (any, function, smart_ptr, lexical_cast), which is why their headers are preloaded in the global module fragment rather than imported. cmdline.hpp now includes the library config header so the export macros are always defined. All 15 CMake tests pass, in both header mode and module mode. --- README.md | 9 +- doc/modules.xml | 19 +- include/boost/program_options/cmdline.hpp | 7 + include/boost/program_options/config.hpp | 26 +++ .../boost/program_options/detail/cmdline.hpp | 4 + .../boost/program_options/detail/convert.hpp | 6 + .../boost/program_options/detail/parsers.hpp | 4 + .../program_options/detail/value_semantic.hpp | 8 + include/boost/program_options/errors.hpp | 4 + include/boost/program_options/option.hpp | 4 + .../program_options/options_description.hpp | 4 + include/boost/program_options/parsers.hpp | 4 + .../program_options/positional_options.hpp | 4 + .../boost/program_options/value_semantic.hpp | 4 + .../boost/program_options/variables_map.hpp | 4 + modules/boost_program_options.cppm | 198 +++++------------- 16 files changed, 158 insertions(+), 151 deletions(-) diff --git a/README.md b/README.md index 02eecebd0..732f17b40 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,12 @@ you can write import boost.program_options; ``` -and keep using the `boost::program_options` namespace unchanged. The change is -strictly additive: the classic headers are not modified and remain fully -supported. +and keep using the `boost::program_options` namespace unchanged. The module +follows the same design as other Boost libraries that ship one (e.g. Boost.Any +and Boost.PFR): the public declarations in the headers are wrapped in +`BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT` blocks, which expand to +`export { ... }` while the module interface unit is being compiled and to +nothing in ordinary builds, so the classic header interface is unchanged. The module is not built by default. Enable it by configuring CMake with `-DBOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON`, which creates the additional diff --git a/doc/modules.xml b/doc/modules.xml index d983e43de..47446351a 100644 --- a/doc/modules.xml +++ b/doc/modules.xml @@ -48,6 +48,16 @@ int main(int argc, char* argv[]) #include with an import. A minimal, compilable example is provided in modules/usage_sample.cpp. + The interface follows the same design as other Boost libraries that + ship a module (for example Boost.Any and Boost.PFR): the public + declarations of the classic headers are wrapped in + BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT / + BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT blocks (defined in + <boost/program_options/config.hpp>), which expand to + export { ... } while the module interface unit is being + compiled and to nothing in ordinary builds, leaving the header-based + interface unchanged. +
Building and Using @@ -73,9 +83,12 @@ ctest --output-on-failure The import statement only makes the library's declarations available. As usual with modules, macros such as BOOST_PROGRAM_OPTIONS_VERSION are not exported; code that - needs them must include the classic headers. Such code may combine the - two consumption styles in the same translation unit, since all entities - remain attached to the global module. + needs those macros must include the classic headers. As with other + modularized Boost libraries, mixing + #include <boost/program_options.hpp> and + import boost.program_options; for the library's own + declarations in the same program is not supported; a translation unit + should use one style or the other.
diff --git a/include/boost/program_options/cmdline.hpp b/include/boost/program_options/cmdline.hpp index 8b57819d8..1beee0b2b 100644 --- a/include/boost/program_options/cmdline.hpp +++ b/include/boost/program_options/cmdline.hpp @@ -6,6 +6,10 @@ #ifndef BOOST_CMDLINE_HPP_VP_2004_03_13 #define BOOST_CMDLINE_HPP_VP_2004_03_13 +#include + +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { namespace program_options { namespace command_line_style { /** Various possible styles of options. @@ -83,6 +87,9 @@ namespace boost { namespace program_options { namespace command_line_style { /** The default style. */ default_style = unix_style }; + +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + }}} diff --git a/include/boost/program_options/config.hpp b/include/boost/program_options/config.hpp index 69141726b..643a9aca2 100644 --- a/include/boost/program_options/config.hpp +++ b/include/boost/program_options/config.hpp @@ -47,6 +47,32 @@ #define BOOST_PROGRAM_OPTIONS_DECL #endif +/////////////////////////////////////////////////////////////////////////////// +// C++20 modules support (modules/boost_program_options.cppm). +// +// When the module interface unit is being compiled, the library's headers +// are included in the module purview and their public declarations are +// wrapped into BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT blocks, which +// expand to 'export { ... }'. In ordinary (header) builds the macros expand +// to nothing and the headers are unchanged. + +#ifdef BOOST_PROGRAM_OPTIONS_INTERFACE_UNIT +# define BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT export { +# define BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT } +#else +# define BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT +# define BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT +#endif + +// With BOOST_USE_MODULES, including any Boost.ProgramOptions header is +// equivalent to 'import boost.program_options;', keeping user code source +// compatible between the two consumption styles. +#if defined(BOOST_USE_MODULES) && !defined(BOOST_PROGRAM_OPTIONS_INTERFACE_UNIT) +#ifndef BOOST_IN_MODULE_PURVIEW +import boost.program_options; +#endif +#endif + #endif // BOOST_PROGRAM_OPTIONS_CONFIG_HK_2004_01_11 diff --git a/include/boost/program_options/detail/cmdline.hpp b/include/boost/program_options/detail/cmdline.hpp index dce407c0b..467f3e1ff 100644 --- a/include/boost/program_options/detail/cmdline.hpp +++ b/include/boost/program_options/detail/cmdline.hpp @@ -27,6 +27,8 @@ # pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::positional_options_description' #endif +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { namespace program_options { namespace detail { /** Command line parser class. Main requirements were: @@ -151,6 +153,8 @@ namespace boost { namespace program_options { namespace detail { }}} +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + #if defined(BOOST_MSVC) # pragma warning (pop) #endif diff --git a/include/boost/program_options/detail/convert.hpp b/include/boost/program_options/detail/convert.hpp index a22dd6f37..48d78d065 100644 --- a/include/boost/program_options/detail/convert.hpp +++ b/include/boost/program_options/detail/convert.hpp @@ -27,6 +27,8 @@ namespace std } #endif +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { /** Converts from local 8 bit encoding into wchar_t string using @@ -86,9 +88,12 @@ namespace boost { } +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + #else #include #include +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT namespace boost{ namespace program_options{ BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::string&); @@ -103,5 +108,6 @@ namespace boost{ } } } +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT #endif #endif diff --git a/include/boost/program_options/detail/parsers.hpp b/include/boost/program_options/detail/parsers.hpp index cdda539ca..0c0ce9517 100644 --- a/include/boost/program_options/detail/parsers.hpp +++ b/include/boost/program_options/detail/parsers.hpp @@ -10,6 +10,8 @@ #include +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { namespace program_options { template @@ -132,4 +134,6 @@ namespace boost { namespace program_options { }} +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + #endif diff --git a/include/boost/program_options/detail/value_semantic.hpp b/include/boost/program_options/detail/value_semantic.hpp index 27b7c241b..0ef54ad6f 100644 --- a/include/boost/program_options/detail/value_semantic.hpp +++ b/include/boost/program_options/detail/value_semantic.hpp @@ -15,6 +15,8 @@ // forward declaration namespace boost { template class optional; } +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { namespace program_options { namespace detail { @@ -78,8 +80,12 @@ namespace boost { namespace program_options { check_first_occurrence(const boost::any& value); } +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + using namespace validators; +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + /** Validates 's' and updates 'v'. @pre 'v' is either empty or in the state assigned by the previous invocation of 'validate'. @@ -242,3 +248,5 @@ namespace boost { namespace program_options { }} + +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT diff --git a/include/boost/program_options/errors.hpp b/include/boost/program_options/errors.hpp index 953db1366..201562166 100644 --- a/include/boost/program_options/errors.hpp +++ b/include/boost/program_options/errors.hpp @@ -21,6 +21,8 @@ # pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::ambiguous_option' #endif +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { namespace program_options { inline std::string strip_prefixes(const std::string& text) @@ -417,6 +419,8 @@ namespace boost { namespace program_options { }} +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + #if defined(BOOST_MSVC) # pragma warning (pop) #endif diff --git a/include/boost/program_options/option.hpp b/include/boost/program_options/option.hpp index 427678fa7..7e7246052 100644 --- a/include/boost/program_options/option.hpp +++ b/include/boost/program_options/option.hpp @@ -11,6 +11,8 @@ #include #include +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { namespace program_options { /** Option found in input source. @@ -68,4 +70,6 @@ namespace boost { namespace program_options { }} +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + #endif diff --git a/include/boost/program_options/options_description.hpp b/include/boost/program_options/options_description.hpp index da2c4bbfe..baececd18 100644 --- a/include/boost/program_options/options_description.hpp +++ b/include/boost/program_options/options_description.hpp @@ -32,6 +32,8 @@ #endif +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + /** Boost namespace */ namespace boost { /** Namespace for the library. */ @@ -294,6 +296,8 @@ namespace program_options { }; }} +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + #if defined(BOOST_MSVC) # pragma warning (pop) #endif diff --git a/include/boost/program_options/parsers.hpp b/include/boost/program_options/parsers.hpp index c86b53746..3143d8ba6 100644 --- a/include/boost/program_options/parsers.hpp +++ b/include/boost/program_options/parsers.hpp @@ -22,6 +22,8 @@ # pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::basic_parsed_options' #endif +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { namespace program_options { class options_description; @@ -290,6 +292,8 @@ namespace boost { namespace program_options { }} +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + #if defined(BOOST_MSVC) # pragma warning (pop) #endif diff --git a/include/boost/program_options/positional_options.hpp b/include/boost/program_options/positional_options.hpp index c19c9250e..7e70b9707 100644 --- a/include/boost/program_options/positional_options.hpp +++ b/include/boost/program_options/positional_options.hpp @@ -16,6 +16,8 @@ # pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::positional_options_description' #endif +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { namespace program_options { /** Describes positional options. @@ -66,6 +68,8 @@ namespace boost { namespace program_options { }} +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + #if defined(BOOST_MSVC) # pragma warning (pop) #endif diff --git a/include/boost/program_options/value_semantic.hpp b/include/boost/program_options/value_semantic.hpp index 717f2cd99..27ad4ca7f 100644 --- a/include/boost/program_options/value_semantic.hpp +++ b/include/boost/program_options/value_semantic.hpp @@ -18,6 +18,8 @@ #include #include +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { namespace program_options { /** Class which specifies how the option's value is to be parsed @@ -418,6 +420,8 @@ namespace boost { namespace program_options { }} +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + #include "boost/program_options/detail/value_semantic.hpp" #endif diff --git a/include/boost/program_options/variables_map.hpp b/include/boost/program_options/variables_map.hpp index 3d7662931..465694a01 100644 --- a/include/boost/program_options/variables_map.hpp +++ b/include/boost/program_options/variables_map.hpp @@ -21,6 +21,8 @@ # pragma warning (disable:4251) // 'boost::program_options::variable_value::v' : class 'boost::any' needs to have dll-interface to be used by clients of class 'boost::program_options::variable_value #endif +BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT + namespace boost { namespace program_options { template @@ -213,6 +215,8 @@ namespace boost { namespace program_options { }} +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + #if defined(BOOST_MSVC) # pragma warning (pop) #endif diff --git a/modules/boost_program_options.cppm b/modules/boost_program_options.cppm index a5eec0303..c1d5e23aa 100644 --- a/modules/boost_program_options.cppm +++ b/modules/boost_program_options.cppm @@ -13,18 +13,21 @@ // // Implementation notes: // -// * The classic headers are included in the global module fragment and the -// public declarations are re-exported with exported using-declarations. -// The using-declaration list is the price of not modifying any header: -// declarations from the global module fragment are not exported -// automatically, so each public name must be re-exported explicitly. -// Libraries that annotate their headers with export macros (e.g. -// Boost.Any) instead include them in the module purview and need no -// using-declarations, but that style requires changing every public -// header and modularizing all dependencies first. Keeping the headers -// untouched makes this change strictly additive: the header-based -// interface, the compiled library and its ABI are shared verbatim -// between the two consumption styles. +// * This follows the same design as other Boost libraries that ship a +// module (e.g. Boost.Any and Boost.PFR): the library's public headers are +// included in the module purview below, and their public declarations are +// wrapped in BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT blocks, which +// expand to 'export { ... }' while this interface unit is being compiled +// and to nothing in ordinary header builds (see +// ). +// +// * Unlike Boost.Any or Boost.PFR, this library's public headers include +// non-modularized Boost libraries (Boost.Any, Boost.Function, +// Boost.SmartPtr, Boost.LexicalCast) and the standard library directly. +// All of those headers are preloaded in the global module fragment below, +// so that the includes triggered inside the purview are no-ops (include +// guards) and no foreign declarations get attached to this module. They +// remain attached to the global module, exactly as in header builds. // // * Macros (e.g. BOOST_PROGRAM_OPTIONS_VERSION) are not exported by C++20 // modules. Code that needs them must keep including the classic headers. @@ -36,12 +39,44 @@ module; -#include +// Dependencies directly included by the library's public headers. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Standard headers directly included by the library's public headers. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include export module boost.program_options; +#define BOOST_PROGRAM_OPTIONS_INTERFACE_UNIT + +#ifdef __clang__ +# pragma clang diagnostic ignored "-Winclude-angled-in-module-purview" +#endif + // Some compilers prune global-module-fragment declarations from the BMI. -// Templates defined by the headers (e.g. boost::any_cast, used by +// Templates defined by the preloaded headers (e.g. boost::any_cast, used by // variable_value::as()) look up operators such as // boost::typeindex::operator== by ADL when instantiated in importing // translation units. Those operators must therefore be exported by the @@ -51,134 +86,7 @@ using ::boost::typeindex::operator==; using ::boost::typeindex::operator!=; }} -export namespace boost { - -// Character conversion helpers declared in namespace boost by -// . -#if !defined(BOOST_NO_STD_WSTRING) -using ::boost::from_8_bit; -using ::boost::to_8_bit; -using ::boost::from_utf8; -using ::boost::to_utf8; -using ::boost::from_local_8_bit; -using ::boost::to_local_8_bit; -#endif - -namespace program_options { - -// errors.hpp -using ::boost::program_options::strip_prefixes; -using ::boost::program_options::error; -using ::boost::program_options::too_many_positional_options_error; -using ::boost::program_options::invalid_command_line_style; -using ::boost::program_options::reading_file; -using ::boost::program_options::error_with_option_name; -using ::boost::program_options::multiple_values; -using ::boost::program_options::multiple_occurrences; -using ::boost::program_options::required_option; -using ::boost::program_options::error_with_no_option_name; -using ::boost::program_options::unknown_option; -using ::boost::program_options::ambiguous_option; -using ::boost::program_options::invalid_syntax; -using ::boost::program_options::invalid_config_file_syntax; -using ::boost::program_options::invalid_command_line_syntax; -using ::boost::program_options::validation_error; -using ::boost::program_options::invalid_option_value; -using ::boost::program_options::invalid_bool_value; - -// option.hpp -using ::boost::program_options::basic_option; -using ::boost::program_options::option; -using ::boost::program_options::woption; - -// value_semantic.hpp and detail/value_semantic.hpp -// Note: the explicit specializations (e.g. value_semantic_codecvt_helper) -// are declared by the headers in the global module fragment and are therefore -// reachable by importers of this module; only the primary templates are -// named below, as some compilers reject using-declarations that name -// template specializations. -using ::boost::program_options::value_semantic; -using ::boost::program_options::value_semantic_codecvt_helper; -using ::boost::program_options::untyped_value; -#ifndef BOOST_NO_RTTI -using ::boost::program_options::typed_value_base; -#endif -using ::boost::program_options::typed_value; -using ::boost::program_options::value; -using ::boost::program_options::wvalue; -using ::boost::program_options::bool_switch; -using ::boost::program_options::validate; - -namespace validators { -using ::boost::program_options::validators::get_single_string; -using ::boost::program_options::validators::check_first_occurrence; -} - -// options_description.hpp -using ::boost::program_options::option_description; -using ::boost::program_options::options_description_easy_init; -using ::boost::program_options::options_description; -using ::boost::program_options::duplicate_option_error; - -// positional_options.hpp -using ::boost::program_options::positional_options_description; - -// cmdline.hpp -namespace command_line_style { -using ::boost::program_options::command_line_style::style_t; -using ::boost::program_options::command_line_style::allow_long; -using ::boost::program_options::command_line_style::allow_short; -using ::boost::program_options::command_line_style::allow_dash_for_short; -using ::boost::program_options::command_line_style::allow_slash_for_short; -using ::boost::program_options::command_line_style::long_allow_adjacent; -using ::boost::program_options::command_line_style::long_allow_next; -using ::boost::program_options::command_line_style::short_allow_adjacent; -using ::boost::program_options::command_line_style::short_allow_next; -using ::boost::program_options::command_line_style::allow_sticky; -using ::boost::program_options::command_line_style::allow_guessing; -using ::boost::program_options::command_line_style::long_case_insensitive; -using ::boost::program_options::command_line_style::short_case_insensitive; -using ::boost::program_options::command_line_style::case_insensitive; -using ::boost::program_options::command_line_style::allow_long_disguise; -using ::boost::program_options::command_line_style::unix_style; -using ::boost::program_options::command_line_style::default_style; -} - -// parsers.hpp and detail/parsers.hpp -using ::boost::program_options::basic_parsed_options; -using ::boost::program_options::parsed_options; -using ::boost::program_options::wparsed_options; -using ::boost::program_options::ext_parser; -using ::boost::program_options::basic_command_line_parser; -using ::boost::program_options::command_line_parser; -using ::boost::program_options::wcommand_line_parser; -using ::boost::program_options::parse_command_line; -using ::boost::program_options::parse_config_file; -using ::boost::program_options::collect_unrecognized_mode; -using ::boost::program_options::include_positional; -using ::boost::program_options::exclude_positional; -using ::boost::program_options::collect_unrecognized; -using ::boost::program_options::parse_environment; -using ::boost::program_options::split_unix; -#ifdef _WIN32 -using ::boost::program_options::split_winmain; -#endif - -// detail/convert.hpp -using ::boost::program_options::to_internal; - -// detail/cmdline.hpp, detail/config_file.hpp -namespace detail { -using ::boost::program_options::detail::cmdline; -using ::boost::program_options::detail::arg; -} - -// variables_map.hpp -using ::boost::program_options::store; -using ::boost::program_options::notify; -using ::boost::program_options::variable_value; -using ::boost::program_options::abstract_variables_map; -using ::boost::program_options::variables_map; - -} // namespace program_options -} // namespace boost +// The library's headers, in the module purview: declarations below are +// attached to this module and the public ones are exported through the +// BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT blocks. +#include From fcddfd766bc2aa2b8807d72dbd0e3fb0eceff429 Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Thu, 22 Oct 2026 11:48:46 +0330 Subject: [PATCH 05/17] Document why the module interface does not use import std yet Boost.Any and Boost.PFR guard their standard library consumption with an optional 'import std;' branch. The equivalent branch was tried here and does not work for this library yet: its public headers depend on Boost libraries that are not modularized (Function, LexicalCast, SmartPtr, Any), those headers textually include the standard library, and MSVC rejects that mix with redefinition errors (std::align_val_t, std::byte, ...). Boost.Any only gets away with it because its remaining textual includes (assert, config, throw_exception) are macro-only headers. Revert to unconditional textual preloads and document in modules/boost_program_options.cppm and CMakeLists.txt why, and that the guarded 'import std;' branch can be added once the dependencies are modularized. --- CMakeLists.txt | 6 ++++ modules/boost_program_options.cppm | 46 +++++++++++++++++++----------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eaf089d9d..2eccc37a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,12 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) target_compile_features(boost_program_options_modules PUBLIC cxx_std_20) + # Note: 'import std;' is deliberately not used in the module interface. + # The library's headers depend on Boost libraries that are not modularized + # yet (Function, LexicalCast, SmartPtr, Any) and those textually include + # the standard library, which conflicts with 'import std;'. See + # modules/boost_program_options.cppm. + if(NOT BOOST_SKIP_INSTALL_RULES AND NOT CMAKE_SKIP_INSTALL_RULES) # Install the module interface source next to the headers, so that it is # available to build systems that do not produce BMIs from installed diff --git a/modules/boost_program_options.cppm b/modules/boost_program_options.cppm index c1d5e23aa..279f8a671 100644 --- a/modules/boost_program_options.cppm +++ b/modules/boost_program_options.cppm @@ -21,13 +21,17 @@ // and to nothing in ordinary header builds (see // ). // +// * The standard library and the non-modularized dependencies are preloaded +// textually in the global module fragment (see the note there on why +// 'import std;' cannot be used yet). +// // * Unlike Boost.Any or Boost.PFR, this library's public headers include // non-modularized Boost libraries (Boost.Any, Boost.Function, -// Boost.SmartPtr, Boost.LexicalCast) and the standard library directly. -// All of those headers are preloaded in the global module fragment below, -// so that the includes triggered inside the purview are no-ops (include -// guards) and no foreign declarations get attached to this module. They -// remain attached to the global module, exactly as in header builds. +// Boost.SmartPtr, Boost.LexicalCast). All of those headers are preloaded +// in the global module fragment below, so that the includes triggered +// inside the purview are no-ops (include guards) and no foreign +// declarations get attached to this module. They remain attached to the +// global module, exactly as in header builds. // // * Macros (e.g. BOOST_PROGRAM_OPTIONS_VERSION) are not exported by C++20 // modules. Code that needs them must keep including the classic headers. @@ -39,19 +43,15 @@ module; -// Dependencies directly included by the library's public headers. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - // Standard headers directly included by the library's public headers. +// +// Note: unlike Boost.Any or Boost.PFR, this library cannot use +// 'import std;' here yet. Its public headers depend on Boost libraries +// that are not modularized (Boost.Function, Boost.LexicalCast, +// Boost.SmartPtr, Boost.Any), and those headers textually include the +// standard library, which conflicts with 'import std;'. Once the +// dependencies are modularized, this block can be replaced with an +// 'import std;' guarded the same way as in modules/boost_any.cppm. #include #include #include @@ -67,6 +67,18 @@ module; #include #include +// Dependencies directly included by the library's public headers. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + export module boost.program_options; #define BOOST_PROGRAM_OPTIONS_INTERFACE_UNIT From 198475ecf49508d4e17aeb9164c9eff388d515de Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Thu, 22 Oct 2026 12:32:59 +0330 Subject: [PATCH 06/17] Fix export block scoping in detail/value_semantic.hpp; keep typeindex re-export Removing the boost::typeindex operator re-export to test whether boost.type_index shipping its own module makes it redundant breaks the build (MSVC C2679 in boost/any.hpp: type_index == type_index is not found by ADL in importing translation units). The operators are still needed because boost.type_index is not imported here: its module is not built without BOOST_USE_MODULES infrastructure, and is preloaded textually in the global module fragment. Document this in the module interface; the block can be dropped once dependencies are modularized and imported. The experiment also exposed a latent brace-scoping bug: in detail/value_semantic.hpp the export block was opened outside the namespace boost { namespace program_options { block but closed inside it, so in module builds the 'using namespace validators;' directive landed in the wrong scope and the validate/value/wvalue definitions were attached incorrectly. The export blocks are now properly nested inside the namespace, split around the using-directive. --- .../program_options/detail/value_semantic.hpp | 7 +++---- modules/boost_program_options.cppm | 18 +++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/include/boost/program_options/detail/value_semantic.hpp b/include/boost/program_options/detail/value_semantic.hpp index 0ef54ad6f..c3e0361e7 100644 --- a/include/boost/program_options/detail/value_semantic.hpp +++ b/include/boost/program_options/detail/value_semantic.hpp @@ -15,9 +15,10 @@ // forward declaration namespace boost { template class optional; } +namespace boost { namespace program_options { + BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT -namespace boost { namespace program_options { namespace detail { extern BOOST_PROGRAM_OPTIONS_DECL std::string arg; @@ -245,8 +246,6 @@ BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT return r; } - +BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT }} - -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT diff --git a/modules/boost_program_options.cppm b/modules/boost_program_options.cppm index 279f8a671..82380b889 100644 --- a/modules/boost_program_options.cppm +++ b/modules/boost_program_options.cppm @@ -87,18 +87,18 @@ export module boost.program_options; # pragma clang diagnostic ignored "-Winclude-angled-in-module-purview" #endif -// Some compilers prune global-module-fragment declarations from the BMI. -// Templates defined by the preloaded headers (e.g. boost::any_cast, used by -// variable_value::as()) look up operators such as -// boost::typeindex::operator== by ADL when instantiated in importing -// translation units. Those operators must therefore be exported by the -// module, like the library's own declarations. +// boost::typeindex comparison operators are re-exported on purpose. +// boost::type_index ships a module of its own, but it is not imported (or +// built) here: is preloaded textually in the global +// module fragment via . Templates from those preloaded +// headers (e.g. boost::any_cast, used by variable_value::as()) look up +// these operators by ADL when instantiated in importing translation units, +// and some compilers do not find global-module declarations there unless +// the module exports them (MSVC: error C2679). Once the dependencies are +// modularized and imported instead, this block can be dropped. export namespace boost { namespace typeindex { using ::boost::typeindex::operator==; using ::boost::typeindex::operator!=; }} -// The library's headers, in the module purview: declarations below are -// attached to this module and the public ones are exported through the -// BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT blocks. #include From a593506153fddd166f4836ff20e480fb5142afe4 Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Thu, 22 Oct 2026 13:34:39 +0330 Subject: [PATCH 07/17] Build the module with module implementation units; support import std Investigation of the import std failure found the actual root causes of several problems: 1. On MSVC, a textual standard header parsed after 'import std;' clashes with the declarations provided by the std module (C2011 redefinitions); textual includes must come first. The import is now placed after the global module fragment preloads, and 'import std;' is enabled when CMake provides the std module (CMAKE_CXX_MODULE_STD + CMAKE_EXPERIMENTAL_CXX_IMPORT_STD), like in Boost.Any. Boost.Any gets away with fewer preloads because its remaining textual dependencies are macro-only headers. 2. More importantly, declarations in a module purview attach to the module, and MSVC mangles their out-of-line definitions with a module qualifier, so an interface built the export-block way cannot link against the classic, non-modular library (unresolved externals like ??0options_description@...Z::). A stale ninja dyndep graph had masked this in earlier local builds; fresh builds fail with 43 unresolved externals. Unlike Boost.Any/PFR, this library is compiled, so the module now follows the compiled-library recipe: modules/impl/*.cc are module implementation units that compile src/*.cpp into the module, giving the definitions the same attachment as the exported declarations. The boost_program_options_modules CMake target is self-contained (it no longer links the classic library) and scans its sources so the implementation units are compiled against the interface BMI. In implementation units the library headers are no-ops (declarations come from the imported primary interface; re-including them textually would redeclare the module's own entities), so every header covered by the interface is guarded with BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT. Internal headers used by the sources (detail/config_file.hpp, environment_iterator.hpp) are included once, unexported, in the interface instead. The shared std/Boost dependencies are preloaded textually in modules/gmf_preload.hpp, shared by all module units. The module test consumes import std when the module was built with it. Validated with fresh build directories: 15/15 tests with textual preloads, and the module test also passes built with import std (C++23 + std module). --- CMakeLists.txt | 71 +++++++++++++--- include/boost/program_options/cmdline.hpp | 6 ++ .../boost/program_options/detail/cmdline.hpp | 6 ++ .../program_options/detail/config_file.hpp | 6 ++ .../boost/program_options/detail/convert.hpp | 6 ++ .../boost/program_options/detail/parsers.hpp | 5 ++ .../program_options/detail/value_semantic.hpp | 5 ++ .../program_options/environment_iterator.hpp | 6 ++ .../boost/program_options/eof_iterator.hpp | 6 ++ include/boost/program_options/errors.hpp | 6 ++ include/boost/program_options/option.hpp | 6 ++ .../program_options/options_description.hpp | 6 ++ include/boost/program_options/parsers.hpp | 6 ++ .../program_options/positional_options.hpp | 6 ++ .../boost/program_options/value_semantic.hpp | 6 ++ .../boost/program_options/variables_map.hpp | 6 ++ modules/boost_program_options.cppm | 74 +++++++---------- modules/gmf_preload.hpp | 82 +++++++++++++++++++ modules/impl/cmdline.cc | 24 ++++++ modules/impl/config_file.cc | 24 ++++++ modules/impl/convert.cc | 24 ++++++ modules/impl/options_description.cc | 24 ++++++ modules/impl/parsers.cc | 24 ++++++ modules/impl/positional_options.cc | 24 ++++++ modules/impl/split.cc | 24 ++++++ modules/impl/utf8_codecvt_facet.cc | 24 ++++++ modules/impl/value_semantic.cc | 24 ++++++ modules/impl/variables_map.cc | 24 ++++++ modules/impl/winmain.cc | 24 ++++++ test/module_test.cpp | 13 ++- 30 files changed, 534 insertions(+), 58 deletions(-) create mode 100644 modules/gmf_preload.hpp create mode 100644 modules/impl/cmdline.cc create mode 100644 modules/impl/config_file.cc create mode 100644 modules/impl/convert.cc create mode 100644 modules/impl/options_description.cc create mode 100644 modules/impl/parsers.cc create mode 100644 modules/impl/positional_options.cc create mode 100644 modules/impl/split.cc create mode 100644 modules/impl/utf8_codecvt_facet.cc create mode 100644 modules/impl/value_semantic.cc create mode 100644 modules/impl/variables_map.cc create mode 100644 modules/impl/winmain.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eccc37a8..aae870393 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,25 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) message(FATAL_ERROR "boost_program_options_modules: building C++20 modules requires CMake 3.28 or later and a Ninja generator.") endif() - add_library(boost_program_options_modules) + # The module interface and implementation units. Declarations in the + # module purview attach to the boost.program_options module, and their + # definitions must carry the same attachment (some compilers mangle + # module-attached functions differently), so the library sources are + # compiled as module implementation units (modules/impl/*.cc) instead of + # being taken from the classic library. + add_library(boost_program_options_modules + modules/impl/cmdline.cc + modules/impl/config_file.cc + modules/impl/convert.cc + modules/impl/options_description.cc + modules/impl/parsers.cc + modules/impl/positional_options.cc + modules/impl/split.cc + modules/impl/utf8_codecvt_facet.cc + modules/impl/value_semantic.cc + modules/impl/variables_map.cc + modules/impl/winmain.cc + ) add_library(Boost::program_options_modules ALIAS boost_program_options_modules) target_sources(boost_program_options_modules @@ -79,17 +97,50 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) FILES modules/boost_program_options.cppm ) - # The module interface re-exports the declarations of the classic headers, - # whose definitions live in boost_program_options. - target_link_libraries(boost_program_options_modules PUBLIC boost_program_options) - target_compile_features(boost_program_options_modules PUBLIC cxx_std_20) - # Note: 'import std;' is deliberately not used in the module interface. - # The library's headers depend on Boost libraries that are not modularized - # yet (Function, LexicalCast, SmartPtr, Any) and those textually include - # the standard library, which conflicts with 'import std;'. See - # modules/boost_program_options.cppm. + # Scan all sources of the target: the implementation units in impl/ are + # recognized as such and compiled against the interface's BMI. + set_target_properties(boost_program_options_modules PROPERTIES CXX_SCAN_FOR_MODULES ON) + + target_include_directories(boost_program_options_modules PRIVATE include) + + target_compile_definitions(boost_program_options_modules + PUBLIC BOOST_PROGRAM_OPTIONS_NO_LIB + PRIVATE BOOST_PROGRAM_OPTIONS_SOURCE + ) + + # Same dependencies as the classic library. + target_link_libraries(boost_program_options_modules + PUBLIC + Boost::any + Boost::config + Boost::core + Boost::detail + Boost::function + Boost::iterator + Boost::lexical_cast + Boost::smart_ptr + Boost::throw_exception + Boost::type_traits + PRIVATE + Boost::bind + Boost::tokenizer + ) + + # Consume the standard library through 'import std;' in the module + # interface when the toolchain provides the std module (CMake 3.30+, + # -DCMAKE_CXX_MODULE_STD=ON and a C++ standard listed in + # CMAKE_CXX_COMPILER_IMPORT_STD), like other modularized Boost libraries. + # The textual preloads in the interface stay: the library's headers are not + # converted to compatibility headers yet. + if(CMAKE_CXX_MODULE_STD AND CMAKE_CXX_STANDARD IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) + set_target_properties(boost_program_options_modules PROPERTIES CXX_MODULE_STD ON) + target_compile_definitions(boost_program_options_modules PUBLIC BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) + message(STATUS "boost_program_options_modules: using 'import std;' (C++${CMAKE_CXX_STANDARD})") + else() + message(STATUS "boost_program_options_modules: using textual standard library preloads") + endif() if(NOT BOOST_SKIP_INSTALL_RULES AND NOT CMAKE_SKIP_INSTALL_RULES) # Install the module interface source next to the headers, so that it is diff --git a/include/boost/program_options/cmdline.hpp b/include/boost/program_options/cmdline.hpp index 1beee0b2b..3f3b82383 100644 --- a/include/boost/program_options/cmdline.hpp +++ b/include/boost/program_options/cmdline.hpp @@ -5,6 +5,11 @@ #ifndef BOOST_CMDLINE_HPP_VP_2004_03_13 #define BOOST_CMDLINE_HPP_VP_2004_03_13 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include @@ -93,5 +98,6 @@ BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT }}} +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/detail/cmdline.hpp b/include/boost/program_options/detail/cmdline.hpp index 467f3e1ff..4eafa052a 100644 --- a/include/boost/program_options/detail/cmdline.hpp +++ b/include/boost/program_options/detail/cmdline.hpp @@ -6,6 +6,11 @@ #ifndef BOOST_CMDLINE_VP_2003_05_19 #define BOOST_CMDLINE_VP_2003_05_19 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include #include @@ -159,5 +164,6 @@ BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT # pragma warning (pop) #endif +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/detail/config_file.hpp b/include/boost/program_options/detail/config_file.hpp index 808bec7f1..8fd2e9e67 100644 --- a/include/boost/program_options/detail/config_file.hpp +++ b/include/boost/program_options/detail/config_file.hpp @@ -6,6 +6,11 @@ #ifndef BOOST_CONFIG_FILE_VP_2003_01_02 #define BOOST_CONFIG_FILE_VP_2003_01_02 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include #include @@ -191,4 +196,5 @@ namespace boost { namespace program_options { namespace detail { # pragma warning(pop) #endif +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/detail/convert.hpp b/include/boost/program_options/detail/convert.hpp index 48d78d065..72aa7fc73 100644 --- a/include/boost/program_options/detail/convert.hpp +++ b/include/boost/program_options/detail/convert.hpp @@ -5,6 +5,11 @@ #ifndef BOOST_CONVERT_HPP_VP_2004_04_28 #define BOOST_CONVERT_HPP_VP_2004_04_28 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include @@ -110,4 +115,5 @@ namespace boost{ } BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT #endif +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/detail/parsers.hpp b/include/boost/program_options/detail/parsers.hpp index 0c0ce9517..4359e41a3 100644 --- a/include/boost/program_options/detail/parsers.hpp +++ b/include/boost/program_options/detail/parsers.hpp @@ -3,6 +3,10 @@ // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. #ifndef BOOST_PARSERS_HPP_VP_2004_05_06 #define BOOST_PARSERS_HPP_VP_2004_05_06 @@ -137,3 +141,4 @@ namespace boost { namespace program_options { BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT #endif +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT diff --git a/include/boost/program_options/detail/value_semantic.hpp b/include/boost/program_options/detail/value_semantic.hpp index c3e0361e7..5eccee109 100644 --- a/include/boost/program_options/detail/value_semantic.hpp +++ b/include/boost/program_options/detail/value_semantic.hpp @@ -3,6 +3,10 @@ // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. // This file defines template functions that are declared in // ../value_semantic.hpp. @@ -249,3 +253,4 @@ BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT }} +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT diff --git a/include/boost/program_options/environment_iterator.hpp b/include/boost/program_options/environment_iterator.hpp index 933919d15..4e03ad049 100644 --- a/include/boost/program_options/environment_iterator.hpp +++ b/include/boost/program_options/environment_iterator.hpp @@ -5,6 +5,11 @@ #ifndef BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 #define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include "eof_iterator.hpp" @@ -49,4 +54,5 @@ namespace boost { char** m_environment; }; } +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/eof_iterator.hpp b/include/boost/program_options/eof_iterator.hpp index c95d27f6b..291c55976 100644 --- a/include/boost/program_options/eof_iterator.hpp +++ b/include/boost/program_options/eof_iterator.hpp @@ -5,6 +5,11 @@ #ifndef BOOST_EOF_ITERATOR_VP_2004_03_12 #define BOOST_EOF_ITERATOR_VP_2004_03_12 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include @@ -97,5 +102,6 @@ namespace boost { }; } +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/errors.hpp b/include/boost/program_options/errors.hpp index 201562166..a53751910 100644 --- a/include/boost/program_options/errors.hpp +++ b/include/boost/program_options/errors.hpp @@ -6,6 +6,11 @@ #ifndef BOOST_ERRORS_VP_2003_01_02 #define BOOST_ERRORS_VP_2003_01_02 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include @@ -425,4 +430,5 @@ BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT # pragma warning (pop) #endif +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/option.hpp b/include/boost/program_options/option.hpp index 7e7246052..89ce835ef 100644 --- a/include/boost/program_options/option.hpp +++ b/include/boost/program_options/option.hpp @@ -5,6 +5,11 @@ #ifndef BOOST_OPTION_HPP_VP_2004_02_25 #define BOOST_OPTION_HPP_VP_2004_02_25 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include @@ -72,4 +77,5 @@ namespace boost { namespace program_options { BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/options_description.hpp b/include/boost/program_options/options_description.hpp index baececd18..4e4efdee4 100644 --- a/include/boost/program_options/options_description.hpp +++ b/include/boost/program_options/options_description.hpp @@ -7,6 +7,11 @@ #ifndef BOOST_OPTION_DESCRIPTION_VP_2003_05_19 #define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include #include @@ -302,4 +307,5 @@ BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT # pragma warning (pop) #endif +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/parsers.hpp b/include/boost/program_options/parsers.hpp index 3143d8ba6..cbb703744 100644 --- a/include/boost/program_options/parsers.hpp +++ b/include/boost/program_options/parsers.hpp @@ -6,6 +6,11 @@ #ifndef BOOST_PARSERS_VP_2003_05_19 #define BOOST_PARSERS_VP_2003_05_19 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include #include @@ -302,4 +307,5 @@ BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT #include "boost/program_options/detail/parsers.hpp" +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/positional_options.hpp b/include/boost/program_options/positional_options.hpp index 7e70b9707..d87586466 100644 --- a/include/boost/program_options/positional_options.hpp +++ b/include/boost/program_options/positional_options.hpp @@ -5,6 +5,11 @@ #ifndef BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 #define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include @@ -74,5 +79,6 @@ BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT # pragma warning (pop) #endif +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/value_semantic.hpp b/include/boost/program_options/value_semantic.hpp index 27ad4ca7f..6102832aa 100644 --- a/include/boost/program_options/value_semantic.hpp +++ b/include/boost/program_options/value_semantic.hpp @@ -5,6 +5,11 @@ #ifndef BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 #define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include #include @@ -424,5 +429,6 @@ BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT #include "boost/program_options/detail/value_semantic.hpp" +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/variables_map.hpp b/include/boost/program_options/variables_map.hpp index 465694a01..4914137d1 100644 --- a/include/boost/program_options/variables_map.hpp +++ b/include/boost/program_options/variables_map.hpp @@ -6,6 +6,11 @@ #ifndef BOOST_VARIABLES_MAP_VP_2003_05_19 #define BOOST_VARIABLES_MAP_VP_2003_05_19 +#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) +// In module implementation units (modules/impl/*.cc) these declarations +// are provided by the imported primary interface; re-including them here +// would redeclare the module's own entities. + #include @@ -221,4 +226,5 @@ BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT # pragma warning (pop) #endif +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/modules/boost_program_options.cppm b/modules/boost_program_options.cppm index 82380b889..68a5cd8cf 100644 --- a/modules/boost_program_options.cppm +++ b/modules/boost_program_options.cppm @@ -21,17 +21,21 @@ // and to nothing in ordinary header builds (see // ). // -// * The standard library and the non-modularized dependencies are preloaded -// textually in the global module fragment (see the note there on why -// 'import std;' cannot be used yet). +// * Unlike Boost.Any or Boost.PFR, this library is compiled: entities +// declared in a module purview are attached to the module, and MSVC (for +// one) mangles their out-of-line definitions with a module qualifier, so +// they cannot be provided by the classic, non-modular library. The module +// target therefore also compiles the library sources as module +// implementation units (impl/*.cc), which redeclare the exported +// interface and provide matching, module-attached definitions. The +// classic library is unchanged and keeps serving header builds. // -// * Unlike Boost.Any or Boost.PFR, this library's public headers include -// non-modularized Boost libraries (Boost.Any, Boost.Function, -// Boost.SmartPtr, Boost.LexicalCast). All of those headers are preloaded -// in the global module fragment below, so that the includes triggered -// inside the purview are no-ops (include guards) and no foreign -// declarations get attached to this module. They remain attached to the -// global module, exactly as in header builds. +// * The standard library and the non-modularized dependencies are preloaded +// textually in the global module fragment (see gmf_preload.hpp), and +// 'import std;' is used in addition when the toolchain provides it. +// The import must come after the textual preloads: on MSVC, a textual +// standard header parsed after 'import std;' clashes with the +// declarations already provided by the std module. // // * Macros (e.g. BOOST_PROGRAM_OPTIONS_VERSION) are not exported by C++20 // modules. Code that needs them must keep including the classic headers. @@ -43,41 +47,11 @@ module; -// Standard headers directly included by the library's public headers. -// -// Note: unlike Boost.Any or Boost.PFR, this library cannot use -// 'import std;' here yet. Its public headers depend on Boost libraries -// that are not modularized (Boost.Function, Boost.LexicalCast, -// Boost.SmartPtr, Boost.Any), and those headers textually include the -// standard library, which conflicts with 'import std;'. Once the -// dependencies are modularized, this block can be replaced with an -// 'import std;' guarded the same way as in modules/boost_any.cppm. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "gmf_preload.hpp" -// Dependencies directly included by the library's public headers. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifdef BOOST_PROGRAM_OPTIONS_USE_STD_MODULE +import std; +#endif export module boost.program_options; @@ -94,11 +68,19 @@ export module boost.program_options; // headers (e.g. boost::any_cast, used by variable_value::as()) look up // these operators by ADL when instantiated in importing translation units, // and some compilers do not find global-module declarations there unless -// the module exports them (MSVC: error C2679). Once the dependencies are -// modularized and imported instead, this block can be dropped. +// the module exports them (MSVC: error C2679). export namespace boost { namespace typeindex { using ::boost::typeindex::operator==; using ::boost::typeindex::operator!=; }} +// The library's headers, in the module purview: the declarations below are +// attached to this module and the public ones are exported through the +// BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT blocks. #include + +// Additional internal headers used by the implementation units: included +// here once (unexported) so that every unit of the module sees the same +// declarations instead of re-including them textually. +#include +#include diff --git a/modules/gmf_preload.hpp b/modules/gmf_preload.hpp new file mode 100644 index 000000000..37dd98f50 --- /dev/null +++ b/modules/gmf_preload.hpp @@ -0,0 +1,82 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Shared global module fragment preloads for the boost.program_options +// module units (the interface in boost_program_options.cppm and the +// implementation units in impl/). +// +// Everything that the library's headers and sources include, except the +// library's own headers, is preloaded here so that the includes triggered +// inside the module purviews are no-ops (include guards) and no foreign +// declarations get attached to the module. Boost.ProgramOptions headers +// must NOT be preloaded here: they are included in the purviews, where +// their declarations are attached to (or, in implementation units, +// redeclare those of) the boost.program_options module. + +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_GMF_PRELOAD_HPP +#define BOOST_PROGRAM_OPTIONS_MODULE_GMF_PRELOAD_HPP + +// Macro-only header; macros are not exported by 'import std'. +#include + +// Standard headers used by the library's headers and sources. +#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 + +// Boost dependencies used by the library's headers and sources. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// The shared utf8_codecvt_facet detail header is macro-parameterized; wrap +// it exactly like +// and src/utf8_codecvt_facet.cpp do, so that the class stays attached to +// the global module, as in classic builds. +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL + +#endif diff --git a/modules/impl/cmdline.cc b/modules/impl/cmdline.cc new file mode 100644 index 000000000..43ec6b38a --- /dev/null +++ b/modules/impl/cmdline.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/cmdline.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/cmdline.cpp" \ No newline at end of file diff --git a/modules/impl/config_file.cc b/modules/impl/config_file.cc new file mode 100644 index 000000000..ab2b9c67d --- /dev/null +++ b/modules/impl/config_file.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/config_file.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/config_file.cpp" \ No newline at end of file diff --git a/modules/impl/convert.cc b/modules/impl/convert.cc new file mode 100644 index 000000000..fa8ad90a0 --- /dev/null +++ b/modules/impl/convert.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/convert.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/convert.cpp" \ No newline at end of file diff --git a/modules/impl/options_description.cc b/modules/impl/options_description.cc new file mode 100644 index 000000000..eec78df9d --- /dev/null +++ b/modules/impl/options_description.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/options_description.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/options_description.cpp" \ No newline at end of file diff --git a/modules/impl/parsers.cc b/modules/impl/parsers.cc new file mode 100644 index 000000000..2248717ee --- /dev/null +++ b/modules/impl/parsers.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/parsers.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/parsers.cpp" \ No newline at end of file diff --git a/modules/impl/positional_options.cc b/modules/impl/positional_options.cc new file mode 100644 index 000000000..3cbea975d --- /dev/null +++ b/modules/impl/positional_options.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/positional_options.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/positional_options.cpp" \ No newline at end of file diff --git a/modules/impl/split.cc b/modules/impl/split.cc new file mode 100644 index 000000000..06fc79779 --- /dev/null +++ b/modules/impl/split.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/split.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/split.cpp" \ No newline at end of file diff --git a/modules/impl/utf8_codecvt_facet.cc b/modules/impl/utf8_codecvt_facet.cc new file mode 100644 index 000000000..e81c8ffb5 --- /dev/null +++ b/modules/impl/utf8_codecvt_facet.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/utf8_codecvt_facet.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/utf8_codecvt_facet.cpp" \ No newline at end of file diff --git a/modules/impl/value_semantic.cc b/modules/impl/value_semantic.cc new file mode 100644 index 000000000..5ebabe43f --- /dev/null +++ b/modules/impl/value_semantic.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/value_semantic.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/value_semantic.cpp" \ No newline at end of file diff --git a/modules/impl/variables_map.cc b/modules/impl/variables_map.cc new file mode 100644 index 000000000..6fc8505a1 --- /dev/null +++ b/modules/impl/variables_map.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/variables_map.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/variables_map.cpp" \ No newline at end of file diff --git a/modules/impl/winmain.cc b/modules/impl/winmain.cc new file mode 100644 index 000000000..553d78ab6 --- /dev/null +++ b/modules/impl/winmain.cc @@ -0,0 +1,24 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Module implementation unit for src/winmain.cpp. Together with the module +// interface in modules/boost_program_options.cppm, this attaches the +// library's definitions to the boost.program_options module, matching the +// attachment of the exported declarations. See the notes in that file. + +module; + +#include "../gmf_preload.hpp" + +// Macros used by the sources (the library's headers are no-ops below). +#include + +module boost.program_options; + +// The library's headers are no-ops in this unit: their declarations are +// provided by the imported primary interface. +#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT + +#include "../../src/winmain.cpp" \ No newline at end of file diff --git a/test/module_test.cpp b/test/module_test.cpp index 0d14c490a..de0f7e787 100644 --- a/test/module_test.cpp +++ b/test/module_test.cpp @@ -7,22 +7,31 @@ // No Boost header is included on purpose: everything must come from // 'import boost.program_options;'. +// Standard library: textual includes by default; when the module was built +// with 'import std' (BOOST_PROGRAM_OPTIONS_USE_STD_MODULE), the standard +// module comes with the module and the textual includes would clash with it. +#ifdef BOOST_PROGRAM_OPTIONS_USE_STD_MODULE +import std; +#else +#include #include #include #include #include #include #include +#endif import boost.program_options; // The test is built in both Debug and Release configurations, so plain // assert() would be a no-op in Release. Use an always-active check. +// (Uses only facilities provided by 'import std', no macros.) #define CHECK(cond) \ do { \ if (!(cond)) { \ - std::fprintf(stderr, "CHECK failed: %s (%s:%d)\n", \ - #cond, __FILE__, __LINE__); \ + std::cerr << "CHECK failed: " << #cond << " (" << __FILE__ \ + << ":" << __LINE__ << ")\n"; \ std::abort(); \ } \ } while (0) From 940fe216ce8cac6505b96408f9052857fb7433d6 Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Thu, 22 Oct 2026 14:11:45 +0330 Subject: [PATCH 08/17] Expand the typeindex re-export comment for the implementation-unit design Re-verified that the boost::typeindex operator re-export is still required with the module implementation unit architecture: removing it fails the module test with MSVC C2679 in boost/any.hpp (any_cast compares type_index objects by ADL in importing translation units). The operators belong to a preloaded, global-module dependency header, so neither the export blocks nor the implementation units of this module cover them. Documented; the block stays until the dependencies are modularized and imported. --- modules/boost_program_options.cppm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/boost_program_options.cppm b/modules/boost_program_options.cppm index 68a5cd8cf..8a7aa2bb2 100644 --- a/modules/boost_program_options.cppm +++ b/modules/boost_program_options.cppm @@ -64,11 +64,13 @@ export module boost.program_options; // boost::typeindex comparison operators are re-exported on purpose. // boost::type_index ships a module of its own, but it is not imported (or // built) here: is preloaded textually in the global -// module fragment via . Templates from those preloaded -// headers (e.g. boost::any_cast, used by variable_value::as()) look up -// these operators by ADL when instantiated in importing translation units, -// and some compilers do not find global-module declarations there unless -// the module exports them (MSVC: error C2679). +// module fragment via , so the operators are attached to +// the global module. The preloaded boost::any_cast template is instantiated +// in importing translation units (e.g. by variable_value::as()) and +// looks up these operators by ADL, and some compilers do not find +// global-module declarations there unless the module exports them (MSVC: +// error C2679). Once the dependencies are modularized and imported instead +// of preloaded, this block can be dropped. export namespace boost { namespace typeindex { using ::boost::typeindex::operator==; using ::boost::typeindex::operator!=; From ca72d03e9797c15f232735f8309a02060b658689 Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Thu, 22 Oct 2026 22:48:00 +0330 Subject: [PATCH 09/17] Restore the thin wrapper interface; keep all changes under src/ Per review feedback, revert the export-block/implementation-unit architecture and keep the library headers completely untouched, with all module-related files under src/: - The module interface is again a thin wrapper (src/cppm/boost/program_options.cppm): the classic umbrella header is included in the global module fragment and the public declarations are re-exported with exported using-declarations. No header is modified, declarations stay attached to the global module, and the definitions in the classic compiled library link directly, so no module implementation units and no global-module-fragment preload list are needed (modules/impl/*.cc and modules/gmf_preload.hpp removed). - The header export-block style used by Boost.Any/Boost.PFR requires, for a compiled library, module implementation units (MSVC mangles module-attached functions with a module qualifier, so the classic library cannot provide their definitions) and modularized dependencies. That migration can be revisited once the Boost dependencies are modularized; documented in the interface. - modules/usage_sample.cpp moves to src/cppm/usage_sample.cpp; CMake, README and doc/modules.xml updated accordingly. Validated in fresh build directories: all 15 tests pass, and the module test also passes built with 'import std;' (C++23 + std module). --- CMakeLists.txt | 59 +----- README.md | 21 +- doc/modules.xml | 30 ++- include/boost/program_options/cmdline.hpp | 13 -- include/boost/program_options/config.hpp | 26 --- .../boost/program_options/detail/cmdline.hpp | 10 - .../program_options/detail/config_file.hpp | 6 - .../boost/program_options/detail/convert.hpp | 12 -- .../boost/program_options/detail/parsers.hpp | 9 - .../program_options/detail/value_semantic.hpp | 16 +- .../program_options/environment_iterator.hpp | 6 - .../boost/program_options/eof_iterator.hpp | 6 - include/boost/program_options/errors.hpp | 10 - include/boost/program_options/option.hpp | 10 - .../program_options/options_description.hpp | 10 - include/boost/program_options/parsers.hpp | 10 - .../program_options/positional_options.hpp | 10 - .../boost/program_options/value_semantic.hpp | 10 - .../boost/program_options/variables_map.hpp | 10 - modules/boost_program_options.cppm | 88 -------- modules/gmf_preload.hpp | 82 -------- modules/impl/cmdline.cc | 24 --- modules/impl/config_file.cc | 24 --- modules/impl/convert.cc | 24 --- modules/impl/options_description.cc | 24 --- modules/impl/parsers.cc | 24 --- modules/impl/positional_options.cc | 24 --- modules/impl/split.cc | 24 --- modules/impl/utf8_codecvt_facet.cc | 24 --- modules/impl/value_semantic.cc | 24 --- modules/impl/variables_map.cc | 24 --- modules/impl/winmain.cc | 24 --- src/cppm/boost/program_options.cppm | 197 ++++++++++++++++++ {modules => src/cppm}/usage_sample.cpp | 0 34 files changed, 233 insertions(+), 682 deletions(-) delete mode 100644 modules/boost_program_options.cppm delete mode 100644 modules/gmf_preload.hpp delete mode 100644 modules/impl/cmdline.cc delete mode 100644 modules/impl/config_file.cc delete mode 100644 modules/impl/convert.cc delete mode 100644 modules/impl/options_description.cc delete mode 100644 modules/impl/parsers.cc delete mode 100644 modules/impl/positional_options.cc delete mode 100644 modules/impl/split.cc delete mode 100644 modules/impl/utf8_codecvt_facet.cc delete mode 100644 modules/impl/value_semantic.cc delete mode 100644 modules/impl/variables_map.cc delete mode 100644 modules/impl/winmain.cc create mode 100644 src/cppm/boost/program_options.cppm rename {modules => src/cppm}/usage_sample.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index aae870393..501651066 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,63 +70,20 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) message(FATAL_ERROR "boost_program_options_modules: building C++20 modules requires CMake 3.28 or later and a Ninja generator.") endif() - # The module interface and implementation units. Declarations in the - # module purview attach to the boost.program_options module, and their - # definitions must carry the same attachment (some compilers mangle - # module-attached functions differently), so the library sources are - # compiled as module implementation units (modules/impl/*.cc) instead of - # being taken from the classic library. - add_library(boost_program_options_modules - modules/impl/cmdline.cc - modules/impl/config_file.cc - modules/impl/convert.cc - modules/impl/options_description.cc - modules/impl/parsers.cc - modules/impl/positional_options.cc - modules/impl/split.cc - modules/impl/utf8_codecvt_facet.cc - modules/impl/value_semantic.cc - modules/impl/variables_map.cc - modules/impl/winmain.cc - ) + # The module interface re-exports the declarations of the classic headers, + # whose definitions live in boost_program_options. + add_library(boost_program_options_modules) add_library(Boost::program_options_modules ALIAS boost_program_options_modules) target_sources(boost_program_options_modules PUBLIC FILE_SET CXX_MODULES - BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/modules" - FILES modules/boost_program_options.cppm + BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/cppm" + FILES src/cppm/boost/program_options.cppm ) - target_compile_features(boost_program_options_modules PUBLIC cxx_std_20) - - # Scan all sources of the target: the implementation units in impl/ are - # recognized as such and compiled against the interface's BMI. - set_target_properties(boost_program_options_modules PROPERTIES CXX_SCAN_FOR_MODULES ON) - - target_include_directories(boost_program_options_modules PRIVATE include) + target_link_libraries(boost_program_options_modules PUBLIC boost_program_options) - target_compile_definitions(boost_program_options_modules - PUBLIC BOOST_PROGRAM_OPTIONS_NO_LIB - PRIVATE BOOST_PROGRAM_OPTIONS_SOURCE - ) - - # Same dependencies as the classic library. - target_link_libraries(boost_program_options_modules - PUBLIC - Boost::any - Boost::config - Boost::core - Boost::detail - Boost::function - Boost::iterator - Boost::lexical_cast - Boost::smart_ptr - Boost::throw_exception - Boost::type_traits - PRIVATE - Boost::bind - Boost::tokenizer - ) + target_compile_features(boost_program_options_modules PUBLIC cxx_std_20) # Consume the standard library through 'import std;' in the module # interface when the toolchain provides the std module (CMake 3.30+, @@ -146,7 +103,7 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) # Install the module interface source next to the headers, so that it is # available to build systems that do not produce BMIs from installed # packages (e.g. MSBuild projects adding the .cppm/.ixx directly). - install(FILES modules/boost_program_options.cppm DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost") + install(FILES src/cppm/boost/program_options.cppm DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost") endif() endif() diff --git a/README.md b/README.md index 732f17b40..65537dbe6 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,17 @@ you can write import boost.program_options; ``` -and keep using the `boost::program_options` namespace unchanged. The module -follows the same design as other Boost libraries that ship one (e.g. Boost.Any -and Boost.PFR): the public declarations in the headers are wrapped in -`BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT` blocks, which expand to -`export { ... }` while the module interface unit is being compiled and to -nothing in ordinary builds, so the classic header interface is unchanged. +and keep using the `boost::program_options` namespace unchanged. + +The interface (`src/cppm/boost/program_options.cppm`) is a thin wrapper: it +includes the classic umbrella header in the global module fragment and +re-exports the public declarations with exported using-declarations. No +library header is modified, every declaration stays attached to the global +module, and the definitions in the classic compiled library are reused +directly. (The export-block style used by header-only libraries such as +Boost.Any and Boost.PFR is not applicable here yet: for a compiled library +it requires module implementation units and modularized dependencies; the +migration can be revisited once the Boost dependencies are modularized.) The module is not built by default. Enable it by configuring CMake with `-DBOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON`, which creates the additional @@ -71,8 +76,8 @@ changes to re-align with the evolution of Boost C++ Libraries and C++. | `doc` | documentation | | `example` | use case examples | | `include` | headers | -| `modules` | C++20 module interface | -| `src` | source code for link library | +| `src` | source code for link library and | +| | C++20 module interface | | `test` | unit tests | ### More information diff --git a/doc/modules.xml b/doc/modules.xml index 47446351a..7423f47e8 100644 --- a/doc/modules.xml +++ b/doc/modules.xml @@ -46,17 +46,18 @@ int main(int argc, char* argv[]) declared by the umbrella header <boost/program_options.hpp>, so existing code only needs to replace the #include with an import. A minimal, compilable - example is provided in modules/usage_sample.cpp. - - The interface follows the same design as other Boost libraries that - ship a module (for example Boost.Any and Boost.PFR): the public - declarations of the classic headers are wrapped in - BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT / - BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT blocks (defined in - <boost/program_options/config.hpp>), which expand to - export { ... } while the module interface unit is being - compiled and to nothing in ordinary builds, leaving the header-based - interface unchanged. + example is provided in src/cppm/usage_sample.cpp. + + The interface (src/cppm/boost/program_options.cppm) is + a thin wrapper: it includes the classic umbrella header in the global + module fragment and re-exports the public declarations with exported + using-declarations. No library header is modified, every declaration + stays attached to the global module, and the definitions in the classic + compiled library are reused directly. The export-block style used by + header-only libraries such as Boost.Any and Boost.PFR is not applicable + here yet: for a compiled library it requires module implementation units + and modularized dependencies; the migration can be revisited once the + Boost dependencies are modularized.
Building and Using @@ -83,12 +84,7 @@ ctest --output-on-failure The import statement only makes the library's declarations available. As usual with modules, macros such as BOOST_PROGRAM_OPTIONS_VERSION are not exported; code that - needs those macros must include the classic headers. As with other - modularized Boost libraries, mixing - #include <boost/program_options.hpp> and - import boost.program_options; for the library's own - declarations in the same program is not supported; a translation unit - should use one style or the other. + needs those macros must include the classic headers.
diff --git a/include/boost/program_options/cmdline.hpp b/include/boost/program_options/cmdline.hpp index 3f3b82383..8b57819d8 100644 --- a/include/boost/program_options/cmdline.hpp +++ b/include/boost/program_options/cmdline.hpp @@ -5,15 +5,6 @@ #ifndef BOOST_CMDLINE_HPP_VP_2004_03_13 #define BOOST_CMDLINE_HPP_VP_2004_03_13 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - - -#include - -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT namespace boost { namespace program_options { namespace command_line_style { /** Various possible styles of options. @@ -92,12 +83,8 @@ namespace boost { namespace program_options { namespace command_line_style { /** The default style. */ default_style = unix_style }; - -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - }}} -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/config.hpp b/include/boost/program_options/config.hpp index 643a9aca2..69141726b 100644 --- a/include/boost/program_options/config.hpp +++ b/include/boost/program_options/config.hpp @@ -47,32 +47,6 @@ #define BOOST_PROGRAM_OPTIONS_DECL #endif -/////////////////////////////////////////////////////////////////////////////// -// C++20 modules support (modules/boost_program_options.cppm). -// -// When the module interface unit is being compiled, the library's headers -// are included in the module purview and their public declarations are -// wrapped into BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT blocks, which -// expand to 'export { ... }'. In ordinary (header) builds the macros expand -// to nothing and the headers are unchanged. - -#ifdef BOOST_PROGRAM_OPTIONS_INTERFACE_UNIT -# define BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT export { -# define BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT } -#else -# define BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT -# define BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT -#endif - -// With BOOST_USE_MODULES, including any Boost.ProgramOptions header is -// equivalent to 'import boost.program_options;', keeping user code source -// compatible between the two consumption styles. -#if defined(BOOST_USE_MODULES) && !defined(BOOST_PROGRAM_OPTIONS_INTERFACE_UNIT) -#ifndef BOOST_IN_MODULE_PURVIEW -import boost.program_options; -#endif -#endif - #endif // BOOST_PROGRAM_OPTIONS_CONFIG_HK_2004_01_11 diff --git a/include/boost/program_options/detail/cmdline.hpp b/include/boost/program_options/detail/cmdline.hpp index 4eafa052a..dce407c0b 100644 --- a/include/boost/program_options/detail/cmdline.hpp +++ b/include/boost/program_options/detail/cmdline.hpp @@ -6,11 +6,6 @@ #ifndef BOOST_CMDLINE_VP_2003_05_19 #define BOOST_CMDLINE_VP_2003_05_19 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include #include @@ -32,8 +27,6 @@ # pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::positional_options_description' #endif -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - namespace boost { namespace program_options { namespace detail { /** Command line parser class. Main requirements were: @@ -158,12 +151,9 @@ namespace boost { namespace program_options { namespace detail { }}} -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - #if defined(BOOST_MSVC) # pragma warning (pop) #endif -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/detail/config_file.hpp b/include/boost/program_options/detail/config_file.hpp index 8fd2e9e67..808bec7f1 100644 --- a/include/boost/program_options/detail/config_file.hpp +++ b/include/boost/program_options/detail/config_file.hpp @@ -6,11 +6,6 @@ #ifndef BOOST_CONFIG_FILE_VP_2003_01_02 #define BOOST_CONFIG_FILE_VP_2003_01_02 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include #include @@ -196,5 +191,4 @@ namespace boost { namespace program_options { namespace detail { # pragma warning(pop) #endif -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/detail/convert.hpp b/include/boost/program_options/detail/convert.hpp index 72aa7fc73..a22dd6f37 100644 --- a/include/boost/program_options/detail/convert.hpp +++ b/include/boost/program_options/detail/convert.hpp @@ -5,11 +5,6 @@ #ifndef BOOST_CONVERT_HPP_VP_2004_04_28 #define BOOST_CONVERT_HPP_VP_2004_04_28 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include @@ -32,8 +27,6 @@ namespace std } #endif -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - namespace boost { /** Converts from local 8 bit encoding into wchar_t string using @@ -93,12 +86,9 @@ namespace boost { } -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - #else #include #include -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT namespace boost{ namespace program_options{ BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::string&); @@ -113,7 +103,5 @@ namespace boost{ } } } -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT #endif -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/detail/parsers.hpp b/include/boost/program_options/detail/parsers.hpp index 4359e41a3..cdda539ca 100644 --- a/include/boost/program_options/detail/parsers.hpp +++ b/include/boost/program_options/detail/parsers.hpp @@ -3,10 +3,6 @@ // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. #ifndef BOOST_PARSERS_HPP_VP_2004_05_06 #define BOOST_PARSERS_HPP_VP_2004_05_06 @@ -14,8 +10,6 @@ #include -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - namespace boost { namespace program_options { template @@ -138,7 +132,4 @@ namespace boost { namespace program_options { }} -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - #endif -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT diff --git a/include/boost/program_options/detail/value_semantic.hpp b/include/boost/program_options/detail/value_semantic.hpp index 5eccee109..27b7c241b 100644 --- a/include/boost/program_options/detail/value_semantic.hpp +++ b/include/boost/program_options/detail/value_semantic.hpp @@ -3,10 +3,6 @@ // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. // This file defines template functions that are declared in // ../value_semantic.hpp. @@ -19,10 +15,7 @@ // forward declaration namespace boost { template class optional; } -namespace boost { namespace program_options { - -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - +namespace boost { namespace program_options { namespace detail { extern BOOST_PROGRAM_OPTIONS_DECL std::string arg; @@ -85,12 +78,8 @@ BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT check_first_occurrence(const boost::any& value); } -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - using namespace validators; -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - /** Validates 's' and updates 'v'. @pre 'v' is either empty or in the state assigned by the previous invocation of 'validate'. @@ -250,7 +239,6 @@ BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT return r; } -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT + }} -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT diff --git a/include/boost/program_options/environment_iterator.hpp b/include/boost/program_options/environment_iterator.hpp index 4e03ad049..933919d15 100644 --- a/include/boost/program_options/environment_iterator.hpp +++ b/include/boost/program_options/environment_iterator.hpp @@ -5,11 +5,6 @@ #ifndef BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 #define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include "eof_iterator.hpp" @@ -54,5 +49,4 @@ namespace boost { char** m_environment; }; } -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/eof_iterator.hpp b/include/boost/program_options/eof_iterator.hpp index 291c55976..c95d27f6b 100644 --- a/include/boost/program_options/eof_iterator.hpp +++ b/include/boost/program_options/eof_iterator.hpp @@ -5,11 +5,6 @@ #ifndef BOOST_EOF_ITERATOR_VP_2004_03_12 #define BOOST_EOF_ITERATOR_VP_2004_03_12 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include @@ -102,6 +97,5 @@ namespace boost { }; } -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/errors.hpp b/include/boost/program_options/errors.hpp index a53751910..953db1366 100644 --- a/include/boost/program_options/errors.hpp +++ b/include/boost/program_options/errors.hpp @@ -6,11 +6,6 @@ #ifndef BOOST_ERRORS_VP_2003_01_02 #define BOOST_ERRORS_VP_2003_01_02 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include @@ -26,8 +21,6 @@ # pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::ambiguous_option' #endif -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - namespace boost { namespace program_options { inline std::string strip_prefixes(const std::string& text) @@ -424,11 +417,8 @@ namespace boost { namespace program_options { }} -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - #if defined(BOOST_MSVC) # pragma warning (pop) #endif -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/option.hpp b/include/boost/program_options/option.hpp index 89ce835ef..427678fa7 100644 --- a/include/boost/program_options/option.hpp +++ b/include/boost/program_options/option.hpp @@ -5,19 +5,12 @@ #ifndef BOOST_OPTION_HPP_VP_2004_02_25 #define BOOST_OPTION_HPP_VP_2004_02_25 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include #include #include -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - namespace boost { namespace program_options { /** Option found in input source. @@ -75,7 +68,4 @@ namespace boost { namespace program_options { }} -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/options_description.hpp b/include/boost/program_options/options_description.hpp index 4e4efdee4..da2c4bbfe 100644 --- a/include/boost/program_options/options_description.hpp +++ b/include/boost/program_options/options_description.hpp @@ -7,11 +7,6 @@ #ifndef BOOST_OPTION_DESCRIPTION_VP_2003_05_19 #define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include #include @@ -37,8 +32,6 @@ #endif -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - /** Boost namespace */ namespace boost { /** Namespace for the library. */ @@ -301,11 +294,8 @@ namespace program_options { }; }} -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - #if defined(BOOST_MSVC) # pragma warning (pop) #endif -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/parsers.hpp b/include/boost/program_options/parsers.hpp index cbb703744..c86b53746 100644 --- a/include/boost/program_options/parsers.hpp +++ b/include/boost/program_options/parsers.hpp @@ -6,11 +6,6 @@ #ifndef BOOST_PARSERS_VP_2003_05_19 #define BOOST_PARSERS_VP_2003_05_19 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include #include @@ -27,8 +22,6 @@ # pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::basic_parsed_options' #endif -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - namespace boost { namespace program_options { class options_description; @@ -297,8 +290,6 @@ namespace boost { namespace program_options { }} -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - #if defined(BOOST_MSVC) # pragma warning (pop) #endif @@ -307,5 +298,4 @@ BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT #include "boost/program_options/detail/parsers.hpp" -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/positional_options.hpp b/include/boost/program_options/positional_options.hpp index d87586466..c19c9250e 100644 --- a/include/boost/program_options/positional_options.hpp +++ b/include/boost/program_options/positional_options.hpp @@ -5,11 +5,6 @@ #ifndef BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 #define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include @@ -21,8 +16,6 @@ # pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::positional_options_description' #endif -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - namespace boost { namespace program_options { /** Describes positional options. @@ -73,12 +66,9 @@ namespace boost { namespace program_options { }} -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - #if defined(BOOST_MSVC) # pragma warning (pop) #endif -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/value_semantic.hpp b/include/boost/program_options/value_semantic.hpp index 6102832aa..717f2cd99 100644 --- a/include/boost/program_options/value_semantic.hpp +++ b/include/boost/program_options/value_semantic.hpp @@ -5,11 +5,6 @@ #ifndef BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 #define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include #include @@ -23,8 +18,6 @@ #include #include -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - namespace boost { namespace program_options { /** Class which specifies how the option's value is to be parsed @@ -425,10 +418,7 @@ namespace boost { namespace program_options { }} -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - #include "boost/program_options/detail/value_semantic.hpp" -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/include/boost/program_options/variables_map.hpp b/include/boost/program_options/variables_map.hpp index 4914137d1..3d7662931 100644 --- a/include/boost/program_options/variables_map.hpp +++ b/include/boost/program_options/variables_map.hpp @@ -6,11 +6,6 @@ #ifndef BOOST_VARIABLES_MAP_VP_2003_05_19 #define BOOST_VARIABLES_MAP_VP_2003_05_19 -#if !defined(BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT) -// In module implementation units (modules/impl/*.cc) these declarations -// are provided by the imported primary interface; re-including them here -// would redeclare the module's own entities. - #include @@ -26,8 +21,6 @@ # pragma warning (disable:4251) // 'boost::program_options::variable_value::v' : class 'boost::any' needs to have dll-interface to be used by clients of class 'boost::program_options::variable_value #endif -BOOST_PROGRAM_OPTIONS_BEGIN_MODULE_EXPORT - namespace boost { namespace program_options { template @@ -220,11 +213,8 @@ namespace boost { namespace program_options { }} -BOOST_PROGRAM_OPTIONS_END_MODULE_EXPORT - #if defined(BOOST_MSVC) # pragma warning (pop) #endif -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT #endif diff --git a/modules/boost_program_options.cppm b/modules/boost_program_options.cppm deleted file mode 100644 index 8a7aa2bb2..000000000 --- a/modules/boost_program_options.cppm +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// C++20 module interface for Boost.ProgramOptions. -// -// Consumers can replace -// #include -// with -// import boost.program_options; -// and keep using the boost::program_options namespace as before. -// -// Implementation notes: -// -// * This follows the same design as other Boost libraries that ship a -// module (e.g. Boost.Any and Boost.PFR): the library's public headers are -// included in the module purview below, and their public declarations are -// wrapped in BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT blocks, which -// expand to 'export { ... }' while this interface unit is being compiled -// and to nothing in ordinary header builds (see -// ). -// -// * Unlike Boost.Any or Boost.PFR, this library is compiled: entities -// declared in a module purview are attached to the module, and MSVC (for -// one) mangles their out-of-line definitions with a module qualifier, so -// they cannot be provided by the classic, non-modular library. The module -// target therefore also compiles the library sources as module -// implementation units (impl/*.cc), which redeclare the exported -// interface and provide matching, module-attached definitions. The -// classic library is unchanged and keeps serving header builds. -// -// * The standard library and the non-modularized dependencies are preloaded -// textually in the global module fragment (see gmf_preload.hpp), and -// 'import std;' is used in addition when the toolchain provides it. -// The import must come after the textual preloads: on MSVC, a textual -// standard header parsed after 'import std;' clashes with the -// declarations already provided by the std module. -// -// * Macros (e.g. BOOST_PROGRAM_OPTIONS_VERSION) are not exported by C++20 -// modules. Code that needs them must keep including the classic headers. -// -// * The module covers everything reachable from . -// The auxiliary iterator headers -// and are generic -// utilities outside of that umbrella header and are not exported here. - -module; - -#include "gmf_preload.hpp" - -#ifdef BOOST_PROGRAM_OPTIONS_USE_STD_MODULE -import std; -#endif - -export module boost.program_options; - -#define BOOST_PROGRAM_OPTIONS_INTERFACE_UNIT - -#ifdef __clang__ -# pragma clang diagnostic ignored "-Winclude-angled-in-module-purview" -#endif - -// boost::typeindex comparison operators are re-exported on purpose. -// boost::type_index ships a module of its own, but it is not imported (or -// built) here: is preloaded textually in the global -// module fragment via , so the operators are attached to -// the global module. The preloaded boost::any_cast template is instantiated -// in importing translation units (e.g. by variable_value::as()) and -// looks up these operators by ADL, and some compilers do not find -// global-module declarations there unless the module exports them (MSVC: -// error C2679). Once the dependencies are modularized and imported instead -// of preloaded, this block can be dropped. -export namespace boost { namespace typeindex { -using ::boost::typeindex::operator==; -using ::boost::typeindex::operator!=; -}} - -// The library's headers, in the module purview: the declarations below are -// attached to this module and the public ones are exported through the -// BOOST_PROGRAM_OPTIONS_BEGIN/END_MODULE_EXPORT blocks. -#include - -// Additional internal headers used by the implementation units: included -// here once (unexported) so that every unit of the module sees the same -// declarations instead of re-including them textually. -#include -#include diff --git a/modules/gmf_preload.hpp b/modules/gmf_preload.hpp deleted file mode 100644 index 37dd98f50..000000000 --- a/modules/gmf_preload.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Shared global module fragment preloads for the boost.program_options -// module units (the interface in boost_program_options.cppm and the -// implementation units in impl/). -// -// Everything that the library's headers and sources include, except the -// library's own headers, is preloaded here so that the includes triggered -// inside the module purviews are no-ops (include guards) and no foreign -// declarations get attached to the module. Boost.ProgramOptions headers -// must NOT be preloaded here: they are included in the purviews, where -// their declarations are attached to (or, in implementation units, -// redeclare those of) the boost.program_options module. - -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_GMF_PRELOAD_HPP -#define BOOST_PROGRAM_OPTIONS_MODULE_GMF_PRELOAD_HPP - -// Macro-only header; macros are not exported by 'import std'. -#include - -// Standard headers used by the library's headers and sources. -#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 - -// Boost dependencies used by the library's headers and sources. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// The shared utf8_codecvt_facet detail header is macro-parameterized; wrap -// it exactly like -// and src/utf8_codecvt_facet.cpp do, so that the class stays attached to -// the global module, as in classic builds. -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL - -#endif diff --git a/modules/impl/cmdline.cc b/modules/impl/cmdline.cc deleted file mode 100644 index 43ec6b38a..000000000 --- a/modules/impl/cmdline.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/cmdline.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/cmdline.cpp" \ No newline at end of file diff --git a/modules/impl/config_file.cc b/modules/impl/config_file.cc deleted file mode 100644 index ab2b9c67d..000000000 --- a/modules/impl/config_file.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/config_file.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/config_file.cpp" \ No newline at end of file diff --git a/modules/impl/convert.cc b/modules/impl/convert.cc deleted file mode 100644 index fa8ad90a0..000000000 --- a/modules/impl/convert.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/convert.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/convert.cpp" \ No newline at end of file diff --git a/modules/impl/options_description.cc b/modules/impl/options_description.cc deleted file mode 100644 index eec78df9d..000000000 --- a/modules/impl/options_description.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/options_description.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/options_description.cpp" \ No newline at end of file diff --git a/modules/impl/parsers.cc b/modules/impl/parsers.cc deleted file mode 100644 index 2248717ee..000000000 --- a/modules/impl/parsers.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/parsers.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/parsers.cpp" \ No newline at end of file diff --git a/modules/impl/positional_options.cc b/modules/impl/positional_options.cc deleted file mode 100644 index 3cbea975d..000000000 --- a/modules/impl/positional_options.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/positional_options.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/positional_options.cpp" \ No newline at end of file diff --git a/modules/impl/split.cc b/modules/impl/split.cc deleted file mode 100644 index 06fc79779..000000000 --- a/modules/impl/split.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/split.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/split.cpp" \ No newline at end of file diff --git a/modules/impl/utf8_codecvt_facet.cc b/modules/impl/utf8_codecvt_facet.cc deleted file mode 100644 index e81c8ffb5..000000000 --- a/modules/impl/utf8_codecvt_facet.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/utf8_codecvt_facet.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/utf8_codecvt_facet.cpp" \ No newline at end of file diff --git a/modules/impl/value_semantic.cc b/modules/impl/value_semantic.cc deleted file mode 100644 index 5ebabe43f..000000000 --- a/modules/impl/value_semantic.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/value_semantic.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/value_semantic.cpp" \ No newline at end of file diff --git a/modules/impl/variables_map.cc b/modules/impl/variables_map.cc deleted file mode 100644 index 6fc8505a1..000000000 --- a/modules/impl/variables_map.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/variables_map.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/variables_map.cpp" \ No newline at end of file diff --git a/modules/impl/winmain.cc b/modules/impl/winmain.cc deleted file mode 100644 index 553d78ab6..000000000 --- a/modules/impl/winmain.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Module implementation unit for src/winmain.cpp. Together with the module -// interface in modules/boost_program_options.cppm, this attaches the -// library's definitions to the boost.program_options module, matching the -// attachment of the exported declarations. See the notes in that file. - -module; - -#include "../gmf_preload.hpp" - -// Macros used by the sources (the library's headers are no-ops below). -#include - -module boost.program_options; - -// The library's headers are no-ops in this unit: their declarations are -// provided by the imported primary interface. -#define BOOST_PROGRAM_OPTIONS_MODULE_IMPL_UNIT - -#include "../../src/winmain.cpp" \ No newline at end of file diff --git a/src/cppm/boost/program_options.cppm b/src/cppm/boost/program_options.cppm new file mode 100644 index 000000000..2d48f0fd9 --- /dev/null +++ b/src/cppm/boost/program_options.cppm @@ -0,0 +1,197 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// C++20 module interface for Boost.ProgramOptions. +// +// Consumers can replace +// #include +// with +// import boost.program_options; +// and keep using the boost::program_options namespace as before. +// +// Implementation notes: +// +// * The classic headers are included in the global module fragment and the +// public declarations are re-exported with exported using-declarations. +// This is a thin wrapper: no header is modified, no declaration is moved, +// renamed or otherwise changed, and every declaration stays attached to +// the global module, so the definitions in the classic compiled library +// link directly. +// +// * The alternative design used by Boost.Any and Boost.PFR (export blocks +// in the library's own headers) is not applicable here yet: it attaches +// the declarations to the module, and a compiled library must then also +// provide its definitions as module implementation units, because some +// compilers (e.g. MSVC) mangle module-attached functions differently +// than the classic library's. It also requires modularized dependencies. +// The thin wrapper needs neither; the migration can be revisited once +// the Boost dependencies are modularized. +// +// * Macros (e.g. BOOST_PROGRAM_OPTIONS_VERSION) are not exported by C++20 +// modules. Code that needs them must keep including the classic headers. +// +// * The module covers everything reachable from . +// The auxiliary iterator headers +// and are generic +// utilities outside of that umbrella header and are not exported here. + +module; + +#include + +// Consume the standard library through 'import std;' as well when the +// toolchain provides it (BOOST_PROGRAM_OPTIONS_USE_STD_MODULE, set by CMake +// like in other modularized Boost libraries). The import must come after +// the textual includes above: on MSVC, a textual standard header parsed +// after 'import std;' clashes with the declarations already provided by +// the std module. +#ifdef BOOST_PROGRAM_OPTIONS_USE_STD_MODULE +import std; +#endif + +export module boost.program_options; + +// Some compilers prune global-module-fragment declarations from the BMI. +// Templates defined by the headers (e.g. boost::any_cast, used by +// variable_value::as()) look up operators such as +// boost::typeindex::operator== by ADL when instantiated in importing +// translation units. Those operators must therefore be exported by the +// module, like the library's own declarations. +export namespace boost { namespace typeindex { +using ::boost::typeindex::operator==; +using ::boost::typeindex::operator!=; +}} + +export namespace boost { + +// Character conversion helpers declared in namespace boost by +// . +#if !defined(BOOST_NO_STD_WSTRING) +using ::boost::from_8_bit; +using ::boost::to_8_bit; +using ::boost::from_utf8; +using ::boost::to_utf8; +using ::boost::from_local_8_bit; +using ::boost::to_local_8_bit; +#endif + +namespace program_options { + +// errors.hpp +using ::boost::program_options::strip_prefixes; +using ::boost::program_options::error; +using ::boost::program_options::too_many_positional_options_error; +using ::boost::program_options::invalid_command_line_style; +using ::boost::program_options::reading_file; +using ::boost::program_options::error_with_option_name; +using ::boost::program_options::multiple_values; +using ::boost::program_options::multiple_occurrences; +using ::boost::program_options::required_option; +using ::boost::program_options::error_with_no_option_name; +using ::boost::program_options::unknown_option; +using ::boost::program_options::ambiguous_option; +using ::boost::program_options::invalid_syntax; +using ::boost::program_options::invalid_config_file_syntax; +using ::boost::program_options::invalid_command_line_syntax; +using ::boost::program_options::validation_error; +using ::boost::program_options::invalid_option_value; +using ::boost::program_options::invalid_bool_value; + +// option.hpp +using ::boost::program_options::basic_option; +using ::boost::program_options::option; +using ::boost::program_options::woption; + +// value_semantic.hpp and detail/value_semantic.hpp +// Note: the explicit specializations (e.g. value_semantic_codecvt_helper) +// are declared by the headers in the global module fragment and are therefore +// reachable by importers of this module; only the primary templates are +// named below, as some compilers reject using-declarations that name +// template specializations. +using ::boost::program_options::value_semantic; +using ::boost::program_options::value_semantic_codecvt_helper; +using ::boost::program_options::untyped_value; +#ifndef BOOST_NO_RTTI +using ::boost::program_options::typed_value_base; +#endif +using ::boost::program_options::typed_value; +using ::boost::program_options::value; +using ::boost::program_options::wvalue; +using ::boost::program_options::bool_switch; +using ::boost::program_options::validate; + +namespace validators { +using ::boost::program_options::validators::get_single_string; +using ::boost::program_options::validators::check_first_occurrence; +} + +// options_description.hpp +using ::boost::program_options::option_description; +using ::boost::program_options::options_description_easy_init; +using ::boost::program_options::options_description; +using ::boost::program_options::duplicate_option_error; + +// positional_options.hpp +using ::boost::program_options::positional_options_description; + +// cmdline.hpp +namespace command_line_style { +using ::boost::program_options::command_line_style::style_t; +using ::boost::program_options::command_line_style::allow_long; +using ::boost::program_options::command_line_style::allow_short; +using ::boost::program_options::command_line_style::allow_dash_for_short; +using ::boost::program_options::command_line_style::allow_slash_for_short; +using ::boost::program_options::command_line_style::long_allow_adjacent; +using ::boost::program_options::command_line_style::long_allow_next; +using ::boost::program_options::command_line_style::short_allow_adjacent; +using ::boost::program_options::command_line_style::short_allow_next; +using ::boost::program_options::command_line_style::allow_sticky; +using ::boost::program_options::command_line_style::allow_guessing; +using ::boost::program_options::command_line_style::long_case_insensitive; +using ::boost::program_options::command_line_style::short_case_insensitive; +using ::boost::program_options::command_line_style::case_insensitive; +using ::boost::program_options::command_line_style::allow_long_disguise; +using ::boost::program_options::command_line_style::unix_style; +using ::boost::program_options::command_line_style::default_style; +} + +// parsers.hpp and detail/parsers.hpp +using ::boost::program_options::basic_parsed_options; +using ::boost::program_options::parsed_options; +using ::boost::program_options::wparsed_options; +using ::boost::program_options::ext_parser; +using ::boost::program_options::basic_command_line_parser; +using ::boost::program_options::command_line_parser; +using ::boost::program_options::wcommand_line_parser; +using ::boost::program_options::parse_command_line; +using ::boost::program_options::parse_config_file; +using ::boost::program_options::collect_unrecognized_mode; +using ::boost::program_options::include_positional; +using ::boost::program_options::exclude_positional; +using ::boost::program_options::collect_unrecognized; +using ::boost::program_options::parse_environment; +using ::boost::program_options::split_unix; +#ifdef _WIN32 +using ::boost::program_options::split_winmain; +#endif + +// detail/convert.hpp +using ::boost::program_options::to_internal; + +// detail/cmdline.hpp, detail/config_file.hpp +namespace detail { +using ::boost::program_options::detail::cmdline; +using ::boost::program_options::detail::arg; +} + +// variables_map.hpp +using ::boost::program_options::store; +using ::boost::program_options::notify; +using ::boost::program_options::variable_value; +using ::boost::program_options::abstract_variables_map; +using ::boost::program_options::variables_map; + +} // namespace program_options +} // namespace boost diff --git a/modules/usage_sample.cpp b/src/cppm/usage_sample.cpp similarity index 100% rename from modules/usage_sample.cpp rename to src/cppm/usage_sample.cpp From 2043e041e8916fc999efd740be5381152d19664d Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Thu, 22 Oct 2026 22:56:59 +0330 Subject: [PATCH 10/17] Make the existing src/*.cpp double as module implementation units Per review feedback, drop the exported using-declaration list from the module interface and avoid creating any extra .cpp files: - The interface (src/cppm/boost/program_options.cppm) now preloads the library's dependencies in the global module fragment and includes the umbrella header in the module purview inside an 'export { ... }' block, so the public declarations are exported without modifying any header and without per-name using-declarations. - Each src/*.cpp gains a leading BOOST_PROGRAM_OPTIONS_MODULE_UNIT conditional that, in the module build, turns the file into a module implementation unit of boost.program_options (global module fragment preloads, 'module boost.program_options;', and the library's own include guards predefined so its headers are no-ops there - their declarations come from the imported interface). In classic builds the files compile unchanged. This provides the module-attached definitions matching the interface, which the classic library cannot (some compilers mangle module-attached functions differently). - The module CMake target compiles the same src/*.cpp with BOOST_PROGRAM_OPTIONS_MODULE_UNIT and scans them so they are built against the interface BMI; it is otherwise like the classic target. The boost::typeindex operator export remains in the interface: the preloaded boost::any_cast is instantiated in importing translation units and finds those operators by ADL only if the module exports them (MSVC error C2679 otherwise). Validated in fresh build directories: all 15 tests pass (classic build unchanged; module test green), and the module test also passes built with 'import std;' (C++23 + std module). --- CMakeLists.txt | 54 ++++++- README.md | 19 +-- doc/modules.xml | 19 ++- src/cmdline.cpp | 78 ++++++++++ src/config_file.cpp | 78 ++++++++++ src/convert.cpp | 78 ++++++++++ src/cppm/boost/program_options.cppm | 233 ++++++++++------------------ src/options_description.cpp | 78 ++++++++++ src/parsers.cpp | 78 ++++++++++ src/positional_options.cpp | 78 ++++++++++ src/split.cpp | 78 ++++++++++ src/utf8_codecvt_facet.cpp | 78 ++++++++++ src/value_semantic.cpp | 78 ++++++++++ src/variables_map.cpp | 78 ++++++++++ src/winmain.cpp | 78 ++++++++++ 15 files changed, 1010 insertions(+), 173 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 501651066..0fc79ac15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,9 +70,26 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) message(FATAL_ERROR "boost_program_options_modules: building C++20 modules requires CMake 3.28 or later and a Ninja generator.") endif() - # The module interface re-exports the declarations of the classic headers, - # whose definitions live in boost_program_options. - add_library(boost_program_options_modules) + # The module interface plus the library sources, compiled as module + # implementation units (BOOST_PROGRAM_OPTIONS_MODULE_UNIT in src/*.cpp): + # declarations in the module purview attach to the module, and their + # definitions must carry the same attachment (some compilers mangle + # module-attached functions differently), so they cannot be taken from + # the classic library. In classic builds the same sources compile + # unchanged. + add_library(boost_program_options_modules + src/cmdline.cpp + src/config_file.cpp + src/convert.cpp + src/options_description.cpp + src/parsers.cpp + src/positional_options.cpp + src/split.cpp + src/utf8_codecvt_facet.cpp + src/value_semantic.cpp + src/variables_map.cpp + src/winmain.cpp + ) add_library(Boost::program_options_modules ALIAS boost_program_options_modules) target_sources(boost_program_options_modules @@ -81,10 +98,37 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) FILES src/cppm/boost/program_options.cppm ) - target_link_libraries(boost_program_options_modules PUBLIC boost_program_options) - target_compile_features(boost_program_options_modules PUBLIC cxx_std_20) + # Scan all sources of the target: the src/*.cpp module implementation + # units are recognized as such and compiled against the interface's BMI. + set_target_properties(boost_program_options_modules PROPERTIES CXX_SCAN_FOR_MODULES ON) + + target_include_directories(boost_program_options_modules PRIVATE include) + + target_compile_definitions(boost_program_options_modules + PUBLIC BOOST_PROGRAM_OPTIONS_NO_LIB + PRIVATE BOOST_PROGRAM_OPTIONS_SOURCE BOOST_PROGRAM_OPTIONS_MODULE_UNIT + ) + + # Same dependencies as the classic library. + target_link_libraries(boost_program_options_modules + PUBLIC + Boost::any + Boost::config + Boost::core + Boost::detail + Boost::function + Boost::iterator + Boost::lexical_cast + Boost::smart_ptr + Boost::throw_exception + Boost::type_traits + PRIVATE + Boost::bind + Boost::tokenizer + ) + # Consume the standard library through 'import std;' in the module # interface when the toolchain provides the std module (CMake 3.30+, # -DCMAKE_CXX_MODULE_STD=ON and a C++ standard listed in diff --git a/README.md b/README.md index 65537dbe6..76a7243de 100644 --- a/README.md +++ b/README.md @@ -26,15 +26,16 @@ import boost.program_options; and keep using the `boost::program_options` namespace unchanged. -The interface (`src/cppm/boost/program_options.cppm`) is a thin wrapper: it -includes the classic umbrella header in the global module fragment and -re-exports the public declarations with exported using-declarations. No -library header is modified, every declaration stays attached to the global -module, and the definitions in the classic compiled library are reused -directly. (The export-block style used by header-only libraries such as -Boost.Any and Boost.PFR is not applicable here yet: for a compiled library -it requires module implementation units and modularized dependencies; the -migration can be revisited once the Boost dependencies are modularized.) +The interface (`src/cppm/boost/program_options.cppm`) preloads the library's +dependencies in the global module fragment and includes the umbrella header +in the module purview inside an `export { ... }` block, so the public +declarations are exported without modifying any header. The library's +sources in `src/*.cpp` carry a `BOOST_PROGRAM_OPTIONS_MODULE_UNIT` +conditional that compiles them, in the module build, as module +implementation units providing matching module-attached definitions; in +classic builds the same files compile unchanged. (The header export-block +style of Boost.Any/Boost.PFR is not needed for this: no header carries +module machinery at all.) The module is not built by default. Enable it by configuring CMake with `-DBOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON`, which creates the additional diff --git a/doc/modules.xml b/doc/modules.xml index 7423f47e8..521f9c04d 100644 --- a/doc/modules.xml +++ b/doc/modules.xml @@ -48,16 +48,15 @@ int main(int argc, char* argv[]) #include with an import. A minimal, compilable example is provided in src/cppm/usage_sample.cpp. - The interface (src/cppm/boost/program_options.cppm) is - a thin wrapper: it includes the classic umbrella header in the global - module fragment and re-exports the public declarations with exported - using-declarations. No library header is modified, every declaration - stays attached to the global module, and the definitions in the classic - compiled library are reused directly. The export-block style used by - header-only libraries such as Boost.Any and Boost.PFR is not applicable - here yet: for a compiled library it requires module implementation units - and modularized dependencies; the migration can be revisited once the - Boost dependencies are modularized. + The interface (src/cppm/boost/program_options.cppm) + preloads the library's dependencies in the global module fragment and + includes the umbrella header in the module purview inside an + export { ... } block, so the public declarations are + exported without modifying any header. The library's sources in + src/*.cpp carry a BOOST_PROGRAM_OPTIONS_MODULE_UNIT + conditional that compiles them, in the module build, as module + implementation units providing matching module-attached definitions; in + classic builds the same files compile unchanged.
Building and Using diff --git a/src/cmdline.cpp b/src/cmdline.cpp index 8f4ae64e4..6377d5181 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/config_file.cpp b/src/config_file.cpp index 7cd18acdf..3d257acdb 100644 --- a/src/config_file.cpp +++ b/src/config_file.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/convert.cpp b/src/convert.cpp index fbe2758b1..87ad4b943 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Vladimir Prus 2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/cppm/boost/program_options.cppm b/src/cppm/boost/program_options.cppm index 2d48f0fd9..03d8d0bce 100644 --- a/src/cppm/boost/program_options.cppm +++ b/src/cppm/boost/program_options.cppm @@ -13,21 +13,19 @@ // // Implementation notes: // -// * The classic headers are included in the global module fragment and the -// public declarations are re-exported with exported using-declarations. -// This is a thin wrapper: no header is modified, no declaration is moved, -// renamed or otherwise changed, and every declaration stays attached to -// the global module, so the definitions in the classic compiled library -// link directly. +// * The dependencies of the library's headers are preloaded textually in +// the global module fragment below, and the library's own umbrella +// header is then included in the module purview inside an export block, +// which exports its declarations without modifying any header. // -// * The alternative design used by Boost.Any and Boost.PFR (export blocks -// in the library's own headers) is not applicable here yet: it attaches -// the declarations to the module, and a compiled library must then also -// provide its definitions as module implementation units, because some -// compilers (e.g. MSVC) mangle module-attached functions differently -// than the classic library's. It also requires modularized dependencies. -// The thin wrapper needs neither; the migration can be revisited once -// the Boost dependencies are modularized. +// * Unlike Boost.Any or Boost.PFR, this library is compiled: entities +// declared in a module purview are attached to the module, and some +// compilers (e.g. MSVC) mangle their out-of-line definitions with a +// module qualifier, so they cannot be provided by the classic, +// non-modular library. The module build therefore compiles the library +// sources in src/*.cpp as module implementation units (see the +// BOOST_PROGRAM_OPTIONS_MODULE_UNIT conditionals in those files); the +// classic build of the same files is unchanged. // // * Macros (e.g. BOOST_PROGRAM_OPTIONS_VERSION) are not exported by C++20 // modules. Code that needs them must keep including the classic headers. @@ -39,7 +37,63 @@ module; -#include +// Standard headers used by the library's headers and sources. +#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 + +// Boost dependencies used by the library's headers and sources. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// The shared utf8_codecvt_facet detail header is macro-parameterized; wrap +// it exactly like +// and src/utf8_codecvt_facet.cpp do, so that the class stays attached to +// the global module, as in classic builds. +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL // Consume the standard library through 'import std;' as well when the // toolchain provides it (BOOST_PROGRAM_OPTIONS_USE_STD_MODULE, set by CMake @@ -54,144 +108,25 @@ import std; export module boost.program_options; // Some compilers prune global-module-fragment declarations from the BMI. -// Templates defined by the headers (e.g. boost::any_cast, used by -// variable_value::as()) look up operators such as -// boost::typeindex::operator== by ADL when instantiated in importing -// translation units. Those operators must therefore be exported by the -// module, like the library's own declarations. +// The preloaded boost::any_cast template is instantiated in importing +// translation units (e.g. by variable_value::as()) and looks up +// boost::typeindex::operator== by ADL; such global-module declarations +// must be exported by the module to be usable there (MSVC: error C2679). export namespace boost { namespace typeindex { using ::boost::typeindex::operator==; using ::boost::typeindex::operator!=; }} -export namespace boost { - -// Character conversion helpers declared in namespace boost by -// . -#if !defined(BOOST_NO_STD_WSTRING) -using ::boost::from_8_bit; -using ::boost::to_8_bit; -using ::boost::from_utf8; -using ::boost::to_utf8; -using ::boost::from_local_8_bit; -using ::boost::to_local_8_bit; -#endif - -namespace program_options { - -// errors.hpp -using ::boost::program_options::strip_prefixes; -using ::boost::program_options::error; -using ::boost::program_options::too_many_positional_options_error; -using ::boost::program_options::invalid_command_line_style; -using ::boost::program_options::reading_file; -using ::boost::program_options::error_with_option_name; -using ::boost::program_options::multiple_values; -using ::boost::program_options::multiple_occurrences; -using ::boost::program_options::required_option; -using ::boost::program_options::error_with_no_option_name; -using ::boost::program_options::unknown_option; -using ::boost::program_options::ambiguous_option; -using ::boost::program_options::invalid_syntax; -using ::boost::program_options::invalid_config_file_syntax; -using ::boost::program_options::invalid_command_line_syntax; -using ::boost::program_options::validation_error; -using ::boost::program_options::invalid_option_value; -using ::boost::program_options::invalid_bool_value; - -// option.hpp -using ::boost::program_options::basic_option; -using ::boost::program_options::option; -using ::boost::program_options::woption; - -// value_semantic.hpp and detail/value_semantic.hpp -// Note: the explicit specializations (e.g. value_semantic_codecvt_helper) -// are declared by the headers in the global module fragment and are therefore -// reachable by importers of this module; only the primary templates are -// named below, as some compilers reject using-declarations that name -// template specializations. -using ::boost::program_options::value_semantic; -using ::boost::program_options::value_semantic_codecvt_helper; -using ::boost::program_options::untyped_value; -#ifndef BOOST_NO_RTTI -using ::boost::program_options::typed_value_base; -#endif -using ::boost::program_options::typed_value; -using ::boost::program_options::value; -using ::boost::program_options::wvalue; -using ::boost::program_options::bool_switch; -using ::boost::program_options::validate; - -namespace validators { -using ::boost::program_options::validators::get_single_string; -using ::boost::program_options::validators::check_first_occurrence; -} - -// options_description.hpp -using ::boost::program_options::option_description; -using ::boost::program_options::options_description_easy_init; -using ::boost::program_options::options_description; -using ::boost::program_options::duplicate_option_error; - -// positional_options.hpp -using ::boost::program_options::positional_options_description; - -// cmdline.hpp -namespace command_line_style { -using ::boost::program_options::command_line_style::style_t; -using ::boost::program_options::command_line_style::allow_long; -using ::boost::program_options::command_line_style::allow_short; -using ::boost::program_options::command_line_style::allow_dash_for_short; -using ::boost::program_options::command_line_style::allow_slash_for_short; -using ::boost::program_options::command_line_style::long_allow_adjacent; -using ::boost::program_options::command_line_style::long_allow_next; -using ::boost::program_options::command_line_style::short_allow_adjacent; -using ::boost::program_options::command_line_style::short_allow_next; -using ::boost::program_options::command_line_style::allow_sticky; -using ::boost::program_options::command_line_style::allow_guessing; -using ::boost::program_options::command_line_style::long_case_insensitive; -using ::boost::program_options::command_line_style::short_case_insensitive; -using ::boost::program_options::command_line_style::case_insensitive; -using ::boost::program_options::command_line_style::allow_long_disguise; -using ::boost::program_options::command_line_style::unix_style; -using ::boost::program_options::command_line_style::default_style; -} - -// parsers.hpp and detail/parsers.hpp -using ::boost::program_options::basic_parsed_options; -using ::boost::program_options::parsed_options; -using ::boost::program_options::wparsed_options; -using ::boost::program_options::ext_parser; -using ::boost::program_options::basic_command_line_parser; -using ::boost::program_options::command_line_parser; -using ::boost::program_options::wcommand_line_parser; -using ::boost::program_options::parse_command_line; -using ::boost::program_options::parse_config_file; -using ::boost::program_options::collect_unrecognized_mode; -using ::boost::program_options::include_positional; -using ::boost::program_options::exclude_positional; -using ::boost::program_options::collect_unrecognized; -using ::boost::program_options::parse_environment; -using ::boost::program_options::split_unix; -#ifdef _WIN32 -using ::boost::program_options::split_winmain; -#endif - -// detail/convert.hpp -using ::boost::program_options::to_internal; - -// detail/cmdline.hpp, detail/config_file.hpp -namespace detail { -using ::boost::program_options::detail::cmdline; -using ::boost::program_options::detail::arg; +// The library's umbrella header, in the module purview: its declarations +// are attached to this module and exported by the enclosing block. The +// includes of the preloaded dependencies above are no-ops here (include +// guards), so nothing foreign is attached. +export { +#include } -// variables_map.hpp -using ::boost::program_options::store; -using ::boost::program_options::notify; -using ::boost::program_options::variable_value; -using ::boost::program_options::abstract_variables_map; -using ::boost::program_options::variables_map; - -} // namespace program_options -} // namespace boost +// Internal headers used by the implementation units: included here once +// (unexported) so that every unit of the module sees the same declarations +// instead of re-including them textually. +#include +#include diff --git a/src/options_description.cpp b/src/options_description.cpp index 0efdc3388..b245126a7 100644 --- a/src/options_description.cpp +++ b/src/options_description.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Vladimir Prus 2002-2004. // Copyright Bertolt Mildner 2004. // Distributed under the Boost Software License, Version 1.0. diff --git a/src/parsers.cpp b/src/parsers.cpp index 4dac608d3..fc56587dc 100644 --- a/src/parsers.cpp +++ b/src/parsers.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/positional_options.cpp b/src/positional_options.cpp index cb6a14524..8bda97a05 100644 --- a/src/positional_options.cpp +++ b/src/positional_options.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Vladimir Prus 2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/split.cpp b/src/split.cpp index c674403ff..a889d36bf 100644 --- a/src/split.cpp +++ b/src/split.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Sascha Ochsenknecht 2009. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/utf8_codecvt_facet.cpp b/src/utf8_codecvt_facet.cpp index 075e4aebb..f8f3f48b7 100644 --- a/src/utf8_codecvt_facet.cpp +++ b/src/utf8_codecvt_facet.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Vladimir Prus 2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/value_semantic.cpp b/src/value_semantic.cpp index c4feb688e..03b99d675 100644 --- a/src/value_semantic.cpp +++ b/src/value_semantic.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Vladimir Prus 2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/variables_map.cpp b/src/variables_map.cpp index 94ac6148c..055ad8cb4 100644 --- a/src/variables_map.cpp +++ b/src/variables_map.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/winmain.cpp b/src/winmain.cpp index 31c8adcb7..5c71a602b 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -1,3 +1,81 @@ +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// In the boost.program_options module build, this translation unit is a +// module implementation unit: it provides the module-attached definitions +// matching the interface in src/cppm/boost/program_options.cppm. In the +// classic build (below) this file is compiled unchanged. +module; + +// Dependencies included by this file, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace program_options { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL +#include +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#include + +module boost.program_options; + +// The library's own headers included below are no-ops: their declarations +// are provided by the imported primary interface. +#define BOOST_ERRORS_VP_2003_01_02 +#define BOOST_CMDLINE_HPP_VP_2004_03_13 +#define BOOST_OPTION_HPP_VP_2004_02_25 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VARIABLES_MAP_VP_2003_05_19 +#define BOOST_CMDLINE_VP_2003_05_19 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 +#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#endif // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt From 7eef6c845b6824683f41c22bcacc563d1fb921db Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Thu, 22 Oct 2026 23:28:08 +0330 Subject: [PATCH 11/17] Minimize the module-unit preludes in src/*.cpp to what each file uses Each BOOST_PROGRAM_OPTIONS_MODULE_UNIT prelude now preloads only the headers that file itself includes and uses (its own includes plus what its body uses that classically arrived transitively through the library headers, e.g. in value_semantic.cpp, and iterator_facade in parsers.cpp, std::size_t in winmain.cpp), and predefines only the include guards of the library headers it includes, instead of a uniform superset. The interface preload was likewise reduced to what the umbrella header and the internal headers use. About import std: the textual standard includes in the global module fragment are load-bearing in both modes. import std does not define include guards, so the (unmodifiable) library headers textually including etc. in the module purview would either attach the standard library to this module or, on MSVC, parse after the std module declarations and fail with C2011 redefinitions (verified with a controlled experiment; the order textual-then-import is the one that works). Libraries whose headers are converted to compatibility headers (Boost.Any) can drop the textual includes; that requires header changes, which this PR deliberately avoids. --- src/cmdline.cpp | 64 ++++-------------------- src/config_file.cpp | 70 ++++---------------------- src/convert.cpp | 65 +++++------------------- src/cppm/boost/program_options.cppm | 37 +++----------- src/options_description.cpp | 64 +++--------------------- src/parsers.cpp | 77 +++++++---------------------- src/positional_options.cpp | 72 +++------------------------ src/split.cpp | 71 +++----------------------- src/utf8_codecvt_facet.cpp | 67 ++++--------------------- src/value_semantic.cpp | 70 +++----------------------- src/variables_map.cpp | 70 +++----------------------- src/winmain.cpp | 71 +++----------------------- 12 files changed, 115 insertions(+), 683 deletions(-) diff --git a/src/cmdline.cpp b/src/cmdline.cpp index 6377d5181..eae1b4d3f 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -1,81 +1,37 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #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 -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL +#include +#include #include module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. +#define BOOST_CMDLINE_VP_2003_05_19 #define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 #define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 #define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 -#define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 #endif + // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/config_file.cpp b/src/config_file.cpp index 3d257acdb..aa69a8b76 100644 --- a/src/config_file.cpp +++ b/src/config_file.cpp @@ -1,81 +1,29 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #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 -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL +#include #include module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 -#define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONVERT_HPP_VP_2004_04_28 #define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#define BOOST_CONVERT_HPP_VP_2004_04_28 +#define BOOST_ERRORS_VP_2003_01_02 #endif + // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/convert.cpp b/src/convert.cpp index 87ad4b943..a6717ed0e 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -1,53 +1,25 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include -#include -#include -#include -#include -#include -#include -#include +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #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 -#include -#include -#include +#include +#include +#include + #define BOOST_UTF8_BEGIN_NAMESPACE \ namespace boost { namespace program_options { namespace detail { #define BOOST_UTF8_END_NAMESPACE }}} @@ -56,26 +28,13 @@ module; #undef BOOST_UTF8_BEGIN_NAMESPACE #undef BOOST_UTF8_END_NAMESPACE #undef BOOST_UTF8_DECL -#include module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 -#define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 -#define BOOST_CMDLINE_VP_2003_05_19 #define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#define BOOST_PROGRAM_OPTIONS_UTF8_CODECVT_FACET_HPP #endif + // Copyright Vladimir Prus 2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/cppm/boost/program_options.cppm b/src/cppm/boost/program_options.cppm index 03d8d0bce..1834448ef 100644 --- a/src/cppm/boost/program_options.cppm +++ b/src/cppm/boost/program_options.cppm @@ -37,34 +37,23 @@ module; -// Standard headers used by the library's headers and sources. +// Standard headers used by the library's headers. #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 -// Boost dependencies used by the library's headers and sources. +// Boost dependencies used by the library's headers. #include #include #include @@ -75,32 +64,22 @@ module; #include #include #include -#include -#include #include #include #include #include -// The shared utf8_codecvt_facet detail header is macro-parameterized; wrap -// it exactly like -// and src/utf8_codecvt_facet.cpp do, so that the class stays attached to -// the global module, as in classic builds. -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL - // Consume the standard library through 'import std;' as well when the // toolchain provides it (BOOST_PROGRAM_OPTIONS_USE_STD_MODULE, set by CMake // like in other modularized Boost libraries). The import must come after // the textual includes above: on MSVC, a textual standard header parsed // after 'import std;' clashes with the declarations already provided by -// the std module. +// the std module. The textual includes stay in both modes because the +// library's (unconverted) headers include standard headers textually; they +// set the include guards that make those purview includes no-ops, keeping +// the standard library attached to the global module. Libraries whose +// headers are converted to compatibility headers (e.g. Boost.Any) can +// replace them with 'import std;' alone. #ifdef BOOST_PROGRAM_OPTIONS_USE_STD_MODULE import std; #endif diff --git a/src/options_description.cpp b/src/options_description.cpp index b245126a7..3e5877e09 100644 --- a/src/options_description.cpp +++ b/src/options_description.cpp @@ -1,81 +1,33 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #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 -#include +#include #include #include -#include -#include -#include #include -#include -#include -#include -#include -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL +#include #include module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 #define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 #define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 #endif + // Copyright Vladimir Prus 2002-2004. // Copyright Bertolt Mildner 2004. // Distributed under the Boost Software License, Version 1.0. diff --git a/src/parsers.cpp b/src/parsers.cpp index fc56587dc..4b35ec813 100644 --- a/src/parsers.cpp +++ b/src/parsers.cpp @@ -1,81 +1,42 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #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 -#include -#include -#include -#include -#include +#include #include -#include +#include #include -#include -#include -#include -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL +#include +#include #include +#ifndef _WIN32 +#include +#endif + module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 -#define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 #define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONVERT_HPP_VP_2004_04_28 #define BOOST_CONFIG_FILE_VP_2003_01_02 +#define BOOST_CONVERT_HPP_VP_2004_04_28 #define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 +#define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 #endif + // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/positional_options.cpp b/src/positional_options.cpp index 8bda97a05..2ee519063 100644 --- a/src/positional_options.cpp +++ b/src/positional_options.cpp @@ -1,81 +1,25 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #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 -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL #include module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 #define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 -#define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 #endif + // Copyright Vladimir Prus 2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/split.cpp b/src/split.cpp index a889d36bf..2040732d5 100644 --- a/src/split.cpp +++ b/src/split.cpp @@ -1,81 +1,26 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL +#include +#include #include module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 #define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 #endif + // Copyright Sascha Ochsenknecht 2009. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/utf8_codecvt_facet.cpp b/src/utf8_codecvt_facet.cpp index f8f3f48b7..ecb97ce1e 100644 --- a/src/utf8_codecvt_facet.cpp +++ b/src/utf8_codecvt_facet.cpp @@ -1,53 +1,21 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #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 -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include + #define BOOST_UTF8_BEGIN_NAMESPACE \ namespace boost { namespace program_options { namespace detail { #define BOOST_UTF8_END_NAMESPACE }}} @@ -56,26 +24,11 @@ module; #undef BOOST_UTF8_BEGIN_NAMESPACE #undef BOOST_UTF8_END_NAMESPACE #undef BOOST_UTF8_DECL -#include module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 -#define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 #endif + // Copyright Vladimir Prus 2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/value_semantic.cpp b/src/value_semantic.cpp index 03b99d675..324564b24 100644 --- a/src/value_semantic.cpp +++ b/src/value_semantic.cpp @@ -1,81 +1,27 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #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 -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL #include module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 -#define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 #define BOOST_CMDLINE_VP_2003_05_19 #define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 #endif + // Copyright Vladimir Prus 2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/variables_map.cpp b/src/variables_map.cpp index 055ad8cb4..ebb923b9e 100644 --- a/src/variables_map.cpp +++ b/src/variables_map.cpp @@ -1,81 +1,27 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #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 -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL #include module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 #define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 #define BOOST_PARSERS_VP_2003_05_19 +#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 #define BOOST_VARIABLES_MAP_VP_2003_05_19 -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 #endif + // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt diff --git a/src/winmain.cpp b/src/winmain.cpp index 5c71a602b..a1ae64907 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -1,81 +1,24 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a -// module implementation unit: it provides the module-attached definitions +// module implementation unit providing the module-attached definitions // matching the interface in src/cppm/boost/program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; -// Dependencies included by this file, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include +// The headers this file includes, preloaded in the global module fragment +// so that nothing foreign is attached to the module. The library's own +// headers included below are no-ops (guards predefined after the module +// declaration): their declarations come from the imported interface. #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 -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL #include module boost.program_options; -// The library's own headers included below are no-ops: their declarations -// are provided by the imported primary interface. -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_CMDLINE_HPP_VP_2004_03_13 -#define BOOST_OPTION_HPP_VP_2004_02_25 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 #define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_EOF_ITERATOR_VP_2004_03_12 #endif + // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt From 89962fae722c338334e413f9a240c2e393d3185a Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Fri, 23 Oct 2026 10:58:47 +0330 Subject: [PATCH 12/17] Follow the boostorg/config#535 compatibility-header pattern for std includes Every standard-header include of the module units (the interface and the BOOST_PROGRAM_OPTIONS_MODULE_UNIT preludes in src/*.cpp) now goes through a local compatibility shim in src/cppm/std/, following the pattern of the boost/config/std headers from boostorg/config PR #535 (Adds support for C++20 modules, not merged yet): #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif #else #include #endif Today the shims compile to the plain includes (no behavior change); once PR #535 is merged and the future modules mode (BOOST_USE_MODULES) is used, they provide import std instead of textual includes inside module units. Each shim carries a TODO comment to replace it with the boost/config/std counterpart at that point; the README and the documentation mention the PR as well. Validated in fresh build directories: 15/15 tests, and the module test with import std. --- README.md | 9 ++++++++ doc/modules.xml | 9 ++++++++ src/cmdline.cpp | 20 ++++++++--------- src/config_file.cpp | 10 ++++----- src/convert.cpp | 14 ++++++------ src/cppm/boost/program_options.cppm | 34 ++++++++++++++++------------- src/cppm/std/algorithm.hpp | 21 ++++++++++++++++++ src/cppm/std/cassert.hpp | 21 ++++++++++++++++++ src/cppm/std/cctype.hpp | 21 ++++++++++++++++++ src/cppm/std/climits.hpp | 21 ++++++++++++++++++ src/cppm/std/clocale.hpp | 21 ++++++++++++++++++ src/cppm/std/cstdarg.hpp | 21 ++++++++++++++++++ src/cppm/std/cstddef.hpp | 21 ++++++++++++++++++ src/cppm/std/cstdio.hpp | 21 ++++++++++++++++++ src/cppm/std/cstdlib.hpp | 21 ++++++++++++++++++ src/cppm/std/cstring.hpp | 21 ++++++++++++++++++ src/cppm/std/cwchar.hpp | 21 ++++++++++++++++++ src/cppm/std/fstream.hpp | 21 ++++++++++++++++++ src/cppm/std/iosfwd.hpp | 21 ++++++++++++++++++ src/cppm/std/iostream.hpp | 21 ++++++++++++++++++ src/cppm/std/istream.hpp | 21 ++++++++++++++++++ src/cppm/std/iterator.hpp | 21 ++++++++++++++++++ src/cppm/std/limits.hpp | 21 ++++++++++++++++++ src/cppm/std/locale.hpp | 21 ++++++++++++++++++ src/cppm/std/map.hpp | 21 ++++++++++++++++++ src/cppm/std/optional.hpp | 21 ++++++++++++++++++ src/cppm/std/set.hpp | 21 ++++++++++++++++++ src/cppm/std/sstream.hpp | 21 ++++++++++++++++++ src/cppm/std/stdexcept.hpp | 21 ++++++++++++++++++ src/cppm/std/string.hpp | 21 ++++++++++++++++++ src/cppm/std/typeinfo.hpp | 21 ++++++++++++++++++ src/cppm/std/utility.hpp | 21 ++++++++++++++++++ src/cppm/std/vector.hpp | 21 ++++++++++++++++++ src/options_description.cpp | 14 ++++++------ src/parsers.cpp | 16 +++++++------- src/positional_options.cpp | 4 ++-- src/split.cpp | 6 ++--- src/utf8_codecvt_facet.cpp | 6 ++--- src/value_semantic.cpp | 6 ++--- src/variables_map.cpp | 4 ++-- src/winmain.cpp | 4 ++-- 41 files changed, 656 insertions(+), 67 deletions(-) create mode 100644 src/cppm/std/algorithm.hpp create mode 100644 src/cppm/std/cassert.hpp create mode 100644 src/cppm/std/cctype.hpp create mode 100644 src/cppm/std/climits.hpp create mode 100644 src/cppm/std/clocale.hpp create mode 100644 src/cppm/std/cstdarg.hpp create mode 100644 src/cppm/std/cstddef.hpp create mode 100644 src/cppm/std/cstdio.hpp create mode 100644 src/cppm/std/cstdlib.hpp create mode 100644 src/cppm/std/cstring.hpp create mode 100644 src/cppm/std/cwchar.hpp create mode 100644 src/cppm/std/fstream.hpp create mode 100644 src/cppm/std/iosfwd.hpp create mode 100644 src/cppm/std/iostream.hpp create mode 100644 src/cppm/std/istream.hpp create mode 100644 src/cppm/std/iterator.hpp create mode 100644 src/cppm/std/limits.hpp create mode 100644 src/cppm/std/locale.hpp create mode 100644 src/cppm/std/map.hpp create mode 100644 src/cppm/std/optional.hpp create mode 100644 src/cppm/std/set.hpp create mode 100644 src/cppm/std/sstream.hpp create mode 100644 src/cppm/std/stdexcept.hpp create mode 100644 src/cppm/std/string.hpp create mode 100644 src/cppm/std/typeinfo.hpp create mode 100644 src/cppm/std/utility.hpp create mode 100644 src/cppm/std/vector.hpp diff --git a/README.md b/README.md index 76a7243de..70c8799a0 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,15 @@ classic builds the same files compile unchanged. (The header export-block style of Boost.Any/Boost.PFR is not needed for this: no header carries module machinery at all.) +The standard-header includes in the module units go through local +compatibility shims in `src/cppm/std/`, following the pattern of +`` from [boostorg/config PR +#535](https://github.com/boostorg/config/pull/535) ("Adds support for +C++20 modules", not merged yet): plain `#include <...>` today, `import +std;` in the future modules mode. Once that PR is merged, the shims are +to be replaced with `` (TODO comments in the +shims). + The module is not built by default. Enable it by configuring CMake with `-DBOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON`, which creates the additional `Boost::program_options_modules` target (it links the classic compiled diff --git a/doc/modules.xml b/doc/modules.xml index 521f9c04d..cb18d2bb9 100644 --- a/doc/modules.xml +++ b/doc/modules.xml @@ -85,6 +85,15 @@ ctest --output-on-failure BOOST_PROGRAM_OPTIONS_VERSION are not exported; code that needs those macros must include the classic headers. + The standard-header includes of the module units go through + local compatibility shims in src/cppm/std/, following + the pattern of <boost/config/std/...> from + boostorg/config PR #535 (Adds support for C++20 + modules): a plain #include today, and + import std; in the future modules mode. Once that PR + is merged, the shims should be replaced with the Boost.Config + headers (see the TODO comments in the shims). +
diff --git a/src/cmdline.cpp b/src/cmdline.cpp index eae1b4d3f..0dfa7545c 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -9,18 +9,18 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "cppm/std/cassert.hpp" +#include "cppm/std/cctype.hpp" +#include "cppm/std/climits.hpp" +#include "cppm/std/cstdio.hpp" +#include "cppm/std/cstring.hpp" +#include "cppm/std/iostream.hpp" +#include "cppm/std/string.hpp" +#include "cppm/std/utility.hpp" +#include "cppm/std/vector.hpp" #include #include -#include +#include "cppm/std/cstddef.hpp" #include module boost.program_options; diff --git a/src/config_file.cpp b/src/config_file.cpp index aa69a8b76..fd5c70b69 100644 --- a/src/config_file.cpp +++ b/src/config_file.cpp @@ -9,12 +9,12 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include -#include -#include -#include +#include "cppm/std/cassert.hpp" +#include "cppm/std/fstream.hpp" +#include "cppm/std/iostream.hpp" +#include "cppm/std/sstream.hpp" #include -#include +#include "cppm/std/cstddef.hpp" #include module boost.program_options; diff --git a/src/convert.cpp b/src/convert.cpp index a6717ed0e..664052938 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -9,14 +9,14 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include -#include -#include -#include -#include -#include +#include "cppm/std/fstream.hpp" +#include "cppm/std/iostream.hpp" +#include "cppm/std/locale.hpp" +#include "cppm/std/clocale.hpp" +#include "cppm/std/stdexcept.hpp" +#include "cppm/std/string.hpp" #include -#include +#include "cppm/std/cstddef.hpp" #include #include diff --git a/src/cppm/boost/program_options.cppm b/src/cppm/boost/program_options.cppm index 1834448ef..f5f22c341 100644 --- a/src/cppm/boost/program_options.cppm +++ b/src/cppm/boost/program_options.cppm @@ -37,21 +37,25 @@ module; -// Standard headers used by the library's headers. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +// Standard headers used by the library's headers, through the local +// compatibility shims in std/ (counterparts of from +// boostorg/config PR #535 "Adds support for C++20 modules"). +// TODO: when that PR is merged, replace the shims with +// includes. +#include "../std/cassert.hpp" +#include "../std/cwchar.hpp" +#include "../std/iosfwd.hpp" +#include "../std/iterator.hpp" +#include "../std/limits.hpp" +#include "../std/locale.hpp" +#include "../std/map.hpp" +#include "../std/optional.hpp" +#include "../std/set.hpp" +#include "../std/stdexcept.hpp" +#include "../std/string.hpp" +#include "../std/typeinfo.hpp" +#include "../std/utility.hpp" +#include "../std/vector.hpp" // Boost dependencies used by the library's headers. #include diff --git a/src/cppm/std/algorithm.hpp b/src/cppm/std/algorithm.hpp new file mode 100644 index 000000000..e22b1bf13 --- /dev/null +++ b/src/cppm/std/algorithm.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/cassert.hpp b/src/cppm/std/cassert.hpp new file mode 100644 index 000000000..6f9480d79 --- /dev/null +++ b/src/cppm/std/cassert.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/cctype.hpp b/src/cppm/std/cctype.hpp new file mode 100644 index 000000000..509187c26 --- /dev/null +++ b/src/cppm/std/cctype.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/climits.hpp b/src/cppm/std/climits.hpp new file mode 100644 index 000000000..2697463a3 --- /dev/null +++ b/src/cppm/std/climits.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/clocale.hpp b/src/cppm/std/clocale.hpp new file mode 100644 index 000000000..f479cafbb --- /dev/null +++ b/src/cppm/std/clocale.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/cstdarg.hpp b/src/cppm/std/cstdarg.hpp new file mode 100644 index 000000000..fce66dc5b --- /dev/null +++ b/src/cppm/std/cstdarg.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/cstddef.hpp b/src/cppm/std/cstddef.hpp new file mode 100644 index 000000000..797d26c46 --- /dev/null +++ b/src/cppm/std/cstddef.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/cstdio.hpp b/src/cppm/std/cstdio.hpp new file mode 100644 index 000000000..d8b999af8 --- /dev/null +++ b/src/cppm/std/cstdio.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/cstdlib.hpp b/src/cppm/std/cstdlib.hpp new file mode 100644 index 000000000..2b7fe8a6b --- /dev/null +++ b/src/cppm/std/cstdlib.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/cstring.hpp b/src/cppm/std/cstring.hpp new file mode 100644 index 000000000..5cc9676d5 --- /dev/null +++ b/src/cppm/std/cstring.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/cwchar.hpp b/src/cppm/std/cwchar.hpp new file mode 100644 index 000000000..f606027f3 --- /dev/null +++ b/src/cppm/std/cwchar.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/fstream.hpp b/src/cppm/std/fstream.hpp new file mode 100644 index 000000000..779146e38 --- /dev/null +++ b/src/cppm/std/fstream.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/iosfwd.hpp b/src/cppm/std/iosfwd.hpp new file mode 100644 index 000000000..09f7370be --- /dev/null +++ b/src/cppm/std/iosfwd.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/iostream.hpp b/src/cppm/std/iostream.hpp new file mode 100644 index 000000000..6375d30da --- /dev/null +++ b/src/cppm/std/iostream.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/istream.hpp b/src/cppm/std/istream.hpp new file mode 100644 index 000000000..b99dbabb9 --- /dev/null +++ b/src/cppm/std/istream.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/iterator.hpp b/src/cppm/std/iterator.hpp new file mode 100644 index 000000000..b3a592f5b --- /dev/null +++ b/src/cppm/std/iterator.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/limits.hpp b/src/cppm/std/limits.hpp new file mode 100644 index 000000000..a8fab9200 --- /dev/null +++ b/src/cppm/std/limits.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/locale.hpp b/src/cppm/std/locale.hpp new file mode 100644 index 000000000..adec862a3 --- /dev/null +++ b/src/cppm/std/locale.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/map.hpp b/src/cppm/std/map.hpp new file mode 100644 index 000000000..33ac0ea71 --- /dev/null +++ b/src/cppm/std/map.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/optional.hpp b/src/cppm/std/optional.hpp new file mode 100644 index 000000000..6f4ea0a38 --- /dev/null +++ b/src/cppm/std/optional.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/set.hpp b/src/cppm/std/set.hpp new file mode 100644 index 000000000..c6bb3f9f9 --- /dev/null +++ b/src/cppm/std/set.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/sstream.hpp b/src/cppm/std/sstream.hpp new file mode 100644 index 000000000..333709547 --- /dev/null +++ b/src/cppm/std/sstream.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/stdexcept.hpp b/src/cppm/std/stdexcept.hpp new file mode 100644 index 000000000..d60afb7e4 --- /dev/null +++ b/src/cppm/std/stdexcept.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/string.hpp b/src/cppm/std/string.hpp new file mode 100644 index 000000000..41e161849 --- /dev/null +++ b/src/cppm/std/string.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/typeinfo.hpp b/src/cppm/std/typeinfo.hpp new file mode 100644 index 000000000..c5e69a251 --- /dev/null +++ b/src/cppm/std/typeinfo.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/utility.hpp b/src/cppm/std/utility.hpp new file mode 100644 index 000000000..4eb4de2a2 --- /dev/null +++ b/src/cppm/std/utility.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/cppm/std/vector.hpp b/src/cppm/std/vector.hpp new file mode 100644 index 000000000..c49f2354d --- /dev/null +++ b/src/cppm/std/vector.hpp @@ -0,0 +1,21 @@ +// Copyright Sorush Sabzpour 2026. +// 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) + +// Local counterpart of from boostorg/config +// PR #535 "Adds support for C++20 modules" (not merged yet). It follows +// that PR's compatibility-header pattern so that, in the future modules +// mode (BOOST_USE_MODULES), the standard library is consumed through +// 'import std;' instead of textual includes inside module units. +// +// TODO: when boostorg/config PR #535 is merged, replace the callers of +// this shim with and delete this file. + +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#endif diff --git a/src/options_description.cpp b/src/options_description.cpp index 3e5877e09..8fbf35638 100644 --- a/src/options_description.cpp +++ b/src/options_description.cpp @@ -9,17 +9,17 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include -#include -#include -#include -#include -#include +#include "cppm/std/cassert.hpp" +#include "cppm/std/climits.hpp" +#include "cppm/std/cstdarg.hpp" +#include "cppm/std/cstring.hpp" +#include "cppm/std/iterator.hpp" +#include "cppm/std/sstream.hpp" #include #include #include #include -#include +#include "cppm/std/cstddef.hpp" #include module boost.program_options; diff --git a/src/parsers.cpp b/src/parsers.cpp index 4b35ec813..1336a62f6 100644 --- a/src/parsers.cpp +++ b/src/parsers.cpp @@ -9,17 +9,17 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include -#include -#include -#include -#include -#include +#include "cppm/std/cctype.hpp" +#include "cppm/std/cstdlib.hpp" +#include "cppm/std/algorithm.hpp" +#include "cppm/std/fstream.hpp" +#include "cppm/std/iostream.hpp" +#include "cppm/std/istream.hpp" #include #include #include -#include -#include +#include "cppm/std/cstddef.hpp" +#include "cppm/std/cstdlib.hpp" #include #ifndef _WIN32 diff --git a/src/positional_options.cpp b/src/positional_options.cpp index 2ee519063..3a7065967 100644 --- a/src/positional_options.cpp +++ b/src/positional_options.cpp @@ -9,9 +9,9 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include +#include "cppm/std/cassert.hpp" #include -#include +#include "cppm/std/cstddef.hpp" #include #include diff --git a/src/split.cpp b/src/split.cpp index 2040732d5..a3b74685e 100644 --- a/src/split.cpp +++ b/src/split.cpp @@ -9,10 +9,10 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include -#include +#include "cppm/std/string.hpp" +#include "cppm/std/vector.hpp" #include -#include +#include "cppm/std/cstddef.hpp" #include #include diff --git a/src/utf8_codecvt_facet.cpp b/src/utf8_codecvt_facet.cpp index ecb97ce1e..6179a736f 100644 --- a/src/utf8_codecvt_facet.cpp +++ b/src/utf8_codecvt_facet.cpp @@ -9,10 +9,10 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include -#include +#include "cppm/std/cassert.hpp" +#include "cppm/std/cstdlib.hpp" #include -#include +#include "cppm/std/cstddef.hpp" #include #include diff --git a/src/value_semantic.cpp b/src/value_semantic.cpp index 324564b24..5d0ff6c78 100644 --- a/src/value_semantic.cpp +++ b/src/value_semantic.cpp @@ -9,9 +9,9 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include -#include -#include +#include "cppm/std/cctype.hpp" +#include "cppm/std/cstddef.hpp" +#include "cppm/std/set.hpp" #include #include diff --git a/src/variables_map.cpp b/src/variables_map.cpp index ebb923b9e..3800c9ff2 100644 --- a/src/variables_map.cpp +++ b/src/variables_map.cpp @@ -9,8 +9,8 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include -#include +#include "cppm/std/cassert.hpp" +#include "cppm/std/cstddef.hpp" #include #include diff --git a/src/winmain.cpp b/src/winmain.cpp index a1ae64907..e2ba0d856 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -9,8 +9,8 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include -#include +#include "cppm/std/cctype.hpp" +#include "cppm/std/cstddef.hpp" #include #include From 2d8cb552cf48ad59fcd79327c2eefee961bfe648 Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Fri, 23 Oct 2026 11:18:38 +0330 Subject: [PATCH 13/17] Add std-header compatibility guards per boostorg/config#535; wire BOOST_USE_MODULES Every standard-header inclusion in the library's headers and sources is now wrapped in one compatibility guard per include block, following the pattern of the boost/config/std headers from boostorg/config PR #535 (Adds support for C++20 modules, not merged yet): #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif #else #include <...> #endif The guards are inactive today (BOOST_USE_MODULES is not defined), so behavior is unchanged; each carries a TODO to switch to when the PR is merged. In module units the guarded std block sits after the textual dependency preloads, keeping the MSVC-safe textual-before-import order, and the units define BOOST_IN_MODULE_PURVIEW after their module declaration, per the convention of that PR. BOOST_USE_MODULES can now be enabled from CMake: the option activates the module build, defines the macro for the module target, and requires the toolchain std module (CMAKE_CXX_MODULE_STD plus a standard in CMAKE_CXX_COMPILER_IMPORT_STD; fatal error otherwise). Full activation of the ecosystem mode additionally requires modularized dependencies: under this flag, already-converted dependencies such as Boost.TypeIndex switch their headers to importing their own modules, superseding the textual preloads used here until the PR #535 ecosystem lands. Noted in CMakeLists.txt, README.md and doc/modules.xml. Validated in fresh build directories: all 15 tests (classic build unchanged) and the module test, both with textual preloads and with import std. --- CMakeLists.txt | 47 ++++++++++-- README.md | 11 +-- doc/modules.xml | 17 ++--- .../boost/program_options/detail/cmdline.hpp | 10 +++ .../program_options/detail/config_file.hpp | 10 +++ .../boost/program_options/detail/convert.hpp | 40 +++++++++++ .../boost/program_options/detail/parsers.hpp | 6 ++ .../program_options/detail/value_semantic.hpp | 6 ++ .../program_options/environment_iterator.hpp | 10 +++ include/boost/program_options/errors.hpp | 10 +++ include/boost/program_options/option.hpp | 10 +++ .../program_options/options_description.hpp | 10 +++ include/boost/program_options/parsers.hpp | 10 +++ .../program_options/positional_options.hpp | 10 +++ .../boost/program_options/value_semantic.hpp | 10 +++ .../boost/program_options/variables_map.hpp | 10 +++ src/cmdline.cpp | 46 +++++++++--- src/config_file.cpp | 46 ++++++++++-- src/convert.cpp | 40 +++++++++-- src/cppm/boost/program_options.cppm | 49 +++++++------ src/cppm/std/algorithm.hpp | 21 ------ src/cppm/std/cassert.hpp | 21 ------ src/cppm/std/cctype.hpp | 21 ------ src/cppm/std/climits.hpp | 21 ------ src/cppm/std/clocale.hpp | 21 ------ src/cppm/std/cstdarg.hpp | 21 ------ src/cppm/std/cstddef.hpp | 21 ------ src/cppm/std/cstdio.hpp | 21 ------ src/cppm/std/cstdlib.hpp | 21 ------ src/cppm/std/cstring.hpp | 21 ------ src/cppm/std/cwchar.hpp | 21 ------ src/cppm/std/fstream.hpp | 21 ------ src/cppm/std/iosfwd.hpp | 21 ------ src/cppm/std/iostream.hpp | 21 ------ src/cppm/std/istream.hpp | 21 ------ src/cppm/std/iterator.hpp | 21 ------ src/cppm/std/limits.hpp | 21 ------ src/cppm/std/locale.hpp | 21 ------ src/cppm/std/map.hpp | 21 ------ src/cppm/std/optional.hpp | 21 ------ src/cppm/std/set.hpp | 21 ------ src/cppm/std/sstream.hpp | 21 ------ src/cppm/std/stdexcept.hpp | 21 ------ src/cppm/std/string.hpp | 21 ------ src/cppm/std/typeinfo.hpp | 21 ------ src/cppm/std/utility.hpp | 21 ------ src/cppm/std/vector.hpp | 21 ------ src/options_description.cpp | 40 +++++++++-- src/parsers.cpp | 71 ++++++++++++++++--- src/positional_options.cpp | 30 +++++++- src/split.cpp | 32 ++++++++- src/utf8_codecvt_facet.cpp | 22 +++++- src/value_semantic.cpp | 32 ++++++++- src/variables_map.cpp | 30 +++++++- src/winmain.cpp | 30 +++++++- 55 files changed, 603 insertions(+), 659 deletions(-) delete mode 100644 src/cppm/std/algorithm.hpp delete mode 100644 src/cppm/std/cassert.hpp delete mode 100644 src/cppm/std/cctype.hpp delete mode 100644 src/cppm/std/climits.hpp delete mode 100644 src/cppm/std/clocale.hpp delete mode 100644 src/cppm/std/cstdarg.hpp delete mode 100644 src/cppm/std/cstddef.hpp delete mode 100644 src/cppm/std/cstdio.hpp delete mode 100644 src/cppm/std/cstdlib.hpp delete mode 100644 src/cppm/std/cstring.hpp delete mode 100644 src/cppm/std/cwchar.hpp delete mode 100644 src/cppm/std/fstream.hpp delete mode 100644 src/cppm/std/iosfwd.hpp delete mode 100644 src/cppm/std/iostream.hpp delete mode 100644 src/cppm/std/istream.hpp delete mode 100644 src/cppm/std/iterator.hpp delete mode 100644 src/cppm/std/limits.hpp delete mode 100644 src/cppm/std/locale.hpp delete mode 100644 src/cppm/std/map.hpp delete mode 100644 src/cppm/std/optional.hpp delete mode 100644 src/cppm/std/set.hpp delete mode 100644 src/cppm/std/sstream.hpp delete mode 100644 src/cppm/std/stdexcept.hpp delete mode 100644 src/cppm/std/string.hpp delete mode 100644 src/cppm/std/typeinfo.hpp delete mode 100644 src/cppm/std/utility.hpp delete mode 100644 src/cppm/std/vector.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fc79ac15..9044b5ad6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,20 @@ endif() option(BOOST_PROGRAM_OPTIONS_BUILD_MODULES "Build the C++20 module interface (boost.program_options)" OFF) +# Modules mode of the boostorg/config PR #535 pattern ("Adds support for +# C++20 modules"): the standard-library compatibility guards in the headers +# and sources route their #include <...> directives to 'import std;'. +# Requires the module build above and a toolchain-provided std module. +# Note: full activation also needs the PR #535 ecosystem (modularized +# dependencies): under this flag, already-converted dependencies such as +# Boost.TypeIndex switch their headers to importing their own modules, +# which supersedes the textual preloads used here until then. +option(BOOST_USE_MODULES "Modules mode: consume the standard library through 'import std;' (boostorg/config#535 pattern)" OFF) + +if(BOOST_USE_MODULES AND NOT BOOST_PROGRAM_OPTIONS_BUILD_MODULES) + set(BOOST_PROGRAM_OPTIONS_BUILD_MODULES ON) +endif() + if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) if(CMAKE_GENERATOR MATCHES "Visual Studio") @@ -129,13 +143,32 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) Boost::tokenizer ) - # Consume the standard library through 'import std;' in the module - # interface when the toolchain provides the std module (CMake 3.30+, - # -DCMAKE_CXX_MODULE_STD=ON and a C++ standard listed in - # CMAKE_CXX_COMPILER_IMPORT_STD), like other modularized Boost libraries. - # The textual preloads in the interface stay: the library's headers are not - # converted to compatibility headers yet. - if(CMAKE_CXX_MODULE_STD AND CMAKE_CXX_STANDARD IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) + # Standard-library consumption of the module units. + # + # BOOST_USE_MODULES (the flag used by the compatibility guards, following + # boostorg/config PR #535) activates the modules mode: the guards replace + # the textual standard includes with 'import std;'. It requires the + # std module (CMake 3.30+, -DCMAKE_CXX_MODULE_STD=ON and a C++ standard + # listed in CMAKE_CXX_COMPILER_IMPORT_STD). + # + # Without it, the standard library is preloaded textually in the global + # module fragment of each module unit, and 'import std;' is additionally + # used when the toolchain provides it (like in other modularized Boost + # libraries). + if(BOOST_USE_MODULES) + if(NOT (CMAKE_CXX_MODULE_STD AND CMAKE_CXX_STANDARD IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD)) + message(FATAL_ERROR + "BOOST_USE_MODULES requires the C++ std module: use CMake 3.30+, set " + "-DCMAKE_CXX_MODULE_STD=ON, choose a -DCMAKE_CXX_STANDARD=... listed in " + "CMAKE_CXX_COMPILER_IMPORT_STD, and, where required by the CMake version, " + "set CMAKE_EXPERIMENTAL_CXX_IMPORT_STD.") + endif() + set_target_properties(boost_program_options_modules PROPERTIES CXX_MODULE_STD ON) + target_compile_definitions(boost_program_options_modules + PRIVATE BOOST_USE_MODULES + PUBLIC BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) + message(STATUS "boost_program_options_modules: modules mode (BOOST_USE_MODULES), 'import std;'") + elseif(CMAKE_CXX_MODULE_STD AND CMAKE_CXX_STANDARD IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) set_target_properties(boost_program_options_modules PROPERTIES CXX_MODULE_STD ON) target_compile_definitions(boost_program_options_modules PUBLIC BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) message(STATUS "boost_program_options_modules: using 'import std;' (C++${CMAKE_CXX_STANDARD})") diff --git a/README.md b/README.md index 70c8799a0..7ec9975c5 100644 --- a/README.md +++ b/README.md @@ -37,14 +37,15 @@ classic builds the same files compile unchanged. (The header export-block style of Boost.Any/Boost.PFR is not needed for this: no header carries module machinery at all.) -The standard-header includes in the module units go through local -compatibility shims in `src/cppm/std/`, following the pattern of +The standard-header includes in the library's headers and sources are +wrapped in a compatibility guard following the pattern of `` from [boostorg/config PR #535](https://github.com/boostorg/config/pull/535) ("Adds support for C++20 modules", not merged yet): plain `#include <...>` today, `import -std;` in the future modules mode. Once that PR is merged, the shims are -to be replaced with `` (TODO comments in the -shims). +std;` in the modules mode (`-DBOOST_USE_MODULES=ON`, which requires a +toolchain-provided std module). Once that PR is merged, the guards are +to be replaced with `` (TODO comments at each +guard). The module is not built by default. Enable it by configuring CMake with `-DBOOST_PROGRAM_OPTIONS_BUILD_MODULES=ON`, which creates the additional diff --git a/doc/modules.xml b/doc/modules.xml index cb18d2bb9..65c1fa977 100644 --- a/doc/modules.xml +++ b/doc/modules.xml @@ -85,14 +85,15 @@ ctest --output-on-failure BOOST_PROGRAM_OPTIONS_VERSION are not exported; code that needs those macros must include the classic headers. - The standard-header includes of the module units go through - local compatibility shims in src/cppm/std/, following - the pattern of <boost/config/std/...> from - boostorg/config PR #535 (Adds support for C++20 - modules): a plain #include today, and - import std; in the future modules mode. Once that PR - is merged, the shims should be replaced with the Boost.Config - headers (see the TODO comments in the shims). + The standard-header includes of the library's headers and + sources are wrapped in a compatibility guard following the pattern + of <boost/config/std/...> from boostorg/config + PR #535 (Adds support for C++20 modules): a plain + #include today, and import std; in the + modules mode (-DBOOST_USE_MODULES=ON, which requires a + toolchain-provided std module). Once that PR is merged, the guards + should be replaced with the Boost.Config headers (see the TODO + comments at each guard). diff --git a/include/boost/program_options/detail/cmdline.hpp b/include/boost/program_options/detail/cmdline.hpp index dce407c0b..6d4701fb2 100644 --- a/include/boost/program_options/detail/cmdline.hpp +++ b/include/boost/program_options/detail/cmdline.hpp @@ -19,8 +19,18 @@ #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include +#endif // standard library compatibility guard #if defined(BOOST_MSVC) # pragma warning (push) diff --git a/include/boost/program_options/detail/config_file.hpp b/include/boost/program_options/detail/config_file.hpp index 808bec7f1..b57236a65 100644 --- a/include/boost/program_options/detail/config_file.hpp +++ b/include/boost/program_options/detail/config_file.hpp @@ -7,9 +7,19 @@ #ifndef BOOST_CONFIG_FILE_VP_2003_01_02 #define BOOST_CONFIG_FILE_VP_2003_01_02 +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include +#endif // standard library compatibility guard #include #include diff --git a/include/boost/program_options/detail/convert.hpp b/include/boost/program_options/detail/convert.hpp index a22dd6f37..90dafbc59 100644 --- a/include/boost/program_options/detail/convert.hpp +++ b/include/boost/program_options/detail/convert.hpp @@ -12,15 +12,45 @@ #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include +#endif // standard library compatibility guard // for mbstate_t +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include +#endif // standard library compatibility guard #if defined(BOOST_NO_STDC_NAMESPACE) +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include +#endif // standard library compatibility guard namespace std { using ::mbstate_t; @@ -86,9 +116,19 @@ namespace boost { } +#else +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif #else #include #include +#endif // standard library compatibility guard namespace boost{ namespace program_options{ BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::string&); diff --git a/include/boost/program_options/detail/parsers.hpp b/include/boost/program_options/detail/parsers.hpp index cdda539ca..1c55d7b6b 100644 --- a/include/boost/program_options/detail/parsers.hpp +++ b/include/boost/program_options/detail/parsers.hpp @@ -8,7 +8,13 @@ #include +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include +#endif // standard library compatibility guard namespace boost { namespace program_options { diff --git a/include/boost/program_options/detail/value_semantic.hpp b/include/boost/program_options/detail/value_semantic.hpp index 27b7c241b..8f31251a7 100644 --- a/include/boost/program_options/detail/value_semantic.hpp +++ b/include/boost/program_options/detail/value_semantic.hpp @@ -9,7 +9,13 @@ #include #ifndef BOOST_NO_CXX17_HDR_OPTIONAL +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else # include +#endif // standard library compatibility guard #endif // forward declaration diff --git a/include/boost/program_options/environment_iterator.hpp b/include/boost/program_options/environment_iterator.hpp index 933919d15..511c8fdbb 100644 --- a/include/boost/program_options/environment_iterator.hpp +++ b/include/boost/program_options/environment_iterator.hpp @@ -8,9 +8,19 @@ #include "eof_iterator.hpp" +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include +#endif // standard library compatibility guard namespace boost { diff --git a/include/boost/program_options/errors.hpp b/include/boost/program_options/errors.hpp index 953db1366..42f507be8 100644 --- a/include/boost/program_options/errors.hpp +++ b/include/boost/program_options/errors.hpp @@ -9,10 +9,20 @@ #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include #include +#endif // standard library compatibility guard #if defined(BOOST_MSVC) diff --git a/include/boost/program_options/option.hpp b/include/boost/program_options/option.hpp index 427678fa7..b2c8a5d12 100644 --- a/include/boost/program_options/option.hpp +++ b/include/boost/program_options/option.hpp @@ -8,8 +8,18 @@ #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include +#endif // standard library compatibility guard namespace boost { namespace program_options { diff --git a/include/boost/program_options/options_description.hpp b/include/boost/program_options/options_description.hpp index da2c4bbfe..dad1a12a1 100644 --- a/include/boost/program_options/options_description.hpp +++ b/include/boost/program_options/options_description.hpp @@ -17,6 +17,15 @@ #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include @@ -25,6 +34,7 @@ #include #include +#endif // standard library compatibility guard #if defined(BOOST_MSVC) # pragma warning (push) diff --git a/include/boost/program_options/parsers.hpp b/include/boost/program_options/parsers.hpp index c86b53746..d22aafb3f 100644 --- a/include/boost/program_options/parsers.hpp +++ b/include/boost/program_options/parsers.hpp @@ -13,9 +13,19 @@ #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include +#endif // standard library compatibility guard #if defined(BOOST_MSVC) # pragma warning (push) diff --git a/include/boost/program_options/positional_options.hpp b/include/boost/program_options/positional_options.hpp index c19c9250e..f1cbfcf39 100644 --- a/include/boost/program_options/positional_options.hpp +++ b/include/boost/program_options/positional_options.hpp @@ -8,8 +8,18 @@ #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include +#endif // standard library compatibility guard #if defined(BOOST_MSVC) # pragma warning (push) diff --git a/include/boost/program_options/value_semantic.hpp b/include/boost/program_options/value_semantic.hpp index 717f2cd99..294f70a3f 100644 --- a/include/boost/program_options/value_semantic.hpp +++ b/include/boost/program_options/value_semantic.hpp @@ -13,10 +13,20 @@ #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include #include +#endif // standard library compatibility guard namespace boost { namespace program_options { diff --git a/include/boost/program_options/variables_map.hpp b/include/boost/program_options/variables_map.hpp index 3d7662931..bcf0d448a 100644 --- a/include/boost/program_options/variables_map.hpp +++ b/include/boost/program_options/variables_map.hpp @@ -12,9 +12,19 @@ #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include +#endif // standard library compatibility guard #if defined(BOOST_MSVC) # pragma warning (push) diff --git a/src/cmdline.cpp b/src/cmdline.cpp index 0dfa7545c..712e807bb 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -9,22 +9,37 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/cassert.hpp" -#include "cppm/std/cctype.hpp" -#include "cppm/std/climits.hpp" -#include "cppm/std/cstdio.hpp" -#include "cppm/std/cstring.hpp" -#include "cppm/std/iostream.hpp" -#include "cppm/std/string.hpp" -#include "cppm/std/utility.hpp" -#include "cppm/std/vector.hpp" #include #include -#include "cppm/std/cstddef.hpp" #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // standard library compatibility guard + module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #define BOOST_CMDLINE_VP_2003_05_19 #define BOOST_ERRORS_VP_2003_01_02 #define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 @@ -53,6 +68,15 @@ module boost.program_options; #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include @@ -64,6 +88,7 @@ module boost.program_options; #include #include +#endif // standard library compatibility guard using namespace boost::placeholders; @@ -749,3 +774,4 @@ namespace boost { namespace program_options { namespace detail { }}} + diff --git a/src/config_file.cpp b/src/config_file.cpp index fd5c70b69..350fd72f8 100644 --- a/src/config_file.cpp +++ b/src/config_file.cpp @@ -9,16 +9,31 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/cassert.hpp" -#include "cppm/std/fstream.hpp" -#include "cppm/std/iostream.hpp" -#include "cppm/std/sstream.hpp" #include -#include "cppm/std/cstddef.hpp" #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#include +#include +#include +#endif // standard library compatibility guard + module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #define BOOST_CONFIG_FILE_VP_2003_01_02 #define BOOST_CONVERT_HPP_VP_2004_04_28 #define BOOST_ERRORS_VP_2003_01_02 @@ -39,9 +54,19 @@ module boost.program_options; #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include +#endif // standard library compatibility guard namespace boost { namespace program_options { namespace detail { @@ -197,8 +222,18 @@ namespace boost { namespace program_options { namespace detail { #if 0 using boost::program_options::config_file; +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include +#endif // standard library compatibility guard int main() { @@ -225,3 +260,4 @@ int main() } } #endif + diff --git a/src/convert.cpp b/src/convert.cpp index 664052938..92ba00dec 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -9,14 +9,7 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/fstream.hpp" -#include "cppm/std/iostream.hpp" -#include "cppm/std/locale.hpp" -#include "cppm/std/clocale.hpp" -#include "cppm/std/stdexcept.hpp" -#include "cppm/std/string.hpp" #include -#include "cppm/std/cstddef.hpp" #include #include @@ -29,8 +22,30 @@ module; #undef BOOST_UTF8_END_NAMESPACE #undef BOOST_UTF8_DECL +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#include +#include +#include +#include +#include +#endif // standard library compatibility guard + module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #define BOOST_CONVERT_HPP_VP_2004_04_28 #define BOOST_PROGRAM_OPTIONS_UTF8_CODECVT_FACET_HPP #endif @@ -40,6 +55,15 @@ module boost.program_options; // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include @@ -47,6 +71,7 @@ module boost.program_options; #include #include #include +#endif // standard library compatibility guard #include @@ -199,3 +224,4 @@ namespace boost { } + diff --git a/src/cppm/boost/program_options.cppm b/src/cppm/boost/program_options.cppm index f5f22c341..ff61c06dc 100644 --- a/src/cppm/boost/program_options.cppm +++ b/src/cppm/boost/program_options.cppm @@ -37,26 +37,6 @@ module; -// Standard headers used by the library's headers, through the local -// compatibility shims in std/ (counterparts of from -// boostorg/config PR #535 "Adds support for C++20 modules"). -// TODO: when that PR is merged, replace the shims with -// includes. -#include "../std/cassert.hpp" -#include "../std/cwchar.hpp" -#include "../std/iosfwd.hpp" -#include "../std/iterator.hpp" -#include "../std/limits.hpp" -#include "../std/locale.hpp" -#include "../std/map.hpp" -#include "../std/optional.hpp" -#include "../std/set.hpp" -#include "../std/stdexcept.hpp" -#include "../std/string.hpp" -#include "../std/typeinfo.hpp" -#include "../std/utility.hpp" -#include "../std/vector.hpp" - // Boost dependencies used by the library's headers. #include #include @@ -73,6 +53,31 @@ module; #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // standard library compatibility guard + // Consume the standard library through 'import std;' as well when the // toolchain provides it (BOOST_PROGRAM_OPTIONS_USE_STD_MODULE, set by CMake // like in other modularized Boost libraries). The import must come after @@ -90,6 +95,10 @@ import std; export module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + // Some compilers prune global-module-fragment declarations from the BMI. // The preloaded boost::any_cast template is instantiated in importing // translation units (e.g. by variable_value::as()) and looks up diff --git a/src/cppm/std/algorithm.hpp b/src/cppm/std/algorithm.hpp deleted file mode 100644 index e22b1bf13..000000000 --- a/src/cppm/std/algorithm.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/cassert.hpp b/src/cppm/std/cassert.hpp deleted file mode 100644 index 6f9480d79..000000000 --- a/src/cppm/std/cassert.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/cctype.hpp b/src/cppm/std/cctype.hpp deleted file mode 100644 index 509187c26..000000000 --- a/src/cppm/std/cctype.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/climits.hpp b/src/cppm/std/climits.hpp deleted file mode 100644 index 2697463a3..000000000 --- a/src/cppm/std/climits.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/clocale.hpp b/src/cppm/std/clocale.hpp deleted file mode 100644 index f479cafbb..000000000 --- a/src/cppm/std/clocale.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/cstdarg.hpp b/src/cppm/std/cstdarg.hpp deleted file mode 100644 index fce66dc5b..000000000 --- a/src/cppm/std/cstdarg.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/cstddef.hpp b/src/cppm/std/cstddef.hpp deleted file mode 100644 index 797d26c46..000000000 --- a/src/cppm/std/cstddef.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/cstdio.hpp b/src/cppm/std/cstdio.hpp deleted file mode 100644 index d8b999af8..000000000 --- a/src/cppm/std/cstdio.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/cstdlib.hpp b/src/cppm/std/cstdlib.hpp deleted file mode 100644 index 2b7fe8a6b..000000000 --- a/src/cppm/std/cstdlib.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/cstring.hpp b/src/cppm/std/cstring.hpp deleted file mode 100644 index 5cc9676d5..000000000 --- a/src/cppm/std/cstring.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/cwchar.hpp b/src/cppm/std/cwchar.hpp deleted file mode 100644 index f606027f3..000000000 --- a/src/cppm/std/cwchar.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/fstream.hpp b/src/cppm/std/fstream.hpp deleted file mode 100644 index 779146e38..000000000 --- a/src/cppm/std/fstream.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/iosfwd.hpp b/src/cppm/std/iosfwd.hpp deleted file mode 100644 index 09f7370be..000000000 --- a/src/cppm/std/iosfwd.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/iostream.hpp b/src/cppm/std/iostream.hpp deleted file mode 100644 index 6375d30da..000000000 --- a/src/cppm/std/iostream.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/istream.hpp b/src/cppm/std/istream.hpp deleted file mode 100644 index b99dbabb9..000000000 --- a/src/cppm/std/istream.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/iterator.hpp b/src/cppm/std/iterator.hpp deleted file mode 100644 index b3a592f5b..000000000 --- a/src/cppm/std/iterator.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/limits.hpp b/src/cppm/std/limits.hpp deleted file mode 100644 index a8fab9200..000000000 --- a/src/cppm/std/limits.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/locale.hpp b/src/cppm/std/locale.hpp deleted file mode 100644 index adec862a3..000000000 --- a/src/cppm/std/locale.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/map.hpp b/src/cppm/std/map.hpp deleted file mode 100644 index 33ac0ea71..000000000 --- a/src/cppm/std/map.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/optional.hpp b/src/cppm/std/optional.hpp deleted file mode 100644 index 6f4ea0a38..000000000 --- a/src/cppm/std/optional.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/set.hpp b/src/cppm/std/set.hpp deleted file mode 100644 index c6bb3f9f9..000000000 --- a/src/cppm/std/set.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/sstream.hpp b/src/cppm/std/sstream.hpp deleted file mode 100644 index 333709547..000000000 --- a/src/cppm/std/sstream.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/stdexcept.hpp b/src/cppm/std/stdexcept.hpp deleted file mode 100644 index d60afb7e4..000000000 --- a/src/cppm/std/stdexcept.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/string.hpp b/src/cppm/std/string.hpp deleted file mode 100644 index 41e161849..000000000 --- a/src/cppm/std/string.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/typeinfo.hpp b/src/cppm/std/typeinfo.hpp deleted file mode 100644 index c5e69a251..000000000 --- a/src/cppm/std/typeinfo.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/utility.hpp b/src/cppm/std/utility.hpp deleted file mode 100644 index 4eb4de2a2..000000000 --- a/src/cppm/std/utility.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/cppm/std/vector.hpp b/src/cppm/std/vector.hpp deleted file mode 100644 index c49f2354d..000000000 --- a/src/cppm/std/vector.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Sorush Sabzpour 2026. -// 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) - -// Local counterpart of from boostorg/config -// PR #535 "Adds support for C++20 modules" (not merged yet). It follows -// that PR's compatibility-header pattern so that, in the future modules -// mode (BOOST_USE_MODULES), the standard library is consumed through -// 'import std;' instead of textual includes inside module units. -// -// TODO: when boostorg/config PR #535 is merged, replace the callers of -// this shim with and delete this file. - -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif diff --git a/src/options_description.cpp b/src/options_description.cpp index 8fbf35638..7680cb32d 100644 --- a/src/options_description.cpp +++ b/src/options_description.cpp @@ -9,21 +9,36 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/cassert.hpp" -#include "cppm/std/climits.hpp" -#include "cppm/std/cstdarg.hpp" -#include "cppm/std/cstring.hpp" -#include "cppm/std/iterator.hpp" -#include "cppm/std/sstream.hpp" #include #include #include #include -#include "cppm/std/cstddef.hpp" #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#include +#include +#include +#include +#include +#endif // standard library compatibility guard + module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 #define BOOST_PARSERS_VP_2003_05_19 #endif @@ -49,12 +64,22 @@ module boost.program_options; #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include #include #include #include #include +#endif // standard library compatibility guard using namespace std; namespace boost { namespace program_options { @@ -728,3 +753,4 @@ namespace boost { namespace program_options { } }} + diff --git a/src/parsers.cpp b/src/parsers.cpp index 1336a62f6..576cecec8 100644 --- a/src/parsers.cpp +++ b/src/parsers.cpp @@ -9,25 +9,39 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/cctype.hpp" -#include "cppm/std/cstdlib.hpp" -#include "cppm/std/algorithm.hpp" -#include "cppm/std/fstream.hpp" -#include "cppm/std/iostream.hpp" -#include "cppm/std/istream.hpp" #include #include #include -#include "cppm/std/cstddef.hpp" -#include "cppm/std/cstdlib.hpp" #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#include +#include +#include +#include +#include +#include +#endif // standard library compatibility guard #ifndef _WIN32 #include #endif module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #define BOOST_CMDLINE_VP_2003_05_19 #define BOOST_CONFIG_FILE_VP_2003_01_02 #define BOOST_CONVERT_HPP_VP_2004_04_28 @@ -60,17 +74,57 @@ module boost.program_options; #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include +#endif // standard library compatibility guard #if !defined(__GNUC__) || __GNUC__ < 3 +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include +#endif // standard library compatibility guard +#else +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif #else #include +#endif // standard library compatibility guard #endif #ifdef _WIN32 +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include +#endif // standard library compatibility guard #else #include #endif @@ -298,3 +352,4 @@ namespace boost { namespace program_options { }} + diff --git a/src/positional_options.cpp b/src/positional_options.cpp index 3a7065967..2a8a743dd 100644 --- a/src/positional_options.cpp +++ b/src/positional_options.cpp @@ -9,14 +9,29 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/cassert.hpp" #include -#include "cppm/std/cstddef.hpp" #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#endif // standard library compatibility guard + module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 #endif @@ -34,7 +49,17 @@ module boost.program_options; #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include +#endif // standard library compatibility guard namespace boost { namespace program_options { @@ -75,3 +100,4 @@ namespace boost { namespace program_options { }} + diff --git a/src/split.cpp b/src/split.cpp index a3b74685e..c29ffe1c3 100644 --- a/src/split.cpp +++ b/src/split.cpp @@ -9,15 +9,30 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/string.hpp" -#include "cppm/std/vector.hpp" #include -#include "cppm/std/cstddef.hpp" #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#include +#endif // standard library compatibility guard + module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #define BOOST_PARSERS_VP_2003_05_19 #endif @@ -33,8 +48,18 @@ module boost.program_options; #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include +#endif // standard library compatibility guard namespace boost { namespace program_options { namespace detail { @@ -85,3 +110,4 @@ namespace boost { namespace program_options { }} // namespace + diff --git a/src/utf8_codecvt_facet.cpp b/src/utf8_codecvt_facet.cpp index 6179a736f..389c29279 100644 --- a/src/utf8_codecvt_facet.cpp +++ b/src/utf8_codecvt_facet.cpp @@ -9,10 +9,7 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/cassert.hpp" -#include "cppm/std/cstdlib.hpp" #include -#include "cppm/std/cstddef.hpp" #include #include @@ -25,8 +22,26 @@ module; #undef BOOST_UTF8_END_NAMESPACE #undef BOOST_UTF8_DECL +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#include +#endif // standard library compatibility guard + module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #endif // Copyright Vladimir Prus 2004. @@ -52,3 +67,4 @@ module boost.program_options; #undef BOOST_UTF8_END_NAMESPACE #undef BOOST_UTF8_DECL + diff --git a/src/value_semantic.cpp b/src/value_semantic.cpp index 5d0ff6c78..536fd3b5f 100644 --- a/src/value_semantic.cpp +++ b/src/value_semantic.cpp @@ -9,14 +9,29 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/cctype.hpp" -#include "cppm/std/cstddef.hpp" -#include "cppm/std/set.hpp" #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#include +#endif // standard library compatibility guard + module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #define BOOST_CMDLINE_VP_2003_05_19 #define BOOST_CONVERT_HPP_VP_2004_04_28 #define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 @@ -34,9 +49,19 @@ module boost.program_options; #include #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include #include +#endif // standard library compatibility guard namespace boost { namespace program_options { @@ -454,3 +479,4 @@ namespace boost { namespace program_options { } }} + diff --git a/src/variables_map.cpp b/src/variables_map.cpp index 3800c9ff2..27c5675b5 100644 --- a/src/variables_map.cpp +++ b/src/variables_map.cpp @@ -9,13 +9,28 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/cassert.hpp" -#include "cppm/std/cstddef.hpp" #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#endif // standard library compatibility guard + module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 #define BOOST_PARSERS_VP_2003_05_19 #define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 @@ -36,7 +51,17 @@ module boost.program_options; #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include +#endif // standard library compatibility guard namespace boost { namespace program_options { @@ -271,3 +296,4 @@ namespace boost { namespace program_options { } }} + diff --git a/src/winmain.cpp b/src/winmain.cpp index e2ba0d856..296ee1765 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -9,13 +9,28 @@ module; // so that nothing foreign is attached to the module. The library's own // headers included below are no-ops (guards predefined after the module // declaration): their declarations come from the imported interface. -#include "cppm/std/cctype.hpp" -#include "cppm/std/cstddef.hpp" #include #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else +#include +#include +#endif // standard library compatibility guard + module boost.program_options; +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW + #define BOOST_PARSERS_VP_2003_05_19 #endif @@ -28,7 +43,17 @@ module boost.program_options; # define BOOST_PROGRAM_OPTIONS_SOURCE #endif #include +// Standard library compatibility guard, following the pattern of +// from boostorg/config PR #535 ("Adds support for +// C++20 modules"). TODO: when that PR is merged, replace the textual +// includes with (see src/cppm/boost/program_options.cppm). +#ifdef BOOST_USE_MODULES +#ifndef BOOST_IN_MODULE_PURVIEW +import std; +#endif +#else #include +#endif // standard library compatibility guard using std::size_t; @@ -123,3 +148,4 @@ namespace boost { namespace program_options { }} #endif + From 85128c2f2f6b1aa644d2d1f21224458135dd64da Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Fri, 23 Oct 2026 11:25:25 +0330 Subject: [PATCH 14/17] Move the module interface to the root-level modules/ directory Place boost_program_options.cppm and usage_sample.cpp in a root-level modules/ directory, matching the layout of the modularized Boost libraries (Boost.Any, Boost.PFR, Boost.TypeIndex). All references (CMake file set and install rule, comments in the compatibility guards, README, documentation) are updated accordingly. --- CMakeLists.txt | 6 +++--- README.md | 6 +++--- doc/modules.xml | 4 ++-- include/boost/program_options/detail/cmdline.hpp | 2 +- include/boost/program_options/detail/config_file.hpp | 2 +- include/boost/program_options/detail/convert.hpp | 8 ++++---- .../boost/program_options/environment_iterator.hpp | 2 +- include/boost/program_options/errors.hpp | 2 +- include/boost/program_options/option.hpp | 2 +- .../boost/program_options/options_description.hpp | 2 +- include/boost/program_options/parsers.hpp | 2 +- include/boost/program_options/positional_options.hpp | 2 +- include/boost/program_options/value_semantic.hpp | 2 +- include/boost/program_options/variables_map.hpp | 2 +- .../boost_program_options.cppm | 2 +- {src/cppm => modules}/usage_sample.cpp | 0 src/cmdline.cpp | 6 +++--- src/config_file.cpp | 8 ++++---- src/convert.cpp | 6 +++--- src/options_description.cpp | 6 +++--- src/parsers.cpp | 12 ++++++------ src/positional_options.cpp | 6 +++--- src/split.cpp | 6 +++--- src/utf8_codecvt_facet.cpp | 4 ++-- src/value_semantic.cpp | 6 +++--- src/variables_map.cpp | 6 +++--- src/winmain.cpp | 6 +++--- 27 files changed, 59 insertions(+), 59 deletions(-) rename src/cppm/boost/program_options.cppm => modules/boost_program_options.cppm (98%) rename {src/cppm => modules}/usage_sample.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9044b5ad6..013165dfe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,8 +108,8 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) target_sources(boost_program_options_modules PUBLIC FILE_SET CXX_MODULES - BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/cppm" - FILES src/cppm/boost/program_options.cppm + BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/modules" + FILES modules/boost_program_options.cppm ) target_compile_features(boost_program_options_modules PUBLIC cxx_std_20) @@ -180,7 +180,7 @@ if(BOOST_PROGRAM_OPTIONS_BUILD_MODULES) # Install the module interface source next to the headers, so that it is # available to build systems that do not produce BMIs from installed # packages (e.g. MSBuild projects adding the .cppm/.ixx directly). - install(FILES src/cppm/boost/program_options.cppm DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost") + install(FILES modules/boost_program_options.cppm DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost") endif() endif() diff --git a/README.md b/README.md index 7ec9975c5..9c28ab964 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ import boost.program_options; and keep using the `boost::program_options` namespace unchanged. -The interface (`src/cppm/boost/program_options.cppm`) preloads the library's +The interface (`modules/boost_program_options.cppm`) preloads the library's dependencies in the global module fragment and includes the umbrella header in the module purview inside an `export { ... }` block, so the public declarations are exported without modifying any header. The library's @@ -87,8 +87,8 @@ changes to re-align with the evolution of Boost C++ Libraries and C++. | `doc` | documentation | | `example` | use case examples | | `include` | headers | -| `src` | source code for link library and | -| | C++20 module interface | +| `modules` | C++20 module interface | +| `src` | source code for link library | | `test` | unit tests | ### More information diff --git a/doc/modules.xml b/doc/modules.xml index 65c1fa977..a511b57d3 100644 --- a/doc/modules.xml +++ b/doc/modules.xml @@ -46,9 +46,9 @@ int main(int argc, char* argv[]) declared by the umbrella header <boost/program_options.hpp>, so existing code only needs to replace the #include with an import. A minimal, compilable - example is provided in src/cppm/usage_sample.cpp. + example is provided in modules/usage_sample.cpp. - The interface (src/cppm/boost/program_options.cppm) + The interface (modules/boost_program_options.cppm) preloads the library's dependencies in the global module fragment and includes the umbrella header in the module purview inside an export { ... } block, so the public declarations are diff --git a/include/boost/program_options/detail/cmdline.hpp b/include/boost/program_options/detail/cmdline.hpp index 6d4701fb2..eb0d538b5 100644 --- a/include/boost/program_options/detail/cmdline.hpp +++ b/include/boost/program_options/detail/cmdline.hpp @@ -22,7 +22,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/include/boost/program_options/detail/config_file.hpp b/include/boost/program_options/detail/config_file.hpp index b57236a65..a4a2074ca 100644 --- a/include/boost/program_options/detail/config_file.hpp +++ b/include/boost/program_options/detail/config_file.hpp @@ -10,7 +10,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/include/boost/program_options/detail/convert.hpp b/include/boost/program_options/detail/convert.hpp index 90dafbc59..97ad90ab7 100644 --- a/include/boost/program_options/detail/convert.hpp +++ b/include/boost/program_options/detail/convert.hpp @@ -15,7 +15,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -29,7 +29,7 @@ import std; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -43,7 +43,7 @@ import std; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -120,7 +120,7 @@ namespace boost { // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/include/boost/program_options/environment_iterator.hpp b/include/boost/program_options/environment_iterator.hpp index 511c8fdbb..69bc0dcb2 100644 --- a/include/boost/program_options/environment_iterator.hpp +++ b/include/boost/program_options/environment_iterator.hpp @@ -11,7 +11,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/include/boost/program_options/errors.hpp b/include/boost/program_options/errors.hpp index 42f507be8..cc8ba227b 100644 --- a/include/boost/program_options/errors.hpp +++ b/include/boost/program_options/errors.hpp @@ -12,7 +12,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/include/boost/program_options/option.hpp b/include/boost/program_options/option.hpp index b2c8a5d12..6f1d15567 100644 --- a/include/boost/program_options/option.hpp +++ b/include/boost/program_options/option.hpp @@ -11,7 +11,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/include/boost/program_options/options_description.hpp b/include/boost/program_options/options_description.hpp index dad1a12a1..cb86bac9d 100644 --- a/include/boost/program_options/options_description.hpp +++ b/include/boost/program_options/options_description.hpp @@ -20,7 +20,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/include/boost/program_options/parsers.hpp b/include/boost/program_options/parsers.hpp index d22aafb3f..16e36d4b7 100644 --- a/include/boost/program_options/parsers.hpp +++ b/include/boost/program_options/parsers.hpp @@ -16,7 +16,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/include/boost/program_options/positional_options.hpp b/include/boost/program_options/positional_options.hpp index f1cbfcf39..4134d6dde 100644 --- a/include/boost/program_options/positional_options.hpp +++ b/include/boost/program_options/positional_options.hpp @@ -11,7 +11,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/include/boost/program_options/value_semantic.hpp b/include/boost/program_options/value_semantic.hpp index 294f70a3f..e9c10d7a2 100644 --- a/include/boost/program_options/value_semantic.hpp +++ b/include/boost/program_options/value_semantic.hpp @@ -16,7 +16,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/include/boost/program_options/variables_map.hpp b/include/boost/program_options/variables_map.hpp index bcf0d448a..3f256f927 100644 --- a/include/boost/program_options/variables_map.hpp +++ b/include/boost/program_options/variables_map.hpp @@ -15,7 +15,7 @@ // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/cppm/boost/program_options.cppm b/modules/boost_program_options.cppm similarity index 98% rename from src/cppm/boost/program_options.cppm rename to modules/boost_program_options.cppm index ff61c06dc..d570ba0de 100644 --- a/src/cppm/boost/program_options.cppm +++ b/modules/boost_program_options.cppm @@ -56,7 +56,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/cppm/usage_sample.cpp b/modules/usage_sample.cpp similarity index 100% rename from src/cppm/usage_sample.cpp rename to modules/usage_sample.cpp diff --git a/src/cmdline.cpp b/src/cmdline.cpp index 712e807bb..8c6a88427 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -16,7 +16,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -71,7 +71,7 @@ module boost.program_options; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/config_file.cpp b/src/config_file.cpp index 350fd72f8..a42eea494 100644 --- a/src/config_file.cpp +++ b/src/config_file.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -15,7 +15,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -57,7 +57,7 @@ module boost.program_options; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -225,7 +225,7 @@ using boost::program_options::config_file; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/convert.cpp b/src/convert.cpp index 92ba00dec..b198df31e 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -25,7 +25,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -58,7 +58,7 @@ module boost.program_options; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/options_description.cpp b/src/options_description.cpp index 7680cb32d..3c2e57c39 100644 --- a/src/options_description.cpp +++ b/src/options_description.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -18,7 +18,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -67,7 +67,7 @@ module boost.program_options; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/parsers.cpp b/src/parsers.cpp index 576cecec8..80dae2f48 100644 --- a/src/parsers.cpp +++ b/src/parsers.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -17,7 +17,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -77,7 +77,7 @@ module boost.program_options; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -91,7 +91,7 @@ import std; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -103,7 +103,7 @@ import std; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -117,7 +117,7 @@ import std; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/positional_options.cpp b/src/positional_options.cpp index 2a8a743dd..7dcf83f9b 100644 --- a/src/positional_options.cpp +++ b/src/positional_options.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -16,7 +16,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -52,7 +52,7 @@ module boost.program_options; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/split.cpp b/src/split.cpp index c29ffe1c3..676aef3d8 100644 --- a/src/split.cpp +++ b/src/split.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -16,7 +16,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -51,7 +51,7 @@ module boost.program_options; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/utf8_codecvt_facet.cpp b/src/utf8_codecvt_facet.cpp index 389c29279..3a1c84481 100644 --- a/src/utf8_codecvt_facet.cpp +++ b/src/utf8_codecvt_facet.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -25,7 +25,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/value_semantic.cpp b/src/value_semantic.cpp index 536fd3b5f..7a787173b 100644 --- a/src/value_semantic.cpp +++ b/src/value_semantic.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -15,7 +15,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -52,7 +52,7 @@ module boost.program_options; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/variables_map.cpp b/src/variables_map.cpp index 27c5675b5..6f0de320f 100644 --- a/src/variables_map.cpp +++ b/src/variables_map.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -15,7 +15,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -54,7 +54,7 @@ module boost.program_options; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; diff --git a/src/winmain.cpp b/src/winmain.cpp index 296ee1765..92aff9a55 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -1,7 +1,7 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in src/cppm/boost/program_options.cppm. In the +// matching the interface in modules/boost_program_options.cppm. In the // classic build (below) this file is compiled unchanged. module; @@ -15,7 +15,7 @@ module; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; @@ -46,7 +46,7 @@ module boost.program_options; // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see src/cppm/boost/program_options.cppm). +// includes with (see modules/boost_program_options.cppm). #ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; From 8eb15685ea714d3e563f2f9672f5b19f7a2a29ae Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Fri, 23 Oct 2026 11:41:35 +0330 Subject: [PATCH 15/17] Remove duplicated includes between the module preludes and the classic code Restructure the BOOST_PROGRAM_OPTIONS_MODULE_UNIT blocks in src/*.cpp: in module builds the classic include section of each file is now skipped entirely (#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT), so the module prelude no longer needs to mirror it through predefined include guards, and every header appears exactly once per compilation: - The prelude preloads only the non-program_options headers the classic code below includes, plus the few the classic build only got transitively through the library's own headers (e.g. for value_semantic.cpp, and iterator_facade for parsers.cpp, // for winmain.cpp). Dead-code extras are gone (e.g. in config_file.cpp, which is only used by the #if 0 block, and the blanket ). - The predefined include-guard defines are removed together with the no-op mechanism they served. - The classic include sections keep their original content and order (convert.cpp's std block moved after the library includes so the skip wraps the whole section); utf8_codecvt_facet.cpp keeps its macro block and .ipp include active in module builds. Validated in fresh build directories: all 15 tests (classic build unchanged) and the module test, both with textual preloads and with import std. --- src/cmdline.cpp | 32 ++++++++++------------- src/config_file.cpp | 24 ++++++++--------- src/convert.cpp | 51 ++++++++++++++++++------------------- src/options_description.cpp | 26 +++++++++---------- src/parsers.cpp | 26 +++++++------------ src/positional_options.cpp | 18 ++++++------- src/split.cpp | 18 ++++++------- src/utf8_codecvt_facet.cpp | 17 ++++++------- src/value_semantic.cpp | 21 +++++++-------- src/variables_map.cpp | 20 ++++++--------- src/winmain.cpp | 19 +++++++------- 11 files changed, 121 insertions(+), 151 deletions(-) diff --git a/src/cmdline.cpp b/src/cmdline.cpp index 8c6a88427..43ac0dd35 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -1,16 +1,17 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. -#include +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. +#include #include +#include #include // Standard library compatibility guard, following the pattern of @@ -22,16 +23,15 @@ module; import std; #endif #else +#include +#include +#include #include +#include #include #include #include -#include #include -#include -#include -#include -#include #endif // standard library compatibility guard module boost.program_options; @@ -39,12 +39,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_ERRORS_VP_2003_01_02 -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 #endif // Copyright Vladimir Prus 2002-2004. @@ -55,6 +49,7 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include @@ -67,6 +62,7 @@ module boost.program_options; #include #include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for diff --git a/src/config_file.cpp b/src/config_file.cpp index a42eea494..bd8a6cd7e 100644 --- a/src/config_file.cpp +++ b/src/config_file.cpp @@ -1,14 +1,14 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. #include #include @@ -21,11 +21,9 @@ module; import std; #endif #else -#include -#include #include -#include -#include +#include +#include #endif // standard library compatibility guard module boost.program_options; @@ -33,10 +31,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_ERRORS_VP_2003_01_02 #endif // Copyright Vladimir Prus 2002-2004. @@ -47,12 +41,14 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include #include #include #include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for diff --git a/src/convert.cpp b/src/convert.cpp index b198df31e..56b7bc103 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -1,16 +1,16 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. -#include +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. #include +#include #include #define BOOST_UTF8_BEGIN_NAMESPACE \ @@ -32,12 +32,11 @@ import std; #endif #else #include -#include -#include #include -#include +#include +#include #include -#include +#include #endif // standard library compatibility guard module boost.program_options; @@ -45,9 +44,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_PROGRAM_OPTIONS_UTF8_CODECVT_FACET_HPP #endif // Copyright Vladimir Prus 2004. @@ -55,6 +51,20 @@ module boost.program_options; // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +#include + +#ifndef BOOST_PROGRAM_OPTIONS_SOURCE +# define BOOST_PROGRAM_OPTIONS_SOURCE +#endif +#include +#include +#include +#include + +#include + // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual @@ -72,18 +82,7 @@ import std; #include #include #endif // standard library compatibility guard - -#include - -#ifndef BOOST_PROGRAM_OPTIONS_SOURCE -# define BOOST_PROGRAM_OPTIONS_SOURCE -#endif -#include -#include -#include -#include - -#include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT using namespace std; using namespace boost::placeholders; diff --git a/src/options_description.cpp b/src/options_description.cpp index 3c2e57c39..0cb169fba 100644 --- a/src/options_description.cpp +++ b/src/options_description.cpp @@ -1,18 +1,18 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. -#include +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. #include -#include #include +#include +#include #include // Standard library compatibility guard, following the pattern of @@ -26,11 +26,10 @@ import std; #else #include #include -#include #include -#include +#include #include -#include +#include #endif // standard library compatibility guard module boost.program_options; @@ -38,9 +37,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PARSERS_VP_2003_05_19 #endif // Copyright Vladimir Prus 2002-2004. @@ -52,6 +48,7 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include // FIXME: this is only to get multiple_occurrences class @@ -63,6 +60,7 @@ module boost.program_options; #include #include #include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for diff --git a/src/parsers.cpp b/src/parsers.cpp index 80dae2f48..b9da46819 100644 --- a/src/parsers.cpp +++ b/src/parsers.cpp @@ -1,14 +1,14 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. #include #include #include @@ -24,13 +24,11 @@ import std; #endif #else #include -#include -#include #include #include #include #include -#include +#include #endif // standard library compatibility guard #ifndef _WIN32 #include @@ -41,14 +39,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONFIG_FILE_VP_2003_01_02 -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14 -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 #endif // Copyright Vladimir Prus 2002-2004. @@ -57,6 +47,7 @@ module boost.program_options; // or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #ifndef BOOST_PROGRAM_OPTIONS_SOURCE @@ -73,6 +64,7 @@ module boost.program_options; #include #include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for diff --git a/src/positional_options.cpp b/src/positional_options.cpp index 7dcf83f9b..43bf2a782 100644 --- a/src/positional_options.cpp +++ b/src/positional_options.cpp @@ -1,16 +1,15 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. #include -#include #include // Standard library compatibility guard, following the pattern of @@ -23,7 +22,6 @@ import std; #endif #else #include -#include #endif // standard library compatibility guard module boost.program_options; @@ -31,8 +29,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - -#define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 #endif // Copyright Vladimir Prus 2004. @@ -43,11 +39,13 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include #include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for diff --git a/src/split.cpp b/src/split.cpp index 676aef3d8..515280708 100644 --- a/src/split.cpp +++ b/src/split.cpp @@ -1,16 +1,15 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. #include -#include #include // Standard library compatibility guard, following the pattern of @@ -24,7 +23,6 @@ import std; #else #include #include -#include #endif // standard library compatibility guard module boost.program_options; @@ -32,8 +30,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - -#define BOOST_PARSERS_VP_2003_05_19 #endif // Copyright Sascha Ochsenknecht 2009. @@ -45,8 +41,10 @@ module boost.program_options; # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for diff --git a/src/utf8_codecvt_facet.cpp b/src/utf8_codecvt_facet.cpp index 3a1c84481..731db5656 100644 --- a/src/utf8_codecvt_facet.cpp +++ b/src/utf8_codecvt_facet.cpp @@ -1,16 +1,15 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. #include -#include #include #define BOOST_UTF8_BEGIN_NAMESPACE \ @@ -33,7 +32,6 @@ import std; #else #include #include -#include #endif // standard library compatibility guard module boost.program_options; @@ -41,7 +39,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - #endif // Copyright Vladimir Prus 2004. @@ -52,7 +49,9 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT #define BOOST_UTF8_BEGIN_NAMESPACE \ namespace boost { namespace program_options { namespace detail { diff --git a/src/value_semantic.cpp b/src/value_semantic.cpp index 7a787173b..8adc45971 100644 --- a/src/value_semantic.cpp +++ b/src/value_semantic.cpp @@ -1,14 +1,14 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. #include #include @@ -21,9 +21,8 @@ module; import std; #endif #else -#include -#include #include +#include #endif // standard library compatibility guard module boost.program_options; @@ -31,10 +30,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - -#define BOOST_CMDLINE_VP_2003_05_19 -#define BOOST_CONVERT_HPP_VP_2004_04_28 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 #endif // Copyright Vladimir Prus 2004. @@ -45,10 +40,12 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include #include #include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual diff --git a/src/variables_map.cpp b/src/variables_map.cpp index 6f0de320f..180e78163 100644 --- a/src/variables_map.cpp +++ b/src/variables_map.cpp @@ -1,14 +1,14 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. #include #include @@ -22,7 +22,6 @@ import std; #endif #else #include -#include #endif // standard library compatibility guard module boost.program_options; @@ -30,11 +29,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - -#define BOOST_OPTION_DESCRIPTION_VP_2003_05_19 -#define BOOST_PARSERS_VP_2003_05_19 -#define BOOST_VALUE_SEMANTIC_HPP_VP_2004_02_24 -#define BOOST_VARIABLES_MAP_VP_2003_05_19 #endif // Copyright Vladimir Prus 2002-2004. @@ -45,11 +39,13 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include #include #include #include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for diff --git a/src/winmain.cpp b/src/winmain.cpp index 92aff9a55..a9c1203fd 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -1,15 +1,14 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT // In the boost.program_options module build, this translation unit is a // module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. In the -// classic build (below) this file is compiled unchanged. +// matching the interface in modules/boost_program_options.cppm. The +// classic code below is compiled unchanged except that its includes are +// skipped: their declarations come from the imported interface, and the +// non-program_options headers are preloaded here instead. module; -// The headers this file includes, preloaded in the global module fragment -// so that nothing foreign is attached to the module. The library's own -// headers included below are no-ops (guards predefined after the module -// declaration): their declarations come from the imported interface. -#include +// Dependencies of the classic code below, preloaded in the global module +// fragment so that nothing foreign is attached to the module. #include // Standard library compatibility guard, following the pattern of @@ -23,6 +22,8 @@ import std; #else #include #include +#include +#include #endif // standard library compatibility guard module boost.program_options; @@ -30,8 +31,6 @@ module boost.program_options; // Purview marker of the boost.program_options module units, per the // convention used by (boostorg/config PR #535). #define BOOST_IN_MODULE_PURVIEW - -#define BOOST_PARSERS_VP_2003_05_19 #endif // Copyright Vladimir Prus 2002-2004. @@ -42,7 +41,9 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include +#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual From 9578881d1b729ebf7d94019400c43b1fb4637dba Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Fri, 23 Oct 2026 12:21:30 +0330 Subject: [PATCH 16/17] Remove the duplicated module prelude; keep the original includes with guards Restructure src/*.cpp to eliminate the duplicated include lists: in module builds, the global module fragment is now formed in place around the file's own include section instead of a parallel prelude list. Each source now shows its original includes at the original position, plus three small guards: - 'module;' opens the global module fragment at the top (module build only); the textual includes below attach to the global module. - The library's own declaration headers are skipped in module builds (#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT): the imported primary interface provides them. - 'module boost.program_options;' closes the fragment before the code. The few headers whose declarations the classic build only gets transitively through the skipped library headers are included in a module-only block (e.g. and iterator_facade for parsers.cpp, and throw_exception for value_semantic.cpp, config.hpp for split.cpp and winmain.cpp, // for winmain.cpp), placed before the standard-library guard so that textual includes come before 'import std;' (MSVC requirement). The standard-library guard in the sources takes the 'import std;' branch both in the ecosystem mode (BOOST_USE_MODULES) and when the module was built with 'import std;' (BOOST_PROGRAM_OPTIONS_USE_STD_MODULE). Files whose code calls assert() keep textual before the guard: 'assert' is a macro, and import std does not provide macros. Validated in fresh build directories: all 15 tests (classic build unchanged), and the module test with textual preloads and with import std. --- src/cmdline.cpp | 65 ++++++++++++-------------------- src/config_file.cpp | 59 ++++++++++++----------------- src/convert.cpp | 66 ++++++++++----------------------- src/options_description.cpp | 63 ++++++++++++------------------- src/parsers.cpp | 74 +++++++++++++++---------------------- src/positional_options.cpp | 55 ++++++++++++--------------- src/split.cpp | 56 ++++++++++++---------------- src/utf8_codecvt_facet.cpp | 55 +++++++-------------------- src/value_semantic.cpp | 59 +++++++++++++---------------- src/variables_map.cpp | 61 +++++++++++++++--------------- src/winmain.cpp | 60 ++++++++++++++---------------- 11 files changed, 261 insertions(+), 412 deletions(-) diff --git a/src/cmdline.cpp b/src/cmdline.cpp index 43ac0dd35..9ecbb9770 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -1,44 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include -#include -#include - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif // standard library compatibility guard - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Vladimir Prus 2002-2004. @@ -49,26 +15,32 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include #include #include #include +#endif #include #include -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +// 'assert' is a macro, which 'import std;' does not provide; keep the +// macro-only header textual in the global module fragment. +#include + +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -86,6 +58,14 @@ import std; #include #endif // standard library compatibility guard +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif + using namespace boost::placeholders; namespace boost { namespace program_options { @@ -771,3 +751,4 @@ namespace boost { namespace program_options { namespace detail { }}} + diff --git a/src/config_file.cpp b/src/config_file.cpp index bd8a6cd7e..aea739aba 100644 --- a/src/config_file.cpp +++ b/src/config_file.cpp @@ -1,36 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#include -#include -#endif // standard library compatibility guard - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Vladimir Prus 2002-2004. @@ -41,20 +15,26 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include #include +#endif #include -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +// 'assert' is a macro, which 'import std;' does not provide; keep the +// macro-only header textual in the global module fragment. +#include + +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -64,6 +44,14 @@ import std; #include #endif // standard library compatibility guard +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif + namespace boost { namespace program_options { namespace detail { using namespace std; @@ -222,7 +210,7 @@ using boost::program_options::config_file; // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -257,3 +245,4 @@ int main() } #endif + diff --git a/src/convert.cpp b/src/convert.cpp index 56b7bc103..12ec261d3 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -1,49 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include -#include - -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#include -#include -#include -#include -#include -#endif // standard library compatibility guard - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Vladimir Prus 2004. @@ -52,14 +13,17 @@ module boost.program_options; // or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif #include +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include +#endif #include #include @@ -69,7 +33,7 @@ module boost.program_options; // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -82,7 +46,14 @@ import std; #include #include #endif // standard library compatibility guard -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT + +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif using namespace std; using namespace boost::placeholders; @@ -224,3 +195,4 @@ namespace boost { } + diff --git a/src/options_description.cpp b/src/options_description.cpp index 0cb169fba..c644e7801 100644 --- a/src/options_description.cpp +++ b/src/options_description.cpp @@ -1,42 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include -#include -#include -#include - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#include -#include -#include -#include -#include -#endif // standard library compatibility guard - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Vladimir Prus 2002-2004. @@ -48,25 +16,31 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include // FIXME: this is only to get multiple_occurrences class // should move that to a separate headers. #include +#endif #include #include #include #include -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +// 'assert' is a macro, which 'import std;' does not provide; keep the +// macro-only header textual in the global module fragment. +#include + +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -78,6 +52,14 @@ import std; #include #include #endif // standard library compatibility guard + +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif using namespace std; namespace boost { namespace program_options { @@ -752,3 +734,4 @@ namespace boost { namespace program_options { }} + diff --git a/src/parsers.cpp b/src/parsers.cpp index b9da46819..77611dca0 100644 --- a/src/parsers.cpp +++ b/src/parsers.cpp @@ -1,44 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include -#include -#include - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#include -#include -#include -#include -#include -#endif // standard library compatibility guard -#ifndef _WIN32 -#include -#endif - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Vladimir Prus 2002-2004. @@ -47,13 +13,15 @@ module boost.program_options; // or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif #include +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include #include @@ -61,16 +29,23 @@ module boost.program_options; #include #include #include +#endif #include #include -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT + +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// Declarations the classic build gets transitively through the +// library's own headers (skipped above in this mode). +#include +#include +#endif // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -79,12 +54,20 @@ import std; #include #endif // standard library compatibility guard +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif + #if !defined(__GNUC__) || __GNUC__ < 3 // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -96,7 +79,7 @@ import std; // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -110,7 +93,7 @@ import std; // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -345,3 +328,4 @@ namespace boost { namespace program_options { }} + diff --git a/src/positional_options.cpp b/src/positional_options.cpp index 43bf2a782..2e4d89c9f 100644 --- a/src/positional_options.cpp +++ b/src/positional_options.cpp @@ -1,34 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif // standard library compatibility guard - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Vladimir Prus 2004. @@ -39,19 +15,25 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include +#endif #include -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +// 'assert' is a macro, which 'import std;' does not provide; keep the +// macro-only header textual in the global module fragment. +#include + +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -59,6 +41,14 @@ import std; #include #endif // standard library compatibility guard +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif + namespace boost { namespace program_options { positional_options_description::positional_options_description() @@ -99,3 +89,4 @@ namespace boost { namespace program_options { }} + diff --git a/src/split.cpp b/src/split.cpp index 515280708..749351f8d 100644 --- a/src/split.cpp +++ b/src/split.cpp @@ -1,35 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#include -#endif // standard library compatibility guard - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Sascha Ochsenknecht 2009. @@ -41,16 +16,24 @@ module boost.program_options; # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. #ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include +#endif #include -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT + +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// Declarations the classic build gets transitively through the +// library's own headers (skipped above in this mode). +#include +#endif // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -59,6 +42,14 @@ import std; #include #endif // standard library compatibility guard +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif + namespace boost { namespace program_options { namespace detail { template< class charT > @@ -109,3 +100,4 @@ namespace boost { namespace program_options { }} // namespace + diff --git a/src/utf8_codecvt_facet.cpp b/src/utf8_codecvt_facet.cpp index 731db5656..426372af3 100644 --- a/src/utf8_codecvt_facet.cpp +++ b/src/utf8_codecvt_facet.cpp @@ -1,44 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include - -#define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace program_options { namespace detail { -#define BOOST_UTF8_END_NAMESPACE }}} -#define BOOST_UTF8_DECL -#include -#undef BOOST_UTF8_BEGIN_NAMESPACE -#undef BOOST_UTF8_END_NAMESPACE -#undef BOOST_UTF8_DECL - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#include -#endif // standard library compatibility guard - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Vladimir Prus 2004. @@ -49,9 +15,7 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT #define BOOST_UTF8_BEGIN_NAMESPACE \ namespace boost { namespace program_options { namespace detail { @@ -66,4 +30,13 @@ module boost.program_options; #undef BOOST_UTF8_END_NAMESPACE #undef BOOST_UTF8_DECL +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif + + diff --git a/src/value_semantic.cpp b/src/value_semantic.cpp index 8adc45971..4eea6b4a0 100644 --- a/src/value_semantic.cpp +++ b/src/value_semantic.cpp @@ -1,35 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#include -#endif // standard library compatibility guard - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Vladimir Prus 2004. @@ -40,17 +15,26 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include #include -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT +#endif +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// Declarations the classic build gets transitively through the +// library's own headers (skipped above in this mode). +#include +#include +#endif + // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -60,6 +44,14 @@ import std; #include #endif // standard library compatibility guard +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif + namespace boost { namespace program_options { using namespace std; @@ -477,3 +469,4 @@ namespace boost { namespace program_options { }} + diff --git a/src/variables_map.cpp b/src/variables_map.cpp index 180e78163..9786959a7 100644 --- a/src/variables_map.cpp +++ b/src/variables_map.cpp @@ -1,34 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include -#include - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#endif // standard library compatibility guard - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Vladimir Prus 2002-2004. @@ -39,19 +15,31 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include #include #include #include -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT +#endif + +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// Declarations the classic build gets transitively through the +// library's own headers (skipped above in this mode). +#include +#endif // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +// 'assert' is a macro, which 'import std;' does not provide; keep the +// macro-only header textual in the global module fragment. +#include + +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -59,6 +47,14 @@ import std; #include #endif // standard library compatibility guard +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif + namespace boost { namespace program_options { using namespace std; @@ -293,3 +289,4 @@ namespace boost { namespace program_options { }} + diff --git a/src/winmain.cpp b/src/winmain.cpp index a9c1203fd..6371f8683 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -1,36 +1,10 @@ #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -// In the boost.program_options module build, this translation unit is a -// module implementation unit providing the module-attached definitions -// matching the interface in modules/boost_program_options.cppm. The -// classic code below is compiled unchanged except that its includes are -// skipped: their declarations come from the imported interface, and the -// non-program_options headers are preloaded here instead. +// In the boost.program_options module build, this translation unit is a module +// implementation unit. The global module fragment starts here: the textual +// includes below attach their declarations to the global module, the library's +// own declaration headers are skipped (their declarations come from the +// imported primary interface), and the module declaration closes the fragment. module; - -// Dependencies of the classic code below, preloaded in the global module -// fragment so that nothing foreign is attached to the module. -#include - -// Standard library compatibility guard, following the pattern of -// from boostorg/config PR #535 ("Adds support for -// C++20 modules"). TODO: when that PR is merged, replace the textual -// includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES -#ifndef BOOST_IN_MODULE_PURVIEW -import std; -#endif -#else -#include -#include -#include -#include -#endif // standard library compatibility guard - -module boost.program_options; - -// Purview marker of the boost.program_options module units, per the -// convention used by (boostorg/config PR #535). -#define BOOST_IN_MODULE_PURVIEW #endif // Copyright Vladimir Prus 2002-2004. @@ -41,14 +15,25 @@ module boost.program_options; #ifndef BOOST_PROGRAM_OPTIONS_SOURCE # define BOOST_PROGRAM_OPTIONS_SOURCE #endif +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. #ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT #include -#endif // !BOOST_PROGRAM_OPTIONS_MODULE_UNIT +#endif +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +// Declarations the classic build gets transitively through the +// library's own headers (skipped above in this mode). +#include +#include +#include +#include +#endif + // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#ifdef BOOST_USE_MODULES +#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -56,6 +41,14 @@ import std; #include #endif // standard library compatibility guard +#ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +module boost.program_options; + +// Purview marker of the boost.program_options module units, per the +// convention used by (boostorg/config PR #535). +#define BOOST_IN_MODULE_PURVIEW +#endif + using std::size_t; #ifdef _WIN32 @@ -150,3 +143,4 @@ namespace boost { namespace program_options { #endif + From 15773957f1ba006862ed56417106285ed313ffc8 Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Fri, 23 Oct 2026 14:21:47 +0330 Subject: [PATCH 17/17] Restore convert.cpp's original include order convert.cpp originally included the standard headers before the Boost dependencies; the restructuring had moved them below. Restore the original order: the standard-library guard now sits at the headers' original position with the exact boostorg/config#535 pattern (BOOST_USE_MODULES branch). Because the textual Boost dependency includes follow it, the BOOST_PROGRAM_OPTIONS_USE_STD_MODULE 'import std;' for this file moves into the module closing block (after all textual includes, before the module declaration): MSVC reconciles textual includes followed by an explicit import, but rejects an import followed by textual includes. Validated in fresh build directories: all 15 tests (classic build unchanged), and the module test with textual preloads and with import std. --- src/convert.cpp | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/convert.cpp b/src/convert.cpp index 12ec261d3..b50047bfe 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -13,27 +13,11 @@ module; // or copy at http://www.boost.org/LICENSE_1_0.txt) -#include - -#ifndef BOOST_PROGRAM_OPTIONS_SOURCE -# define BOOST_PROGRAM_OPTIONS_SOURCE -#endif -#include -// The library's own declaration headers are skipped in module builds: -// the imported primary interface provides them. -#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT -#include -#endif -#include -#include - -#include - // Standard library compatibility guard, following the pattern of // from boostorg/config PR #535 ("Adds support for // C++20 modules"). TODO: when that PR is merged, replace the textual // includes with (see modules/boost_program_options.cppm). -#if defined(BOOST_USE_MODULES) || defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) +#ifdef BOOST_USE_MODULES #ifndef BOOST_IN_MODULE_PURVIEW import std; #endif @@ -47,7 +31,30 @@ import std; #include #endif // standard library compatibility guard +#include + +#ifndef BOOST_PROGRAM_OPTIONS_SOURCE +# define BOOST_PROGRAM_OPTIONS_SOURCE +#endif +#include +// The library's own declaration headers are skipped in module builds: +// the imported primary interface provides them. +#ifndef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +#include +#endif +#include +#include + +#include + #ifdef BOOST_PROGRAM_OPTIONS_MODULE_UNIT +#if defined(BOOST_PROGRAM_OPTIONS_USE_STD_MODULE) +// The standard module declarations: like the other module units, this one +// needs an explicit 'import std;' after its textual includes (MSVC requires +// textual includes before the import), and this file's standard headers sit +// above the Boost dependencies, so the import is issued here. +import std; +#endif module boost.program_options; // Purview marker of the boost.program_options module units, per the