Boost logo

Boost :

Subject: Re: [boost] Do/can we have a C++11 variadic integer list?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-10-01 09:33:12


On 10/01/13 04:14, Daryle Walker wrote:
> 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.
>

Hi Daryle,

I think package_c here:

http://svn.boost.org/svn/boost/sandbox/variadic_templates/boost/mpl/package_c.hpp

does that.

And, package_range_c here:

http://svn.boost.org/svn/boost/sandbox/variadic_templates/boost/mpl/package_range_c.hpp

does, I'm guessing, something similar to make_indices_too, only
it can do it either in reverse or forward order.

And, unpack_args here:

http://svn.boost.org/svn/boost/sandbox/variadic_templates/boost/mpl/unpack_args.hpp

does maybe something like apply_x_and_exploded_tuple_impl.

So, I'd agree that these additions to boost would be useful.

-regards,
Larry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk