GuillaumeDua / CppShelf

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

[mp] none_of, any_of #166

Open GuillaumeDua opened 7 months ago

GuillaumeDua commented 7 months ago

Linked to #165

// none_of
template <typename pack, template <typename> typename predicate>
struct none_of;
template <template <typename ...> typename pack, template <typename> typename predicate, typename ... Ts>
struct none_of<pack<Ts...>, predicate> : std::integral_constant<bool, (true and ... and not predicate<Ts>::value)>{};
template <typename pack, template <typename> typename predicate>
constexpr auto none_of_v = none_of<pack, predicate>::value;

// any_of
template <typename pack, template <typename> typename predicate>
struct any_of;
template <template <typename ...> typename pack, template <typename> typename predicate, typename ... Ts>
struct any_of<pack<Ts...>, predicate> : std::integral_constant<bool, (false or ... or predicate<Ts>::value)>{};
template <typename pack, template <typename> typename predicate>
constexpr auto any_of_v = any_of<pack, predicate>::value;

See std::disjunction