Skip to content

Replace BOOST_FOREACH with range-based for in example/graph-thingie.cpp - #607

Merged
Becheler merged 1 commit into
boostorg:developfrom
reach2sayan:foreach/graph-thingie
Sep 26, 2026
Merged

Becheler merged 1 commit into
boostorg:developfrom
reach2sayan:foreach/graph-thingie

Conversation

@reach2sayan

Copy link
Copy Markdown
Contributor

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

Replaces the single BOOST_FOREACH loop in example/graph-thingie.cpp (over vertices(graph)) with range-based for.
vertices() returns a std::pair of iterators, so the range is wrapped in boost::make_iterator_range(...).
#include <boost/foreach.hpp> becomes
#include <boost/range/iterator_range.hpp>.

The loop variable keeps its explicit type (graph_t::vertex_descriptor) and the loop body is unchanged. Example only; no library code is touched.

Motivation

Refs #593 (task 1.3, "BOOST_FOREACH to range-based for"), item
example/graph-thingie.cpp. Same approach as #603 and #604.

Testing

  • b2 graph-thingie, b2 cxxstd=20 graph-thingie (gcc 13) and b2 toolset=clang cxxstd=17 graph-thingie (clang 18) from libs/graph/example on Linux: all
    passed.
  • Standalone builds with -Wall -Wextra at C++14/17/20/23 on gcc 13 and clang 18:
    zero warnings.
  • Program output is byte-for-byte identical to the develop version at every standard
    on both compilers, including the vertex a (NODE_A) / vertex b (NODE_B) / vertex c () lines printed by the converted loop.

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.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Boost dependency footprint vs develop (auto-generated).
PR run 36272627641 vs develop run 36267169530 (192743b0b6).

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

No header-inclusion-weight changes.

Transitive Boost modules: 47 → 47 (0)

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Compiler-warning counts vs develop (auto-generated).
PR run 36272627653 vs develop run 36267169535 (192743b0b6).

Job Baseline After Delta
macos (clang, 14) 392 392 0
macos (clang, 17) 391 391 0
macos (clang, 20) 391 391 0
ubuntu (clang-19, 14) 392 392 0
ubuntu (clang-19, 17) 391 391 0
ubuntu (clang-19, 20) 391 391 0
ubuntu (clang-19, 23) 391 391 0
ubuntu (gcc-14, 14) 345 345 0
ubuntu (gcc-14, 17) 341 341 0
ubuntu (gcc-14, 20) 341 341 0
ubuntu (gcc-14, 23) 341 341 0
windows_msvc_14_3 (msvc-14.3) 931 931 0

@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@reach2sayan
reach2sayan marked this pull request as ready for review September 26, 2026 22:05
@Becheler

Becheler commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks again @reach2sayan !

One minor remark is to reduce the verbosity of such future PRs.

The git diff is very small/straightforward but the PR description makes it look like a serious change where reviewers must pay attention and read all the PR description :)

AI is pretty verbose and loves to generate text, so finding the right level of verbosity can be tricky!

Thanks again!

@Becheler
Becheler merged commit baa1fe0 into boostorg:develop Sep 26, 2026
32 checks passed
@reach2sayan

Copy link
Copy Markdown
Contributor Author

Thanks again @reach2sayan !

One minor remark is to reduce the verbosity of such future PRs.

The git diff is very small/straightforward but the PR description makes it look like a serious change where reviewers must pay attention and read all the PR description :)

AI is pretty verbose and loves to generate text, so finding the right level of verbosity can be tricky!

Thanks again!

This is funny. This was the one bit that was totally me :p (painstakingly marking the x's) 😂. I thought that was a bgl standard. I was getting tired of that NGL 😂
I'll gladly right more succinct desc.

@reach2sayan
reach2sayan deleted the foreach/graph-thingie branch September 26, 2026 23:07
@Becheler

Copy link
Copy Markdown
Collaborator

Ahaha we do scan the crossed boxes ! It helps knowing what the expectations are (if there is a behavior change when the x shows refactor, then we can assume it's a mistake and flag it).

I was mostly speaking about this part, that can be much lighter as CI and bots will show us the required information!

b2 graph-thingie, b2 cxxstd=20 graph-thingie (gcc 13) and b2 toolset=clang cxxstd=17 graph-thingie (clang 18) from libs/graph/example on Linux: all
passed.
Standalone builds with -Wall -Wextra at C++14/17/20/23 on gcc 13 and clang 18:
zero warnings.
Program output is byte-for-byte identical to the develop version at every standard
on both compilers, including the vertex a (NODE_A) / vertex b (NODE_B) / vertex c () lines printed by the converted loop.

For short PRs, the "change summary" section may end up more verbose than the actual file diff, so no worries we will be happy with a "refactor BOOST_FOREACH in file xxx" 🤗

It's useful for more complex PRs with many changes when reviewers may need a high level vision on how the changes are related and why 🙃 or to show local benchmarks results

@Becheler Becheler added beginner friendly technical debt Code that works but needs refactoring, cleanup, or modernization. Not user-facing. labels Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginner friendly 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