Question: Is there a way to remove one of the types from type expansion?

Let's use tuple as an example,

```
void foo() {
     tuple<int, double, string> t;
     // some facility to expand except the i-th type:
     expand_except_ith<0>(t);   // returns tuple<double, string>
     expand_except_ith<1>(t);   // returns tuple<int, string>
}

```

Answer: 
Here is a short [c++14](/questions/tagged/c%2b%2b14 "show questions tagged 'c++14'") version:

```
template<std::size_t...Is>
auto indexer( std::index_sequence<Is...> ) {
  return [](auto && f) {
    return f( std::integral_constant<std::size_t, Is>{}... );
  };
}
template<std::size_t N>
auto indexer() {
  return indexer( std::make_index_sequence<N>{} );
}

template<std::size_t N, class T>
auto except_nth( T&& t ) {
  constexpr auto size = std::tuple_size< std::decay_t<T> >{};
  static_assert( N < size, "No skipping past the end" );
  auto before = indexer<N>();
  auto after = indexer< size-N-1 > ();
  return before( [&]( auto...As ) {
    return after( [&]( auto...Bs ) {
      return std::make_tuple( std::get<As>(std::forward<T>(t))..., std::get<N+1+Bs>(std::forward<T>(t))... );
    } );
  });
}

```

[Live example](http://coliru.stacked-crooked.com/a/fbc366f092b37536).

This avoids depth-N template instantiation recursion of template instantiation "volume" N^2, which is hard to do in C++11 for this problem.

`indexer` is a cute little helper that lets us expand counting parameter packs without having to write a new function.

`indexer<N>()( [&]( auto...Is ) { /* code */ } )` gives us the integers `0` through `N-1` in a pack `Is...` within `/* code */`.

We do this twice, once for the leading elements, once for the tailing. Then we wrap it all up in a single `make_tuple` call.

Note that gcc in [c++14](/questions/tagged/c%2b%2b14 "show questions tagged 'c++14'") mode needs

```
      return std::make_tuple( std::get<decltype(As){}>(std::forward<T>(t))..., std::get<N+1+decltype(Bs){}>(std::forward<T>(t))... );

```

as it won't let you call a member function with a non-constexpr object even if the function does not use `this`. clang works fine, even in [c++14](/questions/tagged/c%2b%2b14 "show questions tagged 'c++14'"). I think this was a standard ambiguity that was cleared up later.
```cpp
#include <iostream>
#include <string>
#include <tuple>
#include <cassert>
#include <utility>

namespace details
{
    template <std::size_t N, std::size_t Except, std::size_t... Next>
    struct index_sequence_helper : public index_sequence_helper<N - 1U, Except, N - 1U, Next...>
    {
    };

    template <std::size_t N, std::size_t... Next>
    struct index_sequence_helper<N, N, Next...> : public index_sequence_helper<N - 1U, N, Next...>
    {
    };

    template <std::size_t Except, std::size_t... Next>
    struct index_sequence_helper<0U, Except, Next...>
    {
        using type = std::index_sequence<Next...>;
    };
} // namespace details

template <std::size_t N, std::size_t Except>
using make_index_sequence_except = typename details::index_sequence_helper<N, Except + 1>::type;

template <class Tuple, std::size_t... I>
auto make_tuple_by_seq(const Tuple &t, std::index_sequence<I...>)
{
    return std::make_tuple(std::get<I>(t)...);
}

template <size_t N, class... T>
auto expand_except_ith(const std::tuple<T...> &t)
{
    return make_tuple_by_seq(t, make_index_sequence_except<sizeof...(T), N>{});
}

int main()
{
    std::tuple<int, double, std::string> t;
    // some facility to expand except the i-th type:
    auto t0 = expand_except_ith<0>(t); // returns tuple<double, string>
    auto t1 = expand_except_ith<1>(t); // returns tuple<int, string>
    auto t2 = expand_except_ith<2>(t); // returns tuple<int, double>

    std::cout << std::is_same_v<decltype(t0), std::tuple<double, std::string>> << std::endl;
    std::cout << std::is_same_v<decltype(t1), std::tuple<int, std::string>> << std::endl;
    std::cout << std::is_same_v<decltype(t2), std::tuple<int, double>> << std::endl;
}

```

I modified the code from [details of std::make\_index\_sequence and std::index\_sequence](https://stackoverflow.com/questions/49669958/details-of-stdmake-index-sequence-and-stdindex-sequence)