|
Boost Users : |
From: Stephen Gross (sgross_at_[hidden])
Date: 2005-08-17 09:21:25
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...
Thanks,
--Steve
Stephen Gross
Case Western School of Medicine
Cleveland, OH
"By Grabthar's hammer, by the sons of Worvan, you shall be avenged." - Dr.
Lazarus
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