Skip to content

fix: remove dependency to MPL in graph_traits using detector idiom#528

Merged
Becheler merged 1 commit into
boostorg:developfrom
Becheler:refactor/graph-traits-void-t-detector
Jul 16, 2026
Merged

fix: remove dependency to MPL in graph_traits using detector idiom#528
Becheler merged 1 commit into
boostorg:developfrom
Becheler:refactor/graph-traits-void-t-detector

Conversation

@Becheler

@Becheler Becheler commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Reducing dependencies to MPL is important for compile time, dependency graph and general hygiene, as similar behavior is available with modern C++.

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

What this PR does

graph_traits reports a graph's associated types (vertex type, edge type...). Not every graph defines all of them, so graph_traits needs to check if a member type exists on the graph, use it if it does, and fall back to void if it doesn't.

That check was built with Boost.MPL. It used BOOST_MPL_HAS_XXX_TRAIT_DEF macro to generate a "has member X" trait, then mpl::eval_if and mpl::identity to pick either the member or the fallback. This pulled in five boost/mpl headers just to answer "does this type have member X".

This PR refactors it using standard C++ void_t detector idiom. Two small template overloads do the check directly: one matches when the member type exists and exposes it, the other is the fallback. Same result, no MPL, no new dependency, behavior is unchanged.

Motivation

Reducing dependencies to MPL is important for compile time, dependency graph and general hygiene, as similar behavior is available with modern C++.

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 16, 2026
@Becheler Becheler added the technical debt Code that works but needs refactoring, cleanup, or modernization. Not user-facing. label Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

Boost dependency footprint vs develop (auto-generated).
PR run 29494708403 vs develop run 29397385834 (479ee6f1df).

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

No header-inclusion-weight changes.

Transitive Boost modules: 70 → 70 (0)

@Becheler
Becheler force-pushed the refactor/graph-traits-void-t-detector branch from 227c2d4 to 479ee6f Compare July 16, 2026 11:30
@github-actions

Copy link
Copy Markdown

Compiler-warning counts vs develop (auto-generated).
PR run 29494708516 vs develop run 29397386211 (479ee6f1df).

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

@Becheler
Becheler marked this pull request as ready for review July 16, 2026 13:14
@Becheler
Becheler requested a review from jeremy-murphy as a code owner July 16, 2026 13:14
@jeremy-murphy

Copy link
Copy Markdown
Collaborator

Looks good.

@Becheler
Becheler merged commit 1576c02 into boostorg:develop Jul 16, 2026
28 checks passed
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.

2 participants