Messages - Gothi[c] [ switch to compact view ]

Pages: prev1 ... 4 5 6 7 8 [9] 10 11 12 13 14 ... 160next
41
Developer's Corner / Re: Herb Sutter's brief look at C++11
« on: November 01, 2011, 02:33 AM »
Use auto wherever possible. It is useful for two reasons. First, most obviously it’s a convenience that lets us avoid repeating a type name that we already stated and the compiler already knows.

// C++98
map<int,string>::iterator i = m.begin();
 
// C++11
auto i = begin(m);


Second, it’s more than just a convenience when a type has an unknown or unutterable name, such as the type of most lambda functions, that you couldn’t otherwise spell easily or at all.

I'm not sure how much I like this... I mean,.. Isn't this type of thing exactly why we have typdef's ?
At least a typedef still gives you an idea of what type a variable will be, or at least make it relatively easy to look up the type definition in the code. Looking up the return value of begin() in stl seems like more of a pain in the rear, and this is just a simple example... :S


typedef std::vector<std::string> strvector;

// ...

strvector foo = func(); // <- this seems more useful/readable than:

auto foo = func(); // <- no idea wtf foo is from looking at it.


 :two:





42
* Gothi[c] waits for dc to be flagged as terrorist organisation :D
watch all the paypal funds be frozen :D


44
You forgot to add that world food stocks are going down and population is going up :)

45
Living Room / Re: DoCo Banner - Animated!
« on: June 07, 2011, 01:58 PM »
I love the part where he sinks  :P

Pages: prev1 ... 4 5 6 7 8 [9] 10 11 12 13 14 ... 160next
Go to full version