//index_sequence header //Copyright (c) 2014 mmYYmmdd #if !defined MMYYMMDD_INDEX_SEQUENCE_INCLUDED #define MMYYMMDD_INDEX_SEQUENCE_INCLUDED #include #include //****************************************************************************** // common utility //****************************************************************************** namespace mymd { // rebind template-element change template-template-type template struct template_template; template class D, typename...T> struct template_template> { template using rebind = D; template class H> using change = H; }; } //******************************************************************************* // integEr_sequence(integer_sequence), indEx_sequence(index_sequence), // make_indEx_sequence(make_index_sequence) // (will be replaced C++14 standard) //******************************************************************************* namespace mymd { template struct integEr_sequence { using value_type = T; static std::size_t size() { return sizeof...(values); } }; template using indEx_sequence = integEr_sequence; //------------------------------------------------ template struct index_cat; template struct index_cat, indEx_sequence> { using type = indEx_sequence; }; template struct index_shift; template struct index_shift> { using type = indEx_sequence; }; //------------------------------------------------------------------------ namespace detail_index_range_i { template struct index_range_i { using type = typename index_shift::type>::type; }; template struct index_range_i<0, len> { static const std::size_t h = len/2; using type = typename index_cat::type, typename index_range_i::type>::type; }; template <> struct index_range_i<0, 0> { using type = indEx_sequence<>; }; template <> struct index_range_i<0, 1> { using type = indEx_sequence<0>; }; template <> struct index_range_i<0, 2> { using type = indEx_sequence<0, 1>; }; } //+************************************************************** template using index_range = typename detail_index_range_i::index_range_i::type; template using make_indEx_sequence = typename detail_index_range_i::index_range_i<0, last>::type; } //************************************************************************** // at_type / class / get N_th type of a sequence of types // (depends on make_indEx_sequence) //************************************************************************** namespace mymd { namespace detail_index_at { // get N_th type of a sequence of types template struct type_at { using type = T; }; template struct pair_t; template