diff --git a/include/graph/views/breadth_first_search.hpp b/include/graph/views/breadth_first_search.hpp index 6b8f589..8d86224 100644 --- a/include/graph/views/breadth_first_search.hpp +++ b/include/graph/views/breadth_first_search.hpp @@ -674,93 +674,92 @@ class edges_breadth_first_search_view : public bfs_base namespace views { -// -// vertices_breadth_first_search(g,seed) -> vertex_descriptor[vid,v] -// vertices_breadth_first_search(g,seed,vvf) -> vertex_descriptor[vid,v,value] -// -namespace _Vertices_BFS { -# if defined(__clang__) || defined(__EDG__) // TRANSITION, VSO-1681199 - void vertices_breadth_first_search() = delete; // Block unqualified name lookup -# else // ^^^ no workaround / workaround vvv - void vertices_breadth_first_search(); -# endif // ^^^ workaround ^^^ - - template - concept _Has_ref_ADL = _Has_class_or_enum_type<_G> // - && requires(_G&& __g, const vertex_id_t<_G>& uid, _Alloc alloc) { - { _Fake_copy_init(vertices_breadth_first_search(__g, uid, alloc)) }; // intentional ADL - }; - template - concept _Can_ref_eval = index_adjacency_list<_G> // - && requires(_G&& __g, vertex_id_t<_G> uid, _Alloc alloc) { - { _Fake_copy_init(vertices_breadth_first_search_view<_G, void>(__g, uid, alloc)) }; - }; - - template - concept _Has_ref_vvf_ADL = _Has_class_or_enum_type<_G> // - && invocable<_VVF, vertex_reference_t<_G>> // - && requires(_G&& __g, const vertex_id_t<_G>& uid, _VVF vvf, _Alloc alloc) { - { - _Fake_copy_init(vertices_breadth_first_search(__g, uid, vvf, alloc)) - }; // intentional ADL - }; - template - concept _Can_ref_vvf_eval = index_adjacency_list<_G> // - && invocable<_VVF, vertex_reference_t<_G>> // - && requires(_G&& __g, vertex_id_t<_G> uid, _VVF vvf, _Alloc alloc) { - { - _Fake_copy_init(vertices_breadth_first_search_view<_G, _VVF>(__g, uid, vvf, alloc)) - }; - }; - - class _Cpo { - private: - enum class _St_ref { _None, _Non_member, _Auto_eval }; - enum class _St_ref_vvf { _None, _Non_member, _Auto_eval }; - - template - [[nodiscard]] static consteval _Choice_t<_St_ref> _Choose_ref() noexcept { - //static_assert(is_lvalue_reference_v<_G>); - using _UnCV = remove_cvref_t<_G>; - - if constexpr (_Has_ref_ADL<_G, _Alloc, _UnCV>) { - return {_St_ref::_Non_member, - noexcept(_Fake_copy_init(vertices_breadth_first_search(declval<_G>(), declval>(), - declval<_Alloc>())))}; // intentional ADL - } else if constexpr (_Can_ref_eval<_G, _Alloc, _UnCV>) { - return {_St_ref::_Auto_eval, noexcept(_Fake_copy_init(vertices_breadth_first_search_view<_G, void>( - declval<_G>(), declval>(), declval<_Alloc>())))}; - } else { - return {_St_ref::_None}; + // + // vertices_breadth_first_search(g,seed) -> vertex_descriptor[vid,v] + // vertices_breadth_first_search(g,seed,vvf) -> vertex_descriptor[vid,v,value] + // + namespace _Vertices_BFS { +# if defined(__clang__) || defined(__EDG__) // TRANSITION, VSO-1681199 + void vertices_breadth_first_search() = delete; // Block unqualified name lookup +# else // ^^^ no workaround / workaround vvv + void vertices_breadth_first_search(); +# endif // ^^^ workaround ^^^ + + template + concept _Has_ref_ADL = _Has_class_or_enum_type<_G> // + && requires(_G&& __g, const vertex_id_t<_G>& uid, _Alloc alloc) { + { _Fake_copy_init(vertices_breadth_first_search(__g, uid, alloc)) }; // intentional ADL + }; + template + concept _Can_ref_eval = index_adjacency_list<_G> // + && requires(_G&& __g, vertex_id_t<_G> uid, _Alloc alloc) { + { _Fake_copy_init(vertices_breadth_first_search_view<_G, void>(__g, uid, alloc)) }; + }; + + template + concept _Has_ref_vvf_ADL = _Has_class_or_enum_type<_G> // + && invocable<_VVF, vertex_reference_t<_G>> // + && requires(_G&& __g, const vertex_id_t<_G>& uid, _VVF vvf, _Alloc alloc) { + { + _Fake_copy_init(vertices_breadth_first_search(__g, uid, vvf, alloc)) + }; // intentional ADL + }; + template + concept _Can_ref_vvf_eval = + index_adjacency_list<_G> // + && invocable<_VVF, vertex_reference_t<_G>> // + && requires(_G&& __g, vertex_id_t<_G> uid, _VVF vvf, _Alloc alloc) { + { _Fake_copy_init(vertices_breadth_first_search_view<_G, _VVF>(__g, uid, vvf, alloc)) }; + }; + + class _Cpo { + private: + enum class _St_ref { _None, _Non_member, _Auto_eval }; + enum class _St_ref_vvf { _None, _Non_member, _Auto_eval }; + + template + [[nodiscard]] static consteval _Choice_t<_St_ref> _Choose_ref() noexcept { + //static_assert(is_lvalue_reference_v<_G>); + using _UnCV = remove_cvref_t<_G>; + + if constexpr (_Has_ref_ADL<_G, _Alloc, _UnCV>) { + return {_St_ref::_Non_member, + noexcept(_Fake_copy_init(vertices_breadth_first_search(declval<_G>(), declval>(), + declval<_Alloc>())))}; // intentional ADL + } else if constexpr (_Can_ref_eval<_G, _Alloc, _UnCV>) { + return {_St_ref::_Auto_eval, noexcept(_Fake_copy_init(vertices_breadth_first_search_view<_G, void>( + declval<_G>(), declval>(), declval<_Alloc>())))}; + } else { + return {_St_ref::_None}; + } } - } - template - static constexpr _Choice_t<_St_ref> _Choice_ref = _Choose_ref<_G, _Alloc>(); - - template - [[nodiscard]] static consteval _Choice_t<_St_ref_vvf> _Choose_ref_vvf() noexcept { - //static_assert(is_lvalue_reference_v<_G>); - using _UnCV = remove_cvref_t<_G>; - - if constexpr (_Has_ref_vvf_ADL<_G, _VVF, _Alloc, _UnCV>) { - return {_St_ref_vvf::_Non_member, noexcept(_Fake_copy_init(vertices_breadth_first_search( - declval<_G>(), declval>(), declval<_VVF>(), - declval<_Alloc>())))}; // intentional ADL - } else if constexpr (_Can_ref_vvf_eval<_G, _VVF, _Alloc, _UnCV>) { - return {_St_ref_vvf::_Auto_eval, - noexcept(_Fake_copy_init(vertices_breadth_first_search_view<_G, _VVF>( - declval<_G>(), declval>(), declval<_VVF>(), declval<_Alloc>())))}; - } else { - return {_St_ref_vvf::_None}; + template + static constexpr _Choice_t<_St_ref> _Choice_ref = _Choose_ref<_G, _Alloc>(); + + template + [[nodiscard]] static consteval _Choice_t<_St_ref_vvf> _Choose_ref_vvf() noexcept { + //static_assert(is_lvalue_reference_v<_G>); + using _UnCV = remove_cvref_t<_G>; + + if constexpr (_Has_ref_vvf_ADL<_G, _VVF, _Alloc, _UnCV>) { + return {_St_ref_vvf::_Non_member, noexcept(_Fake_copy_init(vertices_breadth_first_search( + declval<_G>(), declval>(), declval<_VVF>(), + declval<_Alloc>())))}; // intentional ADL + } else if constexpr (_Can_ref_vvf_eval<_G, _VVF, _Alloc, _UnCV>) { + return {_St_ref_vvf::_Auto_eval, + noexcept(_Fake_copy_init(vertices_breadth_first_search_view<_G, _VVF>( + declval<_G>(), declval>(), declval<_VVF>(), declval<_Alloc>())))}; + } else { + return {_St_ref_vvf::_None}; + } } - } - template - static constexpr _Choice_t<_St_ref_vvf> _Choice_ref_vvf = _Choose_ref_vvf<_G, _VVF, _Alloc>(); + template + static constexpr _Choice_t<_St_ref_vvf> _Choice_ref_vvf = _Choose_ref_vvf<_G, _VVF, _Alloc>(); - public: - /** + public: + /** * @brief Single Source, Breadth First Search for vertices * * Complexity: O(V + E) @@ -771,24 +770,24 @@ namespace _Vertices_BFS { * @param seed The vertex id to start the search. * @return A forward range for the breadth first search. */ - template > - requires(_Choice_ref<_G&, _Alloc>._Strategy != _St_ref::_None) - [[nodiscard]] constexpr auto operator()(_G&& __g, const vertex_id_t<_G>& seed, _Alloc alloc = _Alloc()) const - noexcept(_Choice_ref<_G&, _Alloc>._No_throw) { - constexpr _St_ref _Strat_ref = _Choice_ref<_G&, _Alloc>._Strategy; - - if constexpr (_Strat_ref == _St_ref::_Non_member) { - return vertices_breadth_first_search(__g, seed, alloc); // intentional ADL - } else if constexpr (_Strat_ref == _St_ref::_Auto_eval) { - return vertices_breadth_first_search_view<_G, void>(__g, seed, alloc); // default impl - } else { - static_assert(_Always_false<_G>, "The default implementation of " - "vertices_breadth_first_search(g,seed,alloc) cannot be evaluated and " - "there is no override defined for the graph."); + template > + requires(_Choice_ref<_G&, _Alloc>._Strategy != _St_ref::_None) + [[nodiscard]] constexpr auto operator()(_G&& __g, const vertex_id_t<_G>& seed, _Alloc alloc = _Alloc()) const + noexcept(_Choice_ref<_G&, _Alloc>._No_throw) { + constexpr _St_ref _Strat_ref = _Choice_ref<_G&, _Alloc>._Strategy; + + if constexpr (_Strat_ref == _St_ref::_Non_member) { + return vertices_breadth_first_search(__g, seed, alloc); // intentional ADL + } else if constexpr (_Strat_ref == _St_ref::_Auto_eval) { + return vertices_breadth_first_search_view<_G, void>(__g, seed, alloc); // default impl + } else { + static_assert(_Always_false<_G>, "The default implementation of " + "vertices_breadth_first_search(g,seed,alloc) cannot be evaluated and " + "there is no override defined for the graph."); + } } - } - /** + /** * @brief Single Source, Breadth First Search for vertices with VVF * * Complexity: O(V + E) @@ -803,117 +802,117 @@ namespace _Vertices_BFS { * * @return A forward range for the breadth first search. */ - template > - requires(_Choice_ref_vvf<_G&, _VVF, _Alloc>._Strategy != _St_ref_vvf::_None) - [[nodiscard]] constexpr auto - operator()(_G&& __g, const vertex_id_t<_G>& seed, _VVF&& vvf, _Alloc alloc = _Alloc()) const - noexcept(_Choice_ref_vvf<_G&, _VVF, _Alloc>._No_throw) { - constexpr _St_ref_vvf _Strat_ref_vvf = _Choice_ref_vvf<_G&, _VVF, _Alloc>._Strategy; - - if constexpr (_Strat_ref_vvf == _St_ref_vvf::_Non_member) { - return vertices_breadth_first_search(__g, seed, vvf, alloc); // intentional ADL - } else if constexpr (_Strat_ref_vvf == _St_ref_vvf::_Auto_eval) { - return vertices_breadth_first_search_view<_G, _VVF>(__g, seed, vvf, alloc); // default impl - } else { - static_assert(_Always_false<_G>, "The default implementation of " - "vertices_breadth_first_search(g,seed,vvf,alloc) cannot be evaluated and " - "there is no override defined for the graph."); + template > + requires(_Choice_ref_vvf<_G&, _VVF, _Alloc>._Strategy != _St_ref_vvf::_None) + [[nodiscard]] constexpr auto + operator()(_G&& __g, const vertex_id_t<_G>& seed, _VVF&& vvf, _Alloc alloc = _Alloc()) const + noexcept(_Choice_ref_vvf<_G&, _VVF, _Alloc>._No_throw) { + constexpr _St_ref_vvf _Strat_ref_vvf = _Choice_ref_vvf<_G&, _VVF, _Alloc>._Strategy; + + if constexpr (_Strat_ref_vvf == _St_ref_vvf::_Non_member) { + return vertices_breadth_first_search(__g, seed, vvf, alloc); // intentional ADL + } else if constexpr (_Strat_ref_vvf == _St_ref_vvf::_Auto_eval) { + return vertices_breadth_first_search_view<_G, _VVF>(__g, seed, vvf, alloc); // default impl + } else { + static_assert(_Always_false<_G>, "The default implementation of " + "vertices_breadth_first_search(g,seed,vvf,alloc) cannot be evaluated and " + "there is no override defined for the graph."); + } } - } - }; -} // namespace _Vertices_BFS + }; + } // namespace _Vertices_BFS -inline namespace _Cpos { - inline constexpr _Vertices_BFS::_Cpo vertices_breadth_first_search; -} + inline namespace _Cpos { + inline constexpr _Vertices_BFS::_Cpo vertices_breadth_first_search; + } -// -// edges_breadth_first_search(g,seed) -> edge_descriptor[vid,uv] -// edges_breadth_first_search(g,seed,evf) -> edge_descriptor[vid,uv,value] -// -namespace _Edges_BFS { -# if defined(__clang__) || defined(__EDG__) // TRANSITION, VSO-1681199 - void edges_breadth_first_search() = delete; // Block unqualified name lookup -# else // ^^^ no workaround / workaround vvv - void edges_breadth_first_search(); -# endif // ^^^ workaround ^^^ - - template - concept _Has_ref_ADL = _Has_class_or_enum_type<_G> // - && requires(_G&& __g, const vertex_id_t<_G>& uid, _Alloc alloc) { - { _Fake_copy_init(edges_breadth_first_search(__g, uid, alloc)) }; // intentional ADL - }; - template - concept _Can_ref_eval = index_adjacency_list<_G> // - && requires(_G&& __g, vertex_id_t<_G> uid, _Alloc alloc) { - { _Fake_copy_init(edges_breadth_first_search_view<_G, void, false>(__g, uid, alloc)) }; - }; - - template - concept _Has_ref_evf_ADL = _Has_class_or_enum_type<_G> // - && invocable<_EVF, edge_reference_t<_G>> // - && requires(_G&& __g, const vertex_id_t<_G>& uid, _EVF evf, _Alloc alloc) { - { - _Fake_copy_init(edges_breadth_first_search(__g, uid, evf, alloc)) - }; // intentional ADL - }; - template - concept _Can_ref_evf_eval = - index_adjacency_list<_G> // - && invocable<_EVF, edge_reference_t<_G>> // - && requires(_G&& __g, vertex_id_t<_G> uid, _EVF evf, _Alloc alloc) { - { _Fake_copy_init(edges_breadth_first_search_view<_G, _EVF, false>(__g, uid, evf, alloc)) }; - }; - - class _Cpo { - private: - enum class _St_ref { _None, _Non_member, _Auto_eval }; - enum class _St_ref_evf { _None, _Non_member, _Auto_eval }; - - template - [[nodiscard]] static consteval _Choice_t<_St_ref> _Choose_ref() noexcept { - //static_assert(is_lvalue_reference_v<_G>); - using _UnCV = remove_cvref_t<_G>; - - if constexpr (_Has_ref_ADL<_G, _Alloc, _UnCV>) { - return {_St_ref::_Non_member, - noexcept(_Fake_copy_init(edges_breadth_first_search(declval<_G>(), declval>(), - declval<_Alloc>())))}; // intentional ADL - } else if constexpr (_Can_ref_eval<_G, _Alloc, _UnCV>) { - return {_St_ref::_Auto_eval, noexcept(_Fake_copy_init(edges_breadth_first_search_view<_G, void, false>( - declval<_G>(), declval>(), declval<_Alloc>())))}; - } else { - return {_St_ref::_None}; + // + // edges_breadth_first_search(g,seed) -> edge_descriptor[vid,uv] + // edges_breadth_first_search(g,seed,evf) -> edge_descriptor[vid,uv,value] + // + namespace _Edges_BFS { +# if defined(__clang__) || defined(__EDG__) // TRANSITION, VSO-1681199 + void edges_breadth_first_search() = delete; // Block unqualified name lookup +# else // ^^^ no workaround / workaround vvv + void edges_breadth_first_search(); +# endif // ^^^ workaround ^^^ + + template + concept _Has_ref_ADL = _Has_class_or_enum_type<_G> // + && requires(_G&& __g, const vertex_id_t<_G>& uid, _Alloc alloc) { + { _Fake_copy_init(edges_breadth_first_search(__g, uid, alloc)) }; // intentional ADL + }; + template + concept _Can_ref_eval = index_adjacency_list<_G> // + && requires(_G&& __g, vertex_id_t<_G> uid, _Alloc alloc) { + { _Fake_copy_init(edges_breadth_first_search_view<_G, void, false>(__g, uid, alloc)) }; + }; + + template + concept _Has_ref_evf_ADL = _Has_class_or_enum_type<_G> // + && invocable<_EVF, edge_reference_t<_G>> // + && requires(_G&& __g, const vertex_id_t<_G>& uid, _EVF evf, _Alloc alloc) { + { + _Fake_copy_init(edges_breadth_first_search(__g, uid, evf, alloc)) + }; // intentional ADL + }; + template + concept _Can_ref_evf_eval = + index_adjacency_list<_G> // + && invocable<_EVF, edge_reference_t<_G>> // + && requires(_G&& __g, vertex_id_t<_G> uid, _EVF evf, _Alloc alloc) { + { _Fake_copy_init(edges_breadth_first_search_view<_G, _EVF, false>(__g, uid, evf, alloc)) }; + }; + + class _Cpo { + private: + enum class _St_ref { _None, _Non_member, _Auto_eval }; + enum class _St_ref_evf { _None, _Non_member, _Auto_eval }; + + template + [[nodiscard]] static consteval _Choice_t<_St_ref> _Choose_ref() noexcept { + //static_assert(is_lvalue_reference_v<_G>); + using _UnCV = remove_cvref_t<_G>; + + if constexpr (_Has_ref_ADL<_G, _Alloc, _UnCV>) { + return {_St_ref::_Non_member, + noexcept(_Fake_copy_init(edges_breadth_first_search(declval<_G>(), declval>(), + declval<_Alloc>())))}; // intentional ADL + } else if constexpr (_Can_ref_eval<_G, _Alloc, _UnCV>) { + return {_St_ref::_Auto_eval, noexcept(_Fake_copy_init(edges_breadth_first_search_view<_G, void, false>( + declval<_G>(), declval>(), declval<_Alloc>())))}; + } else { + return {_St_ref::_None}; + } } - } - template - static constexpr _Choice_t<_St_ref> _Choice_ref = _Choose_ref<_G, _Alloc>(); - - template - [[nodiscard]] static consteval _Choice_t<_St_ref_evf> _Choose_ref_evf() noexcept { - //static_assert(is_lvalue_reference_v<_G>); - using _UnCV = remove_cvref_t<_G>; - - if constexpr (_Has_ref_evf_ADL<_G, _EVF, _Alloc, _UnCV>) { - return {_St_ref_evf::_Non_member, noexcept(_Fake_copy_init(edges_breadth_first_search( - declval<_G>(), declval>(), declval<_EVF>(), - declval<_Alloc>())))}; // intentional ADL - } else if constexpr (_Can_ref_evf_eval<_G, _EVF, _Alloc, _UnCV>) { - return {_St_ref_evf::_Auto_eval, - noexcept(_Fake_copy_init(edges_breadth_first_search_view<_G, _EVF, false>( - declval<_G>(), declval>(), declval<_EVF>(), declval<_Alloc>())))}; - } else { - return {_St_ref_evf::_None}; + template + static constexpr _Choice_t<_St_ref> _Choice_ref = _Choose_ref<_G, _Alloc>(); + + template + [[nodiscard]] static consteval _Choice_t<_St_ref_evf> _Choose_ref_evf() noexcept { + //static_assert(is_lvalue_reference_v<_G>); + using _UnCV = remove_cvref_t<_G>; + + if constexpr (_Has_ref_evf_ADL<_G, _EVF, _Alloc, _UnCV>) { + return {_St_ref_evf::_Non_member, noexcept(_Fake_copy_init(edges_breadth_first_search( + declval<_G>(), declval>(), declval<_EVF>(), + declval<_Alloc>())))}; // intentional ADL + } else if constexpr (_Can_ref_evf_eval<_G, _EVF, _Alloc, _UnCV>) { + return {_St_ref_evf::_Auto_eval, + noexcept(_Fake_copy_init(edges_breadth_first_search_view<_G, _EVF, false>( + declval<_G>(), declval>(), declval<_EVF>(), declval<_Alloc>())))}; + } else { + return {_St_ref_evf::_None}; + } } - } - template - static constexpr _Choice_t<_St_ref_evf> _Choice_ref_evf = _Choose_ref_evf<_G, _EVF, _Alloc>(); + template + static constexpr _Choice_t<_St_ref_evf> _Choice_ref_evf = _Choose_ref_evf<_G, _EVF, _Alloc>(); - public: - /** + public: + /** * @brief Single Source, Breadth First Search for edges * * Complexity: O(V + E) @@ -926,24 +925,24 @@ namespace _Edges_BFS { * * @return A forward range for the breadth first search. */ - template > - requires(_Choice_ref<_G&, _Alloc>._Strategy != _St_ref::_None) - [[nodiscard]] constexpr auto operator()(_G&& __g, const vertex_id_t<_G>& seed, _Alloc alloc = _Alloc()) const - noexcept(_Choice_ref<_G&, _Alloc>._No_throw) { - constexpr _St_ref _Strat_ref = _Choice_ref<_G&, _Alloc>._Strategy; - - if constexpr (_Strat_ref == _St_ref::_Non_member) { - return edges_breadth_first_search(__g, seed, alloc); // intentional ADL - } else if constexpr (_Strat_ref == _St_ref::_Auto_eval) { - return edges_breadth_first_search_view<_G, void, false>(__g, seed, alloc); // default impl - } else { - static_assert(_Always_false<_G>, "The default implementation of " - "edges_breadth_first_search(g,seed,alloc) cannot be evaluated and " - "there is no override defined for the graph."); + template > + requires(_Choice_ref<_G&, _Alloc>._Strategy != _St_ref::_None) + [[nodiscard]] constexpr auto operator()(_G&& __g, const vertex_id_t<_G>& seed, _Alloc alloc = _Alloc()) const + noexcept(_Choice_ref<_G&, _Alloc>._No_throw) { + constexpr _St_ref _Strat_ref = _Choice_ref<_G&, _Alloc>._Strategy; + + if constexpr (_Strat_ref == _St_ref::_Non_member) { + return edges_breadth_first_search(__g, seed, alloc); // intentional ADL + } else if constexpr (_Strat_ref == _St_ref::_Auto_eval) { + return edges_breadth_first_search_view<_G, void, false>(__g, seed, alloc); // default impl + } else { + static_assert(_Always_false<_G>, "The default implementation of " + "edges_breadth_first_search(g,seed,alloc) cannot be evaluated and " + "there is no override defined for the graph."); + } } - } - /** + /** * @brief Single Source, Breadth First Search for edges with EVF * * Complexity: O(V + E) @@ -958,117 +957,119 @@ namespace _Edges_BFS { * * @return A forward range for the breadth first search. */ - template > - requires(_Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy != _St_ref_evf::_None) - [[nodiscard]] constexpr auto - operator()(_G&& __g, const vertex_id_t<_G>& seed, _EVF&& evf, _Alloc alloc = _Alloc()) const - noexcept(_Choice_ref_evf<_G&, _EVF, _Alloc>._No_throw) { - constexpr _St_ref_evf _Strat_ref_evf = _Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy; - - if constexpr (_Strat_ref_evf == _St_ref_evf::_Non_member) { - return edges_breadth_first_search(__g, seed, alloc); // intentional ADL - } else if constexpr (_Strat_ref_evf == _St_ref_evf::_Auto_eval) { - return edges_breadth_first_search_view<_G, _EVF, false>(__g, seed, evf, alloc); // default impl - } else { - static_assert(_Always_false<_G>, "The default implementation of " - "edges_breadth_first_search(g,seed,evf,alloc) cannot be evaluated and " - "there is no override defined for the graph."); + template > + requires(_Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy != _St_ref_evf::_None) + [[nodiscard]] constexpr auto + operator()(_G&& __g, const vertex_id_t<_G>& seed, _EVF&& evf, _Alloc alloc = _Alloc()) const + noexcept(_Choice_ref_evf<_G&, _EVF, _Alloc>._No_throw) { + constexpr _St_ref_evf _Strat_ref_evf = _Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy; + + if constexpr (_Strat_ref_evf == _St_ref_evf::_Non_member) { + return edges_breadth_first_search(__g, seed, alloc); // intentional ADL + } else if constexpr (_Strat_ref_evf == _St_ref_evf::_Auto_eval) { + return edges_breadth_first_search_view<_G, _EVF, false>(__g, seed, evf, alloc); // default impl + } else { + static_assert(_Always_false<_G>, "The default implementation of " + "edges_breadth_first_search(g,seed,evf,alloc) cannot be evaluated and " + "there is no override defined for the graph."); + } } - } - }; -} // namespace _Edges_BFS + }; + } // namespace _Edges_BFS -inline namespace _Cpos { - inline constexpr _Edges_BFS::_Cpo edges_breadth_first_search; -} + inline namespace _Cpos { + inline constexpr _Edges_BFS::_Cpo edges_breadth_first_search; + } -// -// sourced_edges_breadth_first_search(g,seed) -> edge_descriptor[uid,vid,uv] -// sourced_edges_breadth_first_search(g,seed,evf) -> edge_descriptor[uid,vid,uv,value] -// -namespace _Sourced_Edges_BFS { -# if defined(__clang__) || defined(__EDG__) // TRANSITION, VSO-1681199 - void sourced_edges_breadth_first_search() = delete; // Block unqualified name lookup -# else // ^^^ no workaround / workaround vvv - void sourced_edges_breadth_first_search(); -# endif // ^^^ workaround ^^^ - - template - concept _Has_ref_ADL = _Has_class_or_enum_type<_G> // - && requires(_G&& __g, const vertex_id_t<_G>& uid, _Alloc alloc) { - { _Fake_copy_init(sourced_edges_breadth_first_search(__g, uid, alloc)) }; // intentional ADL - }; - template - concept _Can_ref_eval = index_adjacency_list<_G> // - && requires(_G&& __g, vertex_id_t<_G> uid, _Alloc alloc) { - { _Fake_copy_init(edges_breadth_first_search_view<_G, void, true>(__g, uid, alloc)) }; - }; - - template - concept _Has_ref_evf_ADL = _Has_class_or_enum_type<_G> // - && invocable<_EVF, edge_reference_t<_G>> // - && requires(_G&& __g, const vertex_id_t<_G>& uid, _EVF evf, _Alloc alloc) { - { - _Fake_copy_init(sourced_edges_breadth_first_search(__g, uid, evf, alloc)) - }; // intentional ADL - }; - template - concept _Can_ref_evf_eval = - index_adjacency_list<_G> // - && invocable<_EVF, edge_reference_t<_G>> // - && requires(_G&& __g, vertex_id_t<_G> uid, _EVF evf, _Alloc alloc) { - { _Fake_copy_init(edges_breadth_first_search_view<_G, _EVF, true>(__g, uid, evf, alloc)) }; - }; - - class _Cpo { - private: - enum class _St_ref { _None, _Non_member, _Auto_eval }; - enum class _St_ref_evf { _None, _Non_member, _Auto_eval }; - - template - [[nodiscard]] static consteval _Choice_t<_St_ref> _Choose_ref() noexcept { - //static_assert(is_lvalue_reference_v<_G>); - using _UnCV = remove_cvref_t<_G>; - - if constexpr (_Has_ref_ADL<_G, _Alloc, _UnCV>) { - return {_St_ref::_Non_member, - noexcept(_Fake_copy_init(sourced_edges_breadth_first_search(declval<_G>(), declval>(), - declval<_Alloc>())))}; // intentional ADL - } else if constexpr (_Can_ref_eval<_G, _Alloc, _UnCV>) { - return {_St_ref::_Auto_eval, noexcept(_Fake_copy_init(edges_breadth_first_search_view<_G, void, true>( - declval<_G>(), declval>(), declval<_Alloc>())))}; - } else { - return {_St_ref::_None}; + // + // sourced_edges_breadth_first_search(g,seed) -> edge_descriptor[uid,vid,uv] + // sourced_edges_breadth_first_search(g,seed,evf) -> edge_descriptor[uid,vid,uv,value] + // + namespace _Sourced_Edges_BFS { +# if defined(__clang__) || defined(__EDG__) // TRANSITION, VSO-1681199 + void sourced_edges_breadth_first_search() = delete; // Block unqualified name lookup +# else // ^^^ no workaround / workaround vvv + void sourced_edges_breadth_first_search(); +# endif // ^^^ workaround ^^^ + + template + concept _Has_ref_ADL = _Has_class_or_enum_type<_G> // + && requires(_G&& __g, const vertex_id_t<_G>& uid, _Alloc alloc) { + { + _Fake_copy_init(sourced_edges_breadth_first_search(__g, uid, alloc)) + }; // intentional ADL + }; + template + concept _Can_ref_eval = index_adjacency_list<_G> // + && requires(_G&& __g, vertex_id_t<_G> uid, _Alloc alloc) { + { _Fake_copy_init(edges_breadth_first_search_view<_G, void, true>(__g, uid, alloc)) }; + }; + + template + concept _Has_ref_evf_ADL = _Has_class_or_enum_type<_G> // + && invocable<_EVF, edge_reference_t<_G>> // + && requires(_G&& __g, const vertex_id_t<_G>& uid, _EVF evf, _Alloc alloc) { + { + _Fake_copy_init(sourced_edges_breadth_first_search(__g, uid, evf, alloc)) + }; // intentional ADL + }; + template + concept _Can_ref_evf_eval = + index_adjacency_list<_G> // + && invocable<_EVF, edge_reference_t<_G>> // + && requires(_G&& __g, vertex_id_t<_G> uid, _EVF evf, _Alloc alloc) { + { _Fake_copy_init(edges_breadth_first_search_view<_G, _EVF, true>(__g, uid, evf, alloc)) }; + }; + + class _Cpo { + private: + enum class _St_ref { _None, _Non_member, _Auto_eval }; + enum class _St_ref_evf { _None, _Non_member, _Auto_eval }; + + template + [[nodiscard]] static consteval _Choice_t<_St_ref> _Choose_ref() noexcept { + //static_assert(is_lvalue_reference_v<_G>); + using _UnCV = remove_cvref_t<_G>; + + if constexpr (_Has_ref_ADL<_G, _Alloc, _UnCV>) { + return {_St_ref::_Non_member, + noexcept(_Fake_copy_init(sourced_edges_breadth_first_search(declval<_G>(), declval>(), + declval<_Alloc>())))}; // intentional ADL + } else if constexpr (_Can_ref_eval<_G, _Alloc, _UnCV>) { + return {_St_ref::_Auto_eval, noexcept(_Fake_copy_init(edges_breadth_first_search_view<_G, void, true>( + declval<_G>(), declval>(), declval<_Alloc>())))}; + } else { + return {_St_ref::_None}; + } } - } - template - static constexpr _Choice_t<_St_ref> _Choice_ref = _Choose_ref<_G, _Alloc>(); - - template - [[nodiscard]] static consteval _Choice_t<_St_ref_evf> _Choose_ref_evf() noexcept { - //static_assert(is_lvalue_reference_v<_G>); - using _UnCV = remove_cvref_t<_G>; - - if constexpr (_Has_ref_evf_ADL<_G, _EVF, _Alloc, _UnCV>) { - return {_St_ref_evf::_Non_member, noexcept(_Fake_copy_init(sourced_edges_breadth_first_search( - declval<_G>(), declval>(), declval<_EVF>(), - declval<_Alloc>())))}; // intentional ADL - } else if constexpr (_Can_ref_evf_eval<_G, _EVF, _Alloc, _UnCV>) { - return {_St_ref_evf::_Auto_eval, - noexcept(_Fake_copy_init(edges_breadth_first_search_view<_G, _EVF, true>( - declval<_G>(), declval>(), declval<_EVF>(), declval<_Alloc>())))}; - } else { - return {_St_ref_evf::_None}; + template + static constexpr _Choice_t<_St_ref> _Choice_ref = _Choose_ref<_G, _Alloc>(); + + template + [[nodiscard]] static consteval _Choice_t<_St_ref_evf> _Choose_ref_evf() noexcept { + //static_assert(is_lvalue_reference_v<_G>); + using _UnCV = remove_cvref_t<_G>; + + if constexpr (_Has_ref_evf_ADL<_G, _EVF, _Alloc, _UnCV>) { + return {_St_ref_evf::_Non_member, noexcept(_Fake_copy_init(sourced_edges_breadth_first_search( + declval<_G>(), declval>(), declval<_EVF>(), + declval<_Alloc>())))}; // intentional ADL + } else if constexpr (_Can_ref_evf_eval<_G, _EVF, _Alloc, _UnCV>) { + return {_St_ref_evf::_Auto_eval, + noexcept(_Fake_copy_init(edges_breadth_first_search_view<_G, _EVF, true>( + declval<_G>(), declval>(), declval<_EVF>(), declval<_Alloc>())))}; + } else { + return {_St_ref_evf::_None}; + } } - } - template - static constexpr _Choice_t<_St_ref_evf> _Choice_ref_evf = _Choose_ref_evf<_G, _EVF, _Alloc>(); + template + static constexpr _Choice_t<_St_ref_evf> _Choice_ref_evf = _Choose_ref_evf<_G, _EVF, _Alloc>(); - public: - /** + public: + /** * @brief Single Source, Breadth First Search for source edges * * Complexity: O(V + E) @@ -1081,24 +1082,24 @@ namespace _Sourced_Edges_BFS { * * @return A forward range for the breadth first search. */ - template > - requires(_Choice_ref<_G&, _Alloc>._Strategy != _St_ref::_None) - [[nodiscard]] constexpr auto operator()(_G&& __g, const vertex_id_t<_G>& seed, _Alloc alloc = _Alloc()) const - noexcept(_Choice_ref<_G&, _Alloc>._No_throw) { - constexpr _St_ref _Strat_ref = _Choice_ref<_G&, _Alloc>._Strategy; - - if constexpr (_Strat_ref == _St_ref::_Non_member) { - return sourced_edges_breadth_first_search(__g, seed, alloc); // intentional ADL - } else if constexpr (_Strat_ref == _St_ref::_Auto_eval) { - return edges_breadth_first_search_view<_G, void, true>(__g, seed, alloc); // default impl - } else { - static_assert(_Always_false<_G>, "The default implementation of " - "sourced_edges_breadth_first_search(g,seed,alloc) cannot be evaluated and " - "there is no override defined for the graph."); + template > + requires(_Choice_ref<_G&, _Alloc>._Strategy != _St_ref::_None) + [[nodiscard]] constexpr auto operator()(_G&& __g, const vertex_id_t<_G>& seed, _Alloc alloc = _Alloc()) const + noexcept(_Choice_ref<_G&, _Alloc>._No_throw) { + constexpr _St_ref _Strat_ref = _Choice_ref<_G&, _Alloc>._Strategy; + + if constexpr (_Strat_ref == _St_ref::_Non_member) { + return sourced_edges_breadth_first_search(__g, seed, alloc); // intentional ADL + } else if constexpr (_Strat_ref == _St_ref::_Auto_eval) { + return edges_breadth_first_search_view<_G, void, true>(__g, seed, alloc); // default impl + } else { + static_assert(_Always_false<_G>, "The default implementation of " + "sourced_edges_breadth_first_search(g,seed,alloc) cannot be evaluated and " + "there is no override defined for the graph."); + } } - } - /** + /** * @brief Single Source, Breadth First Search for edges with EVF * * Complexity: O(V + E) @@ -1113,31 +1114,32 @@ namespace _Sourced_Edges_BFS { * * @return A forward range for the breadth first search. */ - template > - requires(_Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy != _St_ref_evf::_None) - [[nodiscard]] constexpr auto - operator()(_G&& __g, const vertex_id_t<_G>& seed, _EVF&& evf, _Alloc alloc = _Alloc()) const - noexcept(_Choice_ref_evf<_G&, _EVF, _Alloc>._No_throw) { - constexpr _St_ref_evf _Strat_ref_evf = _Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy; - - if constexpr (_Strat_ref_evf == _St_ref_evf::_Non_member) { - return sourced_edges_breadth_first_search(__g, seed, alloc); // intentional ADL - } else if constexpr (_Strat_ref_evf == _St_ref_evf::_Auto_eval) { - return edges_breadth_first_search_view<_G, _EVF, true>(__g, seed, evf, alloc); // default impl - } else { - static_assert(_Always_false<_G>, "The default implementation of " - "sourced_edges_breadth_first_search(g,seed,evf,alloc) cannot be evaluated and " - "there is no override defined for the graph."); + template > + requires(_Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy != _St_ref_evf::_None) + [[nodiscard]] constexpr auto + operator()(_G&& __g, const vertex_id_t<_G>& seed, _EVF&& evf, _Alloc alloc = _Alloc()) const + noexcept(_Choice_ref_evf<_G&, _EVF, _Alloc>._No_throw) { + constexpr _St_ref_evf _Strat_ref_evf = _Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy; + + if constexpr (_Strat_ref_evf == _St_ref_evf::_Non_member) { + return sourced_edges_breadth_first_search(__g, seed, alloc); // intentional ADL + } else if constexpr (_Strat_ref_evf == _St_ref_evf::_Auto_eval) { + return edges_breadth_first_search_view<_G, _EVF, true>(__g, seed, evf, alloc); // default impl + } else { + static_assert(_Always_false<_G>, + "The default implementation of " + "sourced_edges_breadth_first_search(g,seed,evf,alloc) cannot be evaluated and " + "there is no override defined for the graph."); + } } - } - }; -} // namespace _Sourced_Edges_BFS + }; + } // namespace _Sourced_Edges_BFS -inline namespace _Cpos { - inline constexpr _Sourced_Edges_BFS::_Cpo sourced_edges_breadth_first_search; -} + inline namespace _Cpos { + inline constexpr _Sourced_Edges_BFS::_Cpo sourced_edges_breadth_first_search; + } } // namespace views } // namespace std::graph -#endif // GRAPH_BFS_HPP +#endif // GRAPH_BFS_HPP diff --git a/include/graph/views/depth_first_search.hpp b/include/graph/views/depth_first_search.hpp index fd9c582..efb6a92 100644 --- a/include/graph/views/depth_first_search.hpp +++ b/include/graph/views/depth_first_search.hpp @@ -650,7 +650,7 @@ namespace views { # endif // ^^^ workaround ^^^ template - concept _Has_ref_ADL = _Has_class_or_enum_type<_G> // + concept _Has_ref_ADL = _Has_class_or_enum_type<_G> // && requires(_G&& __g, const vertex_id_t<_G>& uid, _Alloc alloc) { { _Fake_copy_init(vertices_depth_first_search(__g, uid, alloc)) }; // intentional ADL }; @@ -724,7 +724,7 @@ namespace views { static constexpr _Choice_t<_St_ref_vvf> _Choice_ref_vvf = _Choose_ref_vvf<_G, _VVF, _Alloc>(); public: - /** + /** * @brief Single Source, Breadth First Search for vertices * * Complexity: O(V + E) @@ -742,7 +742,7 @@ namespace views { constexpr _St_ref _Strat_ref = _Choice_ref<_G&, _Alloc>._Strategy; if constexpr (_Strat_ref == _St_ref::_Non_member) { - return vertices_depth_first_search(__g, seed, alloc); // intentional ADL + return vertices_depth_first_search(__g, seed, alloc); // intentional ADL } else if constexpr (_Strat_ref == _St_ref::_Auto_eval) { return vertices_depth_first_search_view<_G, void>(__g, seed, alloc); // default impl } else { @@ -752,7 +752,7 @@ namespace views { } } - /** + /** * @brief Single Source, Breadth First Search for vertices with VVF * * Complexity: O(V + E) @@ -775,7 +775,7 @@ namespace views { constexpr _St_ref_vvf _Strat_ref_vvf = _Choice_ref_vvf<_G&, _VVF, _Alloc>._Strategy; if constexpr (_Strat_ref_vvf == _St_ref_vvf::_Non_member) { - return vertices_depth_first_search(__g, seed, vvf, alloc); // intentional ADL + return vertices_depth_first_search(__g, seed, vvf, alloc); // intentional ADL } else if constexpr (_Strat_ref_vvf == _St_ref_vvf::_Auto_eval) { return vertices_depth_first_search_view<_G, _VVF>(__g, seed, vvf, alloc); // default impl } else { @@ -804,7 +804,7 @@ namespace views { # endif // ^^^ workaround ^^^ template - concept _Has_ref_ADL = _Has_class_or_enum_type<_G> // + concept _Has_ref_ADL = _Has_class_or_enum_type<_G> // && requires(_G&& __g, const vertex_id_t<_G>& uid, _Alloc alloc) { { _Fake_copy_init(edges_depth_first_search(__g, uid, alloc)) }; // intentional ADL }; @@ -877,7 +877,7 @@ namespace views { static constexpr _Choice_t<_St_ref_evf> _Choice_ref_evf = _Choose_ref_evf<_G, _EVF, _Alloc>(); public: - /** + /** * @brief Single Source, Breadth First Search for edges * * Complexity: O(V + E) @@ -897,7 +897,7 @@ namespace views { constexpr _St_ref _Strat_ref = _Choice_ref<_G&, _Alloc>._Strategy; if constexpr (_Strat_ref == _St_ref::_Non_member) { - return edges_depth_first_search(__g, seed, alloc); // intentional ADL + return edges_depth_first_search(__g, seed, alloc); // intentional ADL } else if constexpr (_Strat_ref == _St_ref::_Auto_eval) { return edges_depth_first_search_view<_G, void, false>(__g, seed, alloc); // default impl } else { @@ -907,7 +907,7 @@ namespace views { } } - /** + /** * @brief Single Source, Breadth First Search for edges with EVF * * Complexity: O(V + E) @@ -930,7 +930,7 @@ namespace views { constexpr _St_ref_evf _Strat_ref_evf = _Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy; if constexpr (_Strat_ref_evf == _St_ref_evf::_Non_member) { - return edges_depth_first_search(__g, seed, alloc); // intentional ADL + return edges_depth_first_search(__g, seed, alloc); // intentional ADL } else if constexpr (_Strat_ref_evf == _St_ref_evf::_Auto_eval) { return edges_depth_first_search_view<_G, _EVF, false>(__g, seed, evf, alloc); // default impl } else { @@ -1034,7 +1034,7 @@ namespace views { static constexpr _Choice_t<_St_ref_evf> _Choice_ref_evf = _Choose_ref_evf<_G, _EVF, _Alloc>(); public: - /** + /** * @brief Single Source, Breadth First Search for source edges * * Complexity: O(V + E) @@ -1054,7 +1054,7 @@ namespace views { constexpr _St_ref _Strat_ref = _Choice_ref<_G&, _Alloc>._Strategy; if constexpr (_Strat_ref == _St_ref::_Non_member) { - return sourced_edges_depth_first_search(__g, seed, alloc); // intentional ADL + return sourced_edges_depth_first_search(__g, seed, alloc); // intentional ADL } else if constexpr (_Strat_ref == _St_ref::_Auto_eval) { return edges_depth_first_search_view<_G, void, true>(__g, seed, alloc); // default impl } else { @@ -1064,7 +1064,7 @@ namespace views { } } - /** + /** * @brief Single Source, Breadth First Search for edges with EVF * * Complexity: O(V + E) @@ -1087,7 +1087,7 @@ namespace views { constexpr _St_ref_evf _Strat_ref_evf = _Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy; if constexpr (_Strat_ref_evf == _St_ref_evf::_Non_member) { - return sourced_edges_depth_first_search(__g, seed, alloc); // intentional ADL + return sourced_edges_depth_first_search(__g, seed, alloc); // intentional ADL } else if constexpr (_Strat_ref_evf == _St_ref_evf::_Auto_eval) { return edges_depth_first_search_view<_G, _EVF, true>(__g, seed, evf, alloc); // default impl } else {