Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Please consider...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 9507 of 9828
Post > Topic >>

Please consider this addition for tuples in c++0x

by german diago <germandiago@[EMAIL PROTECTED] > Apr 16, 2008 at 11:37 AM

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! ]
 




 4 Posts in Topic:
Please consider this addition for tuples in c++0x
german diago <germandi  2008-04-16 11:37:05 
Re: Please consider this addition for tuples in c++0x
Mathias Gaunard <loufo  2008-04-17 03:55:06 
Re: Please consider this addition for tuples in c++0x
Brendan <catphive@[EMA  2008-04-17 03:51:10 
Re: Please consider this addition for tuples in c++0x
german diago <germandi  2008-04-17 11:43:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 15:35:59 CDT 2008.