Boost logo

Boost Users :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2005-08-17 22:13:58


Stephen Gross writes:
> I read up on boost::mpl::at<...>. It's pretty cool, but I wanted to make it
> a little easier to use. I found it a little annoying to have to type out
> 'int_<...>' for the index number, so I created a struct to automate that
> feature:
>
> ==========================
> template<typename SEQ, int IDX>
> struct atIdx
> {
> typedef typename boost::mpl::at<SEQ, boost::mpl::int_<IDX> >::type type;
> };
> ==========================
>
> With the struct above, you can do the following:
>
> =============================
> typedef boost::mpl::vector<int, char, int> t;
> atIdx<t, 0>::type i; // This line is shorter than the one below:
> /* atIdx<t, boost::mpl::int_<0> >::type i; */
> =============================
>
> Is this feature already available in boost somewhere? If I've reinvented the
> wheel, I'll be happy to use an existing implementation...

See http://www.boost.org/libs/mpl/doc/refmanual/at-c.html.

-- 
Aleksey Gurtovoy
MetaCommunications Engineering

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net