Skip to content

Migrate public traits from MPL to STL (breaking change)#530

Open
Becheler wants to merge 2 commits into
boostorg:developfrom
Becheler:refactor/mpl-public-traits-to-std
Open

Migrate public traits from MPL to STL (breaking change)#530
Becheler wants to merge 2 commits into
boostorg:developfrom
Becheler:refactor/mpl-public-traits-to-std

Conversation

@Becheler

@Becheler Becheler commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Reduce the number of MPL dependencies. Probably not relevant for 1.92 given how late we are in the cycle.

Before submitting

  • This PR targets the develop branch.
  • I searched for an existing PR or issue covering the same change.
  • My contribution is licensed under the Boost Software License 1.0.

Type of change

  • Bug fix
  • New feature or API addition
  • Refactor (no behavior change)
  • Documentation
  • Build, CI, or tooling
  • [] Other (specify below)

Does this PR introduce a breaking change?

  • Yes (describe migration impact below)

  • No

  • Patterns that break (all need the same two things at once: an overload set keyed on the exact mpl:: type, fed a BGL trait's ::type, which is the type that changed):

    • mpl::true_/mpl::false_ overloads driven by a BGL trait's ::type. The tag no longer matches the overload:
      • Ex: f(typename is_directed_graph<G>::type()) against void f(mpl::true_) / void f(mpl::false_).
    • Exact-type checks
      • Ex: static_assert(is_same<is_directed_graph<G>::type, mpl::true_>::value).
    • Template specializations keyed on mpl::true_/mpl::false_ that are instantiated with a BGL trait's ::type.
  • Patterns that still work:

    • Anything reading ::value (overwhelming majority ?)
      • Ex: if (is_directed_graph<G>::value)
      • Ex: if constexpr (is_directed_graph<G>::value)
    • Feeding the trait into mpl::if_ / mpl::and_ / mpl::not_ and similar. Those read ::value, so std::integral_constant works.
    • Overloads that take a generic template<class B> parameter and read B::value instead of matching a concrete tag type.
    • Overloads already written on std::true_type / std::false_type. Before this change they would have had to convert first.

What this PR does

Converts Boost.Graph's public traits from Boost.MPL to standard <type_traits>. This is a breaking change: the traits now derive from std::integral_constant / std::true_type / std::false_type instead of boost::mpl::bool_ / true_ / false_.

  • graph_selectors.hpp: directedS/undirectedS/bidirectionalS's is_directed_t and is_bidir_t now std::true_type/std::false_type.
  • graph_traits.hpp: is_directed_graph, is_undirected_graph, is_multigraph, is_incidence/bidirectional/vertex_list/edge_list_graph, is_adjacency_matrix, is_directed_uni/bidirectional_graph, has_*_property, has_bundled_*, and is_no_bundle now derive from std::integral_constant (file MPL-free)
  • graph_mutability_traits.hpp: the whole graph_has_* and is_mutable_* family now derive from std::integral_constant (file MPL-free)
  • reverse_graph.hpp: is_reverse_graph now std::true_type/std::false_type; internal mpl::if_ to std::conditional (file MPL-free)
  • labeled_graph_traits.hpp: converted the labeled mutability traits (graph_has_*_by_label, is_labeled_mutable_*) and determine_mutability from mpl::bool_/and_/if_ to std::integral_constant/std::conditional, (file MPL-free)
  • pending/property.hpp: has_property and is_no_property now on std; internal mpl::if_ to std::conditional.
  • test/: test_direction, test_properties, test_construction, test_destruction update their tag-dispatch overloads from boost::mpl::true_/false_ to std::true_type/std::false_type to match the new trait types.
  • adjacency_list.hpp: converted is_random_access and is_distributed_selector from mpl::true_/false_ to std::true_type/false_type making public adjacency_list_traits::is_rand_access a std type.

Motivation

Reduce the number of MPL dependencies.

Testing

Checklist

  • Existing tests pass (b2 in the test/ directory).
  • New behavior is covered by a test, or this is a docs / build / refactor change.
  • Documentation was updated if user-facing behavior changed.
  • No new compiler warnings on the platforms I built against.

@Becheler Becheler self-assigned this Jul 17, 2026
@Becheler Becheler added the technical debt Code that works but needs refactoring, cleanup, or modernization. Not user-facing. label Jul 17, 2026
@Becheler Becheler changed the title Refactor/mpl public traits to std Migrate public traits from MPL to STL (breaking change) Jul 17, 2026
@Becheler
Becheler force-pushed the refactor/mpl-public-traits-to-std branch from 6355cb7 to 03c418a Compare July 17, 2026 07:47
@Becheler
Becheler force-pushed the refactor/mpl-public-traits-to-std branch from 03c418a to c9ce317 Compare July 17, 2026 08:23
@github-actions

Copy link
Copy Markdown

Boost dependency footprint vs develop (auto-generated).
PR run 29566287405 vs develop run 29503421582 (c9ce31788e).

Header-inclusion weights (graph files pulling each direct dependency in):

Dependency develop PR Δ
mpl 30 26 -4

Transitive Boost modules: 69 → 69 (0)

@Becheler
Becheler marked this pull request as ready for review July 17, 2026 09:58
@Becheler
Becheler requested a review from jeremy-murphy as a code owner July 17, 2026 09:58
@github-actions

Copy link
Copy Markdown

Compiler-warning counts vs develop (auto-generated).
PR run 29566287403 vs develop run 29503421610 (c9ce31788e).

Job Baseline After Delta
macos (clang, 14) 4 4 0
macos (clang, 17) 4 4 0
macos (clang, 20) 4 4 0
ubuntu (clang-19, 14) 4 4 0
ubuntu (clang-19, 17) 4 4 0
ubuntu (clang-19, 20) 4 4 0
ubuntu (clang-19, 23) 4 4 0
ubuntu (gcc-14, 14) 10 10 0
ubuntu (gcc-14, 17) 10 10 0
ubuntu (gcc-14, 20) 10 10 0
ubuntu (gcc-14, 23) 10 10 0
windows_msvc_14_3 (msvc-14.3) 971 971 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

technical debt Code that works but needs refactoring, cleanup, or modernization. Not user-facing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant