#include <type_traits> // std::is_same
#if 1 // Not in C++11 // make_index_sequence
#include <cstdint>
template < std:: size_t ...> struct index_sequence { } ;
template < std:: size_t N, std:: size_t ... Is >
struct make_index_sequence : make_index_sequence< N - 1 , N - 1 , Is...> { } ;
template < std:: size_t ... Is >
struct make_index_sequence< 0u, Is...> : index_sequence< Is...> { using type = index_sequence< Is...> ; } ;
#endif // make_index_sequence
namespace detail
{
template < typename Seq1, std:: size_t Offset, typename Seq2> struct concat_seq;
template < std:: size_t ... Is1 , std:: size_t Offset, std:: size_t ... Is2 >
struct concat_seq< index_sequence< Is1...> , Offset, index_sequence< Is2...>>
{
using type = index_sequence< Is1..., ( Offset + Is2) ...> ;
} ;
}
template < std:: size_t N, std:: size_t E>
using gen_seq = typename detail:: concat_seq < typename make_index_sequence< E> :: type , E + 1 , typename make_index_sequence< ( N > E) ? ( N - E - 1 ) : 0 > :: type > :: type ;
static_assert( std:: is_same < index_sequence< 0 , 1 , 3 , 4 > , gen_seq< 5 , 2 >> :: value , "" ) ;
static_assert( std:: is_same < index_sequence< 1 , 2 > , gen_seq< 3 , 0 >> :: value , "" ) ;
static_assert( std:: is_same < index_sequence< 0 , 1 , 2 , 3 > , gen_seq< 4 , 4 >> :: value , "" ) ;
int main( ) { }
I2luY2x1ZGUgPHR5cGVfdHJhaXRzPiAvLyBzdGQ6OmlzX3NhbWUKCiNpZiAxIC8vIE5vdCBpbiBDKysxMSAvLyBtYWtlX2luZGV4X3NlcXVlbmNlCiNpbmNsdWRlIDxjc3RkaW50PgoKdGVtcGxhdGUgPHN0ZDo6c2l6ZV90Li4uPiBzdHJ1Y3QgaW5kZXhfc2VxdWVuY2Uge307Cgp0ZW1wbGF0ZSA8c3RkOjpzaXplX3QgTiwgc3RkOjpzaXplX3QuLi4gSXM+CnN0cnVjdCBtYWtlX2luZGV4X3NlcXVlbmNlIDogbWFrZV9pbmRleF9zZXF1ZW5jZTxOIC0gMSwgTiAtIDEsIElzLi4uPiB7fTsKCnRlbXBsYX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