Question: Im trying create a filtered type of a variadic template/parameter pack and also preserve ordering.

```cpp
// example what im trying to accomplish
template<typename... Args>
struct query
{
    using filtered = typename filtered<std::is_integral_v, Args...>
}

```

In this example filtered would filter all integral types eg.

```
query<int, A, B>::filtered == query<A, B>::filtered

```

How can I create a util like this or something that would achieve the same results

Answer: 
With [Boost.Mp11](https://www.boost.org/doc/libs/1_72_0/libs/mp11/doc/html/mp11.html#mp_filterp_l), this is a short one-liner (as always):

```
using filtered = mp_filter<std::is_integral, mp_list<Args...>>;

```

Note that if you want this to be a `std::tuple`, that's:

```
using filtered = mp_filter<std::is_integral, std::tuple<Args...>>;

```
You can avoid recursion using `std::tuple_cat()`

```
#include <type_traits>
#include <tuple>

template <template <typename> class F, typename T>
std::enable_if_t<true == F<T>::value, std::tuple<>> filter ();

template <template <typename> class F, typename T>
std::enable_if_t<false == F<T>::value, std::tuple<T>> filter ();

template <typename...>
struct query;

template <typename ... Ts>
query<Ts...> deTuple (std::tuple<Ts...>);

template <template <typename> class F, typename ... Ts>
struct filtered
 { using type = decltype(std::tuple_cat(filter<F, Ts>()...)); };

template<typename... Args>
struct query
{
    using filtered = decltype(deTuple(std::declval<
      typename filtered<std::is_integral, Args...>::type>()));
};

class A {};
class B {};

int main ()
 {
   using T1 = typename query<int, A, B>::filtered;
   using T2 = query<A, B>;

   static_assert( std::is_same_v<T1, T2> );
 }

```