Open GuillaumeDua opened 5 months ago
Or strict count: no pack specialization.
Motivation
using one = std::tuple<A, B, C>; using two = std::tuple<B, C>; count_v<A, one, two>; // what if we wanna check if "A" is either `one` or `two` ? (ambiguous)
Solution: plain + apply_t wrapper
template <typename T, typename ... ttps> struct count : std::integral_constant<std::size_t, (std::size_t{0} + ... + std::size_t{std::is_same_v<T, ttps>})>{}; template <typename T, template <typename...> typename pack, typename ... ttps> struct count<T, pack<ttps...>> : count<T, ttps...>{}; template <typename T, typename ... ttps> constexpr std::size_t count_v = count<T, ttps...>::value;
Or strict count: no pack specialization.
Motivation
Solution: plain + apply_t wrapper