TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: Bo Simonsen
from: andrew clarke
date: 2009-04-30 01:03:06
subject: Ping?

On Tue 2009-04-28 22:04, Bo Simonsen (2:236/100) wrote to Mike Luther:

 BS> Just thought of, are you guys also excited to see the final
 BS> version of the C++0x standard?

 BS> So far, I've experimented some, especially with the auto-keyword.
 BS> (It's in GCC 4.4)

 BS> Instead of writing:

 BS> std::set cont;
 BS> cont.insert(5);
 BS> cont.insert(7);

 BS> for(typename std::set::iterator it = cont.begin(); 
 BS>     it != cont.end();
 BS>     ++it) {
 BS>     // do something with *it
 BS> }

How does "typename" work here?  I'm not familiar with recent C++
developments...

 BS> We can simply write:

 BS> for(auto it=cont.begin(); it != cont.end(); ++it) {

 BS> }

Hmm.  I don't really know how that works, but I think I prefer this:

    typedef std::set intset_t;
    intset_t cont;

    cont.insert(5);
    cont.insert(7);

    intset_t::iterator it = cont.begin();

    while (it != cont.end())
    {
        // do something with *it
        ++it;
    }

Having said that, my personal preference is a bit academic - as these days
I spend most of my programming time writing code in Python :-)

  cont = set()
  cont.add(5)
  cont.add(7)

  for it in cont:
    print it

Regards
Andrew

--- timEd/FreeBSD 1.11.b2
* Origin: Blizzard of Ozz, Melbourne, Victoria, Australia (3:633/267)
SEEN-BY: 633/260 267
@PATH: 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.