From b3cb64738bd1b873ec25a63f84e23050023b353b Mon Sep 17 00:00:00 2001 From: Arnaud Becheler <8360330+Becheler@users.noreply.github.com> Date: Fri, 17 Jul 2026 10:58:26 +0200 Subject: [PATCH] refactor: remove dependency on boost.tti using detector idiom --- CMakeLists.txt | 1 - build.jam | 1 - include/boost/graph/depth_first_search.hpp | 32 ++++++++++++---------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf2e99fbc..4099ab75e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,6 @@ target_link_libraries(boost_graph Boost::smart_ptr Boost::spirit Boost::throw_exception - Boost::tti Boost::tuple Boost::type_traits Boost::unordered diff --git a/build.jam b/build.jam index c8f1b19af..511c1c7af 100644 --- a/build.jam +++ b/build.jam @@ -35,7 +35,6 @@ constant boost_dependencies : /boost/smart_ptr//boost_smart_ptr /boost/spirit//boost_spirit /boost/throw_exception//boost_throw_exception - /boost/tti//boost_tti /boost/tuple//boost_tuple /boost/type_traits//boost_type_traits /boost/unordered//boost_unordered diff --git a/include/boost/graph/depth_first_search.hpp b/include/boost/graph/depth_first_search.hpp index b42666cab..7b354c499 100644 --- a/include/boost/graph/depth_first_search.hpp +++ b/include/boost/graph/depth_first_search.hpp @@ -24,7 +24,8 @@ #include #include #include -#include +#include +#include #include #include @@ -68,7 +69,19 @@ namespace detail } }; - BOOST_TTI_HAS_MEMBER_FUNCTION(finish_edge) + // has_finish_edge::value is true when vis.finish_edge(e, g) is + // a valid call for e of type E and g of type const G&. + template < typename Vis, typename E, typename G, typename = void > + struct has_finish_edge : std::false_type + { + }; + template < typename Vis, typename E, typename G > + struct has_finish_edge< Vis, E, G, + boost::void_t< decltype(std::declval< Vis& >().finish_edge( + std::declval< E& >(), std::declval< const G& >())) > > + : std::true_type + { + }; template < bool IsCallable > struct do_call_finish_edge { @@ -89,18 +102,9 @@ namespace detail template < typename E, typename G, typename Vis > void call_finish_edge(Vis& vis, E e, const G& g) - { // Only call if method exists -#if ((defined(__GNUC__) && (__GNUC__ > 4) \ - || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9))) \ - || defined(__clang__) \ - || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1200))) - do_call_finish_edge< has_member_function_finish_edge< Vis, void, - boost::mpl::vector< E, const G& > >::value >::call_finish_edge(vis, - e, g); -#else - do_call_finish_edge< has_member_function_finish_edge< Vis, - void >::value >::call_finish_edge(vis, e, g); -#endif + { // Only call if the visitor has a callable finish_edge(e, g) + do_call_finish_edge< has_finish_edge< Vis, E, G >::value >:: + call_finish_edge(vis, e, g); } // Define BOOST_RECURSIVE_DFS to use older, recursive version.