Visitor extensions#31
Merged
Merged
Conversation
- Add has_any_visitor_event<G,V> — disjunction of all 19 has_on_* concepts
- Add valid_visitor<G,V> — satisfied by empty_visitor or any visitor with at
least one recognised on_* callback; rejects structs whose only on_*-like
methods are misspelled and would otherwise be silently ignored
- Add #include <concepts> and <type_traits> to traversal_common.hpp
- Enforce valid_visitor via static_assert at the top of the implementing body
of bfs, dfs, dijkstra and bellman_ford; message directs user to the typo
and the empty_visitor{} escape hatch
- Add compile-time static_assert tests in test_breadth_first_search.cpp
covering empty_visitor (pass), a correct visitor (pass), and a typo
visitor (fail)
BGL-style composable visitors built on the existing duck-typed on_* model, without changing any traversal algorithm. Layer 1 — single-event adaptors (on_discover_vertex(f), on_tree_edge(f), ...): wrap a callable so it fires for exactly one event; analogue of BGL event tags. Generated for all 14 event names (5 vertex + 9 edge) via a macro. Layer 2 — composite_visitor / make_visitor(...): fan one traversal out to many sub-visitors. Each event method is constrained by a fold over the child pack, so a composite only exposes on_X when a child handles X — keeping has_on_* and valid_visitor detection accurate and preserving zero-overhead event skipping. Bridges descriptor- and id-form children from a single event via vertex_id(). Layer 3 — prebuilt recorders: predecessor_recorder, distance_recorder (weighted + hop-count overloads) and time_stamper. Each returns a plain (g,x)->void callable so the caller binds it to any event, e.g. on_tree_edge(predecessor_recorder(pred)) for BFS/DFS or on_edge_relaxed(predecessor_recorder(pred)) for Dijkstra/Bellman-Ford. - Register header in graph/algorithms.hpp umbrella - Add tests/algorithms/test_visitor_factory.cpp (compile-time valid_visitor / has_on_* integration checks + runtime BFS/DFS/Dijkstra coverage) - Wire test file into tests/algorithms/CMakeLists.txt
…tegy.md visitor_factory.hpp: Add '@Par BGL Comparison' section to the file-level Doxygen block showing BGL make_bfs_visitor syntax vs. graph-v3 make_visitor, plus a bullet list of four key design differences. bgl_migration_strategy.md: Update Section 7 'Visitor Pattern Migration' to replace the 'Composable Visitor Adaptors — Gap (still open)' subsection with full documentation of the three-layer toolkit (single-event adaptors, make_visitor, prebuilt recorders), the BGL vs. graph-v3 syntax comparison, and a per-recorder event-binding table. Also update the Key Differences table, Executive Summary gaps list, Phase 3 roadmap table, and 'Done' note. Bump last-reviewed date to 2026-05-30.
…isitor_factory Local variable 'edges' at lines 75 and 92 shadowed graph::adj_list::_cpo_instances::edges (graph_cpo.hpp:816). Clang on macOS/CI treats -Wshadow as -Werror.
…extensions branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.