Boost logo

Boost :

Subject: [boost] Do/can we have a C++11 variadic integer list?
From: Daryle Walker (darylew_at_[hidden])
Date: 2013-10-01 05:14:01

I'm talking about this:
    template < std::size_t ...N > struct indices_too { using next = indices_too<N..., sizeof...(N)>; }; template < std::size_t N > struct make_indices_too { using type = typename make_indices_too<N - 1u>::type::next; }; template < > struct make_indices_too<0u> { using type = indices_too<>; };
I've written things like this 4 times for my prototype Boost classes, and I want it in Boost already so I can just reference that version. Something like it will come in C++14, but we could provide it here for C++11 users?
Do we already have one?
Here's how to use one:
    template < typename Function, typename T, class Tuple, std::size_t ...I > void apply_x_and_exploded_tuple_impl( Function &&f, T &&x, Tuple &&t, indices_too<I...> ) { using std::forward;
        forward<Function>( f )( forward<T>(x), forward<typename std::tuple_element<I, typename std::remove_reference<Tuple>::type>::type>(std::get<I>( t ))... ); }
    template < typename Function, typename T, class Tuple > void apply_x_and_exploded_tuple( Function &&f, T &&x, Tuple &&t ) { using std::forward;
        apply_x_and_exploded_tuple_impl( forward<Function>(f), forward<T>(x), forward<Tuple>(t), typename make_indices_too<std::tuple_size<typename std::remove_reference<Tuple>::type>::value>::type{} ); }
Daryle W.

Boost list run by bdawes at, gregod at, cpdaniel at, john at