GuillaumeDua / CppShelf

Collection of powerfuls - C++ Single-Header Libraries Files
https://guillaumedua.github.io/CppShelf/
MIT License
9 stars 1 forks source link

[mp] filters #174

Open GuillaumeDua opened 9 months ago

GuillaumeDua commented 9 months ago

WIP: https://godbolt.org/z/9vzT69f9G

// filters
// Note: about `template <typename...> typename predicate`
//       instead of template <typename> typename predicate -> clang
template <template <typename...> typename, typename>
struct filters;
template <template <typename...> typename predicate, template <typename...> typename pack, typename ... Ts>
requires requires { ((predicate<Ts>::value) and ...); }
struct filters<predicate, pack<Ts...>>
    : flatten_once<
        pack<
            std::conditional_t<predicate<Ts>::value, pack<Ts>, pack<>>...
        >
    >
{};
template <template <typename...> typename predicate, typename pack>
using filters_t = typename filters<predicate, pack>::type;