Я хотел бы знать, возможно ли отфильтровать типы, переданные в вариативный шаблон (на основе шаблона предиката), чтобы создать другой вариативный шаблон, содержащий те типы, которые удовлетворяют предикату:
/** Filter a parameter pack */
template <template <class> class,
template <class...> class,
class...>
struct filter;
template <template <class> class Pred, template <class...> class Variadic>
struct filter<Pred, Variadic> : Variadic<>
{};
template <template <class> class Pred,
template <class...> class Variadic,
class T, class... Ts>
struct filter<Pred, Variadic, T, Ts...>
{
// FIXME: this just stops at first T where Pred<T> is true
using type = typename std::conditional<
Pred<T>::value,
Variadic<T, Ts...>, // can't do: Variadic<T, filter<...>>
filter<Pred, Variadic, Ts...> >::type;
};
Как видите, я не нашел способа «извлечь» пакет параметров из остальных отфильтрованных типов.
Заранее спасибо!