Skip to content

C++20 module support #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 84 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
8a4416f
Initial implementation
anarthal Dec 22, 2024
da9305f
check_cmake_version
anarthal Dec 22, 2024
3808ec9
mp_size
anarthal Dec 22, 2024
904ee5d
detail/modules.hpp
anarthal Dec 22, 2024
7249a36
mp_size_2
anarthal Dec 22, 2024
7da0531
Use CMake helper function
anarthal Dec 22, 2024
224e8e7
Temporarily comment tests
anarthal Dec 22, 2024
c86e5a0
Recovered 10 more tests
anarthal Dec 22, 2024
ebdb3c4
Rename module to boost_xxx.cpppm
anarthal Dec 30, 2024
97e83bc
BASE_DIRS
anarthal Dec 30, 2024
2d0cd75
extern C++
anarthal Dec 30, 2024
3bf2419
Rename config macro to BOOST_USE_MODULES
anarthal Dec 30, 2024
05d398e
Tests: list that don't require ifdefs
anarthal Jan 1, 2025
df6c026
Missing exports in bind and mp_plus
anarthal Jan 1, 2025
252ddc7
Tests: algorithm 1
anarthal Jan 1, 2025
4283284
Finished list tests
anarthal Jan 1, 2025
a792291
Algorithm tests 2
anarthal Jan 1, 2025
8354e2c
Non-cmake algorithm test
anarthal Jan 1, 2025
40165f8
tests: integral
anarthal Jan 1, 2025
a7f9b00
Tests: compile
anarthal Jan 1, 2025
ed0935f
Utility tests
anarthal Jan 1, 2025
23871f8
Integer sequence tests
anarthal Jan 1, 2025
e4294bc
Missing exports in tuple
anarthal Jan 1, 2025
13c3bce
Tests: tuple
anarthal Jan 1, 2025
9f7574d
Set modularization and tests
anarthal Jan 1, 2025
36f58d0
Tests: function
anarthal Jan 1, 2025
f4c4e60
Map tests and modularization
anarthal Jan 1, 2025
8057e78
Bind tests
anarthal Jan 1, 2025
561cf44
Lambda tests and modularization
anarthal Jan 1, 2025
df2c079
Version tests
anarthal Jan 1, 2025
c35971e
Move away from BOOST_MODULE_EXPORT
anarthal Jan 3, 2025
87b5093
Follow format conventions
anarthal Jan 3, 2025
0db3440
CI prototype
anarthal Jan 3, 2025
9259563
force CI run
anarthal Jan 3, 2025
d40a6e0
Incorrect script path
anarthal Jan 3, 2025
7e06b93
Incorrect script path (2)
anarthal Jan 3, 2025
7c9f142
Added some modules CIs
anarthal Jan 3, 2025
2cace6f
Experiment with null container
anarthal Jan 6, 2025
71cfe04
Install packages
anarthal Jan 6, 2025
27c0e8f
Missing git and flags
anarthal Jan 6, 2025
ad34be9
Missing ca-certificates
anarthal Jan 6, 2025
3ec117b
Missing python
anarthal Jan 6, 2025
4981334
Update remotes and install fixes
anarthal Jan 6, 2025
4dc9e3e
Move away from boost_set_cxx20_module_settings
anarthal Jan 6, 2025
965e512
Missing export in CI
anarthal Jan 6, 2025
269a621
Guards for add_subdir/install tests
anarthal Jan 6, 2025
417c6dd
Increase max cmake version of tests
anarthal Jan 6, 2025
78d9ef2
Recover the other posix flows
anarthal Jan 6, 2025
efe931b
Add Windows CMake add_subdirectory for modules
anarthal Jan 6, 2025
2a2a64b
Incorrect matrix reference
anarthal Jan 6, 2025
1369aa5
Remove install packages condition
anarthal Jan 6, 2025
de4b613
Add call to vcvarsall
anarthal Jan 6, 2025
1ef600d
add cmd /c
anarthal Jan 6, 2025
8b55719
Replace /c by /k
anarthal Jan 6, 2025
a3daecc
Move cmd /k location
anarthal Jan 6, 2025
d28ed4b
Attempt with call
anarthal Jan 6, 2025
8b67df4
Windows install modules
anarthal Jan 6, 2025
05ead52
Missing vcvarsall calls
anarthal Jan 6, 2025
38dfa0f
Run tests Windows
anarthal Jan 6, 2025
63dce8f
Missing cmake args
anarthal Jan 6, 2025
fd36f27
Missing __scope in header-only build
anarthal Jan 6, 2025
442ee2d
Missing -DBOOST_USE_MODULES=1
anarthal Jan 6, 2025
478901d
Separate Posix add_subdirectory workflow
anarthal Jan 6, 2025
38f54bc
Install workflow for modules in posix
anarthal Jan 6, 2025
e950579
Posix cmake test with modules
anarthal Jan 6, 2025
037fc1c
Missing BOOST_USE_MODULES
anarthal Jan 6, 2025
89b6066
Cleanup and recover all module builds
anarthal Jan 6, 2025
413faae
Recover the other builds
anarthal Jan 6, 2025
0b2f029
Cleanup existing workflows
anarthal Jan 6, 2025
810f292
Missing clone of Boost.Build
anarthal Jan 6, 2025
3f98b3b
Missing boost_install
anarthal Jan 6, 2025
d05eaaf
Recover depinst
anarthal Jan 7, 2025
2aff610
Update setup script
anarthal Jan 7, 2025
87fd498
Experiment with export using
anarthal Jan 7, 2025
9e36eb3
Experiment with import in GMF
anarthal Jan 10, 2025
e7fe52a
Export using cleanup
anarthal Jan 10, 2025
bd86b4d
Merge branch 'develop' into feature/cxx20-modules
anarthal Jan 11, 2025
268f361
Modularize mp_from_sequence_3
anarthal Jan 11, 2025
76759bd
Recover all CIs
anarthal Jan 11, 2025
ea45418
Fix standalone CMake
anarthal Jan 11, 2025
f6cd1d7
Guard cmake_policy
anarthal Jan 12, 2025
e19dc20
Migrate the library to use compatibility headers
anarthal Jan 15, 2025
62be460
Migrate tests to compatibility headers
anarthal Jan 15, 2025
c4ba590
Missing detail/config include in tuple_transform_2
anarthal Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
326 changes: 322 additions & 4 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

27 changes: 23 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,37 @@
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

cmake_minimum_required(VERSION 3.5...3.16)
cmake_minimum_required(VERSION 3.5...3.31)

project(boost_mp11 VERSION 1.88.0 LANGUAGES CXX)

add_library(boost_mp11 INTERFACE)
if (BOOST_USE_MODULES)
add_library(boost_mp11 STATIC)
target_sources(boost_mp11 PUBLIC FILE_SET CXX_MODULES BASE_DIRS modules FILES modules/boost_mp11.cppm)
set(__scope PUBLIC)

# Enable and propagate C++23, import std, and the modules macro
target_compile_features(boost_mp11 PUBLIC cxx_std_23)
set_target_properties(boost_mp11 PROPERTIES CXX_MODULE_STD 1)
target_compile_definitions(boost_mp11 PUBLIC BOOST_USE_MODULES)

else()
add_library(boost_mp11 INTERFACE)
target_compile_features(boost_mp11 INTERFACE cxx_alias_templates cxx_variadic_templates cxx_decltype)
set(__scope INTERFACE)
endif()

add_library(Boost::mp11 ALIAS boost_mp11)
target_include_directories(boost_mp11 ${__scope} include)

target_include_directories(boost_mp11 INTERFACE include)
target_compile_features(boost_mp11 INTERFACE cxx_alias_templates cxx_variadic_templates cxx_decltype)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

# Required to call deprecated FetchContent_Populate
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.30.0")
cmake_policy(SET CMP0169 OLD)
endif()

# Fetch support files

message(STATUS "Fetching BoostFetch.cmake")
Expand Down
13 changes: 11 additions & 2 deletions include/boost/mp11/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
import boost.mp11;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Say, if another library includes multiple MP11 headers and thus produces multiple import statements. Would this be harmful in any way? For example, would this affect compilation performance? Would it make sense to move the above two lines in a separate internal header with its own include guard, so that only one import is produced, no matter how many interface headers are included?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is any performance penalty in importing several times.


#else

#include <boost/mp11/list.hpp>
#include <boost/mp11/set.hpp>
#include <boost/mp11/integral.hpp>
Expand All @@ -23,8 +30,8 @@
#include <boost/mp11/detail/mp_remove_if.hpp>
#include <boost/mp11/detail/config.hpp>
#include <boost/mp11/integer_sequence.hpp>
#include <type_traits>
#include <utility>
#include <boost/mp11/detail/std/type_traits.hpp>
#include <boost/mp11/detail/std/utility.hpp>

#if defined(_MSC_VER) || defined(__GNUC__)
# pragma push_macro( "I" )
Expand Down Expand Up @@ -1350,4 +1357,6 @@ template<class L, class S> using mp_join = mp_apply<mp_append, mp_intersperse<L,
# pragma pop_macro( "I" )
#endif

#endif

#endif // #ifndef BOOST_MP11_ALGORITHM_HPP_INCLUDED
11 changes: 10 additions & 1 deletion include/boost/mp11/bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
import boost.mp11;

#else

#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/utility.hpp>
#include <cstddef>
#include <boost/mp11/detail/std/cstddef.hpp>

#if defined(_MSC_VER) || defined(__GNUC__)
# pragma push_macro( "I" )
Expand Down Expand Up @@ -117,4 +124,6 @@ template<class Q, class... T> using mp_bind_q = mp_bind<Q::template fn, T...>;
# pragma pop_macro( "I" )
#endif

#endif

#endif // #ifndef BOOST_MP11_BIND_HPP_INCLUDED
2 changes: 1 addition & 1 deletion include/boost/mp11/detail/mp_plus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// http://www.boost.org/LICENSE_1_0.txt

#include <boost/mp11/detail/config.hpp>
#include <type_traits>
#include <boost/mp11/detail/std/type_traits.hpp>

namespace boost
{
Expand Down
2 changes: 1 addition & 1 deletion include/boost/mp11/detail/mp_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// https://www.boost.org/LICENSE_1_0.txt

#include <boost/mp11/detail/config.hpp>
#include <type_traits>
#include <boost/mp11/detail/std/type_traits.hpp>

#if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)

Expand Down
4 changes: 2 additions & 2 deletions include/boost/mp11/detail/mp_with_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include <boost/mp11/integral.hpp>
#include <boost/mp11/detail/config.hpp>
#include <type_traits>
#include <utility>
#include <boost/mp11/detail/std/type_traits.hpp>
#include <boost/mp11/detail/std/utility.hpp>
#include <cassert>

#if defined( BOOST_MP11_HAS_CXX14_CONSTEXPR )
Expand Down
5 changes: 5 additions & 0 deletions include/boost/mp11/detail/std/cstddef.hpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, this sort of files should be made common, in a separate internal Boost library.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are in my Boost.Config branch (https://github.com/anarthal/config/tree/feature/cxx20-modules), but MP11 is supposed to have zero Boost dependencies, so some of them have been copied here. The Boost.Charconv PR uses the ones in Boost.Config.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, I have a better idea of how this could be implemented, that does not require creating headers like this. See here.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifdef BOOST_USE_MODULES
import std;
#else
#include <cstddef>
#endif
5 changes: 5 additions & 0 deletions include/boost/mp11/detail/std/tuple.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifdef BOOST_USE_MODULES
import std;
#else
#include <tuple>
#endif
5 changes: 5 additions & 0 deletions include/boost/mp11/detail/std/type_traits.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifdef BOOST_USE_MODULES
import std;
#else
#include <type_traits>
#endif
5 changes: 5 additions & 0 deletions include/boost/mp11/detail/std/utility.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifdef BOOST_USE_MODULES
import std;
#else
#include <utility>
#endif
11 changes: 10 additions & 1 deletion include/boost/mp11/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
import boost.mp11;

#else

#include <boost/mp11/integral.hpp>
#include <boost/mp11/utility.hpp>
#include <boost/mp11/detail/mp_list.hpp>
Expand All @@ -16,7 +23,7 @@
#include <boost/mp11/detail/mp_min_element.hpp>
#include <boost/mp11/detail/mp_void.hpp>
#include <boost/mp11/detail/config.hpp>
#include <type_traits>
#include <boost/mp11/detail/std/type_traits.hpp>

namespace boost
{
Expand Down Expand Up @@ -219,4 +226,6 @@ template<class T1, class... T> using mp_max = mp_max_element<mp_list<T1, T...>,
} // namespace mp11
} // namespace boost

#endif

#endif // #ifndef BOOST_MP11_FUNCTION_HPP_INCLUDED
11 changes: 10 additions & 1 deletion include/boost/mp11/integer_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
#include <cstddef>
import boost.mp11;

#else

#include <boost/mp11/version.hpp>
#include <boost/mp11/detail/std/cstddef.hpp>

#if defined(_MSC_VER) || defined(__GNUC__)
# pragma push_macro( "I" )
Expand Down Expand Up @@ -118,4 +125,6 @@ template<class... T> using index_sequence_for = make_integer_sequence<std::size_
# pragma pop_macro( "I" )
#endif

#endif

#endif // #ifndef BOOST_MP11_INTEGER_SEQUENCE_HPP_INCLUDED
13 changes: 11 additions & 2 deletions include/boost/mp11/integral.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
import boost.mp11;

#else

#include <boost/mp11/version.hpp>
#include <boost/mp11/detail/mp_value.hpp>
#include <type_traits>
#include <cstddef>
#include <boost/mp11/detail/std/type_traits.hpp>
#include <boost/mp11/detail/std/cstddef.hpp>

#if defined(_MSC_VER) || defined(__GNUC__)
# pragma push_macro( "I" )
Expand Down Expand Up @@ -48,4 +55,6 @@ template<std::size_t N> using mp_size_t = std::integral_constant<std::size_t, N>
# pragma pop_macro( "I" )
#endif

#endif

#endif // #ifndef BOOST_MP11_INTEGRAL_HPP_INCLUDED
13 changes: 11 additions & 2 deletions include/boost/mp11/lambda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
import boost.mp11;

#else

#include <boost/mp11/detail/config.hpp>

#if BOOST_MP11_WORKAROUND(BOOST_MP11_MSVC, <= 1800)
Expand All @@ -17,8 +24,8 @@
#else

#include <boost/mp11/bind.hpp>
#include <cstddef>
#include <type_traits>
#include <boost/mp11/detail/std/cstddef.hpp>
#include <boost/mp11/detail/std/type_traits.hpp>

#if defined(_MSC_VER) || defined(__GNUC__)
# pragma push_macro( "I" )
Expand Down Expand Up @@ -196,4 +203,6 @@ template<template <class...> class C, class... Ts> struct lambda_impl<C<Ts...>>

#endif // mp_lambda supported

#endif

#endif // #ifndef BOOST_MP11_LAMBDA_HPP_INCLUDED
11 changes: 10 additions & 1 deletion include/boost/mp11/list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
import boost.mp11;

#else

#include <boost/mp11/integral.hpp>
#include <boost/mp11/detail/mp_list.hpp>
#include <boost/mp11/detail/mp_list_v.hpp>
Expand All @@ -17,7 +24,7 @@
#include <boost/mp11/detail/mp_rename.hpp>
#include <boost/mp11/detail/mp_append.hpp>
#include <boost/mp11/detail/config.hpp>
#include <type_traits>
#include <boost/mp11/detail/std/type_traits.hpp>

#if defined(_MSC_VER) || defined(__GNUC__)
# pragma push_macro( "I" )
Expand Down Expand Up @@ -478,4 +485,6 @@ template<class L, class Q> using mp_transform_third_q = mp_transform_third<L, Q:
# pragma pop_macro( "I" )
#endif

#endif

#endif // #ifndef BOOST_MP11_LIST_HPP_INCLUDED
11 changes: 10 additions & 1 deletion include/boost/mp11/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
import boost.mp11;

#else

#include <boost/mp11/detail/mp_map_find.hpp>
#include <boost/mp11/list.hpp>
#include <boost/mp11/integral.hpp>
#include <boost/mp11/utility.hpp>
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/function.hpp>
#include <boost/mp11/set.hpp>
#include <type_traits>
#include <boost/mp11/detail/std/type_traits.hpp>

namespace boost
{
Expand Down Expand Up @@ -116,4 +123,6 @@ template<class M> using mp_is_map = typename detail::mp_is_map_impl<M>::type;
} // namespace mp11
} // namespace boost

#endif

#endif // #ifndef BOOST_MP11_MAP_HPP_INCLUDED
9 changes: 9 additions & 0 deletions include/boost/mp11/mpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
import boost.mp11;

#else

#include <boost/mp11/mpl_list.hpp>
#include <boost/mp11/mpl_tuple.hpp>

#endif

#endif // #ifndef BOOST_MP11_MPL_HPP_INCLUDED
9 changes: 9 additions & 0 deletions include/boost/mp11/mpl_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
import boost.mp11;

#else

#include <boost/mp11/detail/mpl_common.hpp>

namespace boost
Expand All @@ -25,4 +32,6 @@ template<class... T> struct sequence_tag<mp11::mp_list<T...>>
} // namespace mpl
} // namespace boost

#endif

#endif // #ifndef BOOST_MP11_MPL_LIST_HPP_INCLUDED
11 changes: 10 additions & 1 deletion include/boost/mp11/mpl_tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt

#if defined(BOOST_USE_MODULES) && !defined(BOOST_MP11_INTERFACE_UNIT)

#include <boost/mp11/version.hpp>
import boost.mp11;

#else

#include <boost/mp11/detail/mpl_common.hpp>
#include <tuple>
#include <boost/mp11/detail/std/tuple.hpp>

namespace boost
{
Expand All @@ -26,4 +33,6 @@ template<class... T> struct sequence_tag<std::tuple<T...>>
} // namespace mpl
} // namespace boost

#endif

#endif // #ifndef BOOST_MP11_MPL_TUPLE_HPP_INCLUDED
Loading
Loading