Skip to content

Commit

Permalink
Remove use of UnCV in incidence.hpp & neighbors.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pratzl committed Jan 23, 2024
1 parent 772faf2 commit 56d585a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
20 changes: 8 additions & 12 deletions include/graph/views/incidence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,19 @@ namespace views {
void incidence();
#endif // ^^^ workaround ^^^

template <class _G, class _UnCV>
template <class _G>
concept _Has_id_ADL = adjacency_list<_G> && requires(_G&& __g, const vertex_id_t<_G>& uid) {
{ _Fake_copy_init(incidence(__g, uid)) }; // intentional ADL
};
template <class _G, class _UnCV>
template <class _G>
concept _Can_id_eval = adjacency_list<_G>;

template <class _G, class _UnCV, class EVF>
template <class _G, class EVF>
concept _Has_id_evf_ADL = adjacency_list<_G> && invocable<EVF, edge_reference_t<_G>> &&
requires(_G&& __g, const vertex_id_t<_G>& uid, const EVF& evf) {
{ _Fake_copy_init(incidence(__g, uid, evf)) }; // intentional ADL
};
template <class _G, class _UnCV, class EVF>
template <class _G, class EVF>
concept _Can_id_evf_eval = adjacency_list<_G> && invocable<EVF, edge_reference_t<_G>>;

class _Cpo {
Expand All @@ -275,12 +275,10 @@ namespace views {
template <class _G>
[[nodiscard]] static consteval _Choice_t<_St_id> _Choose_id() noexcept {
static_assert(is_lvalue_reference_v<_G>);
using _UnCV = remove_cvref_t<_G>;

if constexpr (_Has_id_ADL<_G, _UnCV>) {
if constexpr (_Has_id_ADL<_G>) {
return {_St_id::_Non_member,
noexcept(_Fake_copy_init(incidence(declval<_G>(), declval<vertex_id_t<_G>>())))}; // intentional ADL
} else if constexpr (_Can_id_eval<_G, _UnCV>) {
} else if constexpr (_Can_id_eval<_G>) {
return {_St_id::_Auto_eval,
noexcept(_Fake_copy_init(incidence_view<_G, false, void>(
incidence_iterator<_G, false, void>(declval<_G>(), declval<vertex_id_t<_G>>()),
Expand All @@ -296,12 +294,10 @@ namespace views {
template <class _G, class EVF>
[[nodiscard]] static consteval _Choice_t<_St_id> _Choose_id_evf() noexcept {
static_assert(is_lvalue_reference_v<_G>);
using _UnCV = remove_cvref_t<_G>;

if constexpr (_Has_id_evf_ADL<_G, _UnCV, EVF>) {
if constexpr (_Has_id_evf_ADL<_G, EVF>) {
return {_St_id::_Non_member, noexcept(_Fake_copy_init(incidence(declval<_G>(), declval<vertex_id_t<_G>>(),
declval<EVF>())))}; // intentional ADL
} else if constexpr (_Can_id_evf_eval<_G, _UnCV, EVF>) {
} else if constexpr (_Can_id_evf_eval<_G, EVF>) {
return {_St_id::_Auto_eval,
noexcept(_Fake_copy_init(incidence_view<_G, false, EVF>(
incidence_iterator<_G, false, EVF>(declval<_G>(), declval<vertex_id_t<_G>>(), declval<EVF>()),
Expand Down
20 changes: 8 additions & 12 deletions include/graph/views/neighbors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,21 @@ namespace views {
void neighbors();
#endif // ^^^ workaround ^^^

template <class _G, class _UnCV>
template <class _G>
concept _Has_id_ADL = adjacency_list<_G> && requires(_G&& __g, const vertex_id_t<_G>& uid) {
{ _Fake_copy_init(neighbors(__g, uid)) }; // intentional ADL
};
template <class _G, class _UnCV>
template <class _G>
concept _Can_id_eval = adjacency_list<_G> && requires(_G&& __g, vertex_id_t<_G>& uid) {
{ _Fake_copy_init(edges(__g, uid)) };
};

template <class _G, class _UnCV, class VVF>
template <class _G, class VVF>
concept _Has_id_vvf_ADL = adjacency_list<_G> && invocable<VVF, vertex_reference_t<_G>> &&
requires(_G&& __g, const vertex_id_t<_G>& uid, const VVF& vvf) {
{ _Fake_copy_init(neighbors(__g, uid, vvf)) }; // intentional ADL
};
template <class _G, class _UnCV, class VVF>
template <class _G, class VVF>
concept _Can_id_vvf_eval = adjacency_list<_G> && invocable<VVF, vertex_reference_t<_G>>;

class _Cpo {
Expand All @@ -298,12 +298,10 @@ namespace views {
template <class _G>
[[nodiscard]] static consteval _Choice_t<_St_id> _Choose_id() noexcept {
static_assert(is_lvalue_reference_v<_G>);
using _UnCV = remove_cvref_t<_G>;

if constexpr (_Has_id_ADL<_G, _UnCV>) {
if constexpr (_Has_id_ADL<_G>) {
return {_St_id::_Non_member,
noexcept(_Fake_copy_init(neighbors(declval<_G>(), declval<vertex_id_t<_G>>())))}; // intentional ADL
} else if constexpr (_Can_id_eval<_G, _UnCV>) {
} else if constexpr (_Can_id_eval<_G>) {
return {_St_id::_Auto_eval,
noexcept(_Fake_copy_init(neighbors_view<_G, false, void>(
neighbor_iterator<_G, false, void>(declval<_G>(), declval<vertex_id_t<_G>>()),
Expand All @@ -319,12 +317,10 @@ namespace views {
template <class _G, class VVF>
[[nodiscard]] static consteval _Choice_t<_St_id> _Choose_id_vvf() noexcept {
static_assert(is_lvalue_reference_v<_G>);
using _UnCV = remove_cvref_t<_G>;

if constexpr (_Has_id_vvf_ADL<_G, _UnCV, VVF>) {
if constexpr (_Has_id_vvf_ADL<_G, VVF>) {
return {_St_id::_Non_member, noexcept(_Fake_copy_init(neighbors(declval<_G>(), declval<vertex_id_t<_G>>(),
declval<VVF>())))}; // intentional ADL
} else if constexpr (_Can_id_vvf_eval<_G, _UnCV, VVF>) {
} else if constexpr (_Can_id_vvf_eval<_G, VVF>) {
return {_St_id::_Auto_eval,
noexcept(_Fake_copy_init(neighbors_view<_G, false, VVF>(
neighbor_iterator<_G, false, VVF>(declval<_G>(), declval<vertex_id_t<_G>>(), declval<VVF>()),
Expand Down

0 comments on commit 56d585a

Please sign in to comment.