1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

#include <iostream>
template< typename T, T... VALUES > struct seq_c {};
template< typename T, T... > struct size ;
template< typename T, T... VALUES > struct size< seq_c< T, VALUES...> >
{ enum { value = sizeof...(VALUES) } ; } ;
template< typename T, T V, typename U > struct push_front {} ;
template< typename T, T V, T... VALUES > struct push_front< T, V, seq_c< T, VALUES...> >
{ typedef seq_c< T, V, VALUES... > type ; } ;
template< typename T > struct pop_front {} ;
template< typename T, T V, T... VALUES > struct pop_front< seq_c< T, V, VALUES...> >
{ typedef seq_c< T, VALUES...> type ; } ;
template< typename T > struct sum ;
template< typename T > struct sum < seq_c<T> > { static constexpr T value = T() ; } ;
template< typename T, T V, T... VALUES > struct sum< seq_c< T, V, VALUES...> >
{ static constexpr T value = V + sum< seq_c< T, VALUES... > >::value ; } ;
// .. etc
int main()
{
using ten_to_fifteen = seq_c< int, 10, 11, 12, 13, 14, 15 > ;
std::cout << "size of ten_to_fifteen: " << size<ten_to_fifteen>::value
<< " sum: " << sum<ten_to_fifteen>::value << '\n' ;
using nine_to_fifteen = push_front< int, 9, ten_to_fifteen >::type ;
std::cout << "size of nine_to_fifteen: " << size<nine_to_fifteen>::value
<< " sum: " << sum<nine_to_fifteen>::value << '\n' ;
using eleven_to_fifteen = pop_front< ten_to_fifteen >::type ;
std::cout << "size of eleven_to_fifteen: " << size<eleven_to_fifteen>::value
<< " sum: " << sum<eleven_to_fifteen>::value << '\n' ;
}
