Skip to content

Commit

Permalink
simplied gather signatures (#116)
Browse files Browse the repository at this point in the history
* simplied gather signatures

* clang-format

* revert CMakeList.txt change

* fixed formatting issue
  • Loading branch information
dietmarkuehl authored Jan 13, 2025
1 parent ba3abd3 commit f5de841
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
7 changes: 3 additions & 4 deletions include/beman/execution26/detail/gather_signatures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct same_tag<Tag, R(A...)> {
};
template <typename Tag>
struct bound_tag {
using type = Tag;
template <typename T>
using predicate = ::beman::execution26::detail::same_tag<Tag, T>;
};
Expand Down Expand Up @@ -69,14 +70,12 @@ template <typename Tag,
template <typename...> class Variant>
requires requires {
typename ::beman::execution26::detail::gather_signatures_helper<
::beman::execution26::detail::meta::
filter<::beman::execution26::detail::bound_tag<Tag>::template predicate, signatures>,
::beman::execution26::detail::meta::filter_tag<::beman::execution26::detail::same_tag, Tag, signatures>,
Tuple,
Variant>::type;
}
using gather_signatures = ::beman::execution26::detail::gather_signatures_helper<
::beman::execution26::detail::meta::filter<::beman::execution26::detail::bound_tag<Tag>::template predicate,
signatures>,
::beman::execution26::detail::meta::filter_tag<::beman::execution26::detail::same_tag, Tag, signatures>,
Tuple,
Variant>::type;
} // namespace beman::execution26::detail
Expand Down
24 changes: 23 additions & 1 deletion include/beman/execution26/detail/meta_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,44 @@ namespace beman::execution26::detail::meta::detail {
template <template <typename> class, typename>
struct filter;

template <template <typename, typename> class, typename, typename>
struct filter_tag;

template <template <typename> class Predicate, template <typename...> class List>
struct filter<Predicate, List<>> {
using type = List<>;
};

template <template <typename, typename> class Predicate, typename Tag, template <typename...> class List>
struct filter_tag<Predicate, Tag, List<>> {
using type = List<>;
};

template <template <typename> class Predicate, template <typename...> class List, typename H, typename... T>
struct filter<Predicate, List<H, T...>> {
using tail = typename beman::execution26::detail::meta::detail::filter<Predicate, List<T...>>::type;
using type = ::std::conditional_t<Predicate<H>::value, ::beman::execution26::detail::meta::prepend<H, tail>, tail>;
};

template <template <typename, typename> class Predicate,
typename Tag,
template <typename...> class List,
typename H,
typename... T>
struct filter_tag<Predicate, Tag, List<H, T...>> {
using tail = typename beman::execution26::detail::meta::detail::filter_tag<Predicate, Tag, List<T...>>::type;
using type =
::std::conditional_t<Predicate<Tag, H>::value, ::beman::execution26::detail::meta::prepend<H, tail>, tail>;
};
} // namespace beman::execution26::detail::meta::detail

namespace beman::execution26::detail::meta {
template <template <typename> class Predicate, typename List>
using filter = ::beman::execution26::detail::meta::detail::filter<Predicate, List>::type;
}

template <template <typename, typename> class Predicate, typename Tag, typename List>
using filter_tag = ::beman::execution26::detail::meta::detail::filter_tag<Predicate, Tag, List>::type;
} // namespace beman::execution26::detail::meta

// ----------------------------------------------------------------------------

Expand Down

0 comments on commit f5de841

Please sign in to comment.