Hello. I would like to propose a small addition to the tuple class
template in c++0x. I'm surprised I didn't
see this in any proposal, since it's gonna give us more than a
headache (I think) if it's not included.
Since the tuple class template is a container, it would be very useful
to be able to loop over
each element in the tuple. This is not easy, since that requires
metaprogramming.
A good small addition would be to do something like this:
struct do_something
{
template <class T>
void operator()(const T & elem)
{
//...
}
};
int main()
{
tuple<int, float, std::string> t(3, 2.38f, "hello");
tuple_elem_each(t, do_something());
}
I recommend this or a similar thing to be included. Because looping a
tuple in a manual way is difficult.
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|