ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Herb Sutter's brief look at C++11

(1/5) > >>

Herb Sutter, Microsoft's head C++/CLI guy and author of the famous Guru of the Week columns, has nice little overview of some of C++11 new features over on this blog. It's really worth checking out.

The C++11 standard offers many useful new features. This page focuses specifically and only on those features that make C++11 really feel like a new language compared to C++98, because:

* They change the styles and idioms you’ll use when writing C++ code, often including the way you’ll design C++ libraries. For example, you’ll see more smart pointer parameters and return values, and functions that return big objects by value.
* They will be used so pervasively that you’ll probably see them in most code examples. For example, virtually every five-line modern C++ code example will say “auto” somewhere.-
--- End quote ---

thanks for sharing this info -- going to read now.  :up:

I must say I'm loving the few C++11 features that appeared in Visual Studio 2010. Can't wait to get developing with the fuller new standard library.

Auto and range for alone will save a ton of typing (or a ton of typedefs) :-*.

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.

--- End quote ---

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.



[0] Message Index

[#] Next page

Go to full version