0% found this document useful (0 votes)
34 views2 pages

Should You Care About C++11?: Boost::shared - PTR

C++11 adds many new language features to C++ to improve its expressiveness, clarity, and efficiency. It fixes annoyances and reduces verbosity. Key features include lambda expressions, move semantics, improved templates, and multithreading support in the standard library. The C++ standards committee worked hard over many meetings to design an implementation that works across compilers and platforms while producing maintainable code. C++11 makes C++ a more usable language through features like auto type deduction and ranged-based for loops that simplify code.

Uploaded by

BENSON H
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

Should You Care About C++11?: Boost::shared - PTR

C++11 adds many new language features to C++ to improve its expressiveness, clarity, and efficiency. It fixes annoyances and reduces verbosity. Key features include lambda expressions, move semantics, improved templates, and multithreading support in the standard library. The C++ standards committee worked hard over many meetings to design an implementation that works across compilers and platforms while producing maintainable code. C++11 makes C++ a more usable language through features like auto type deduction and ranged-based for loops that simplify code.

Uploaded by

BENSON H
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Should you care about C++11?

Most definitely. C++11 adds many new language features to C++. C++11 should fix many
annoyances and reduce the overall verbosity of C++ as well as provide new tools, such as lambda
expressions, that increase its overall expressiveness and clarity. Fetaures like move semantics
improve the basic efficiency of the language, allowing you to write faster code, and the improvements
to the template system make it much easier to write generic code.

The new standard library will also include many new features, including adding multithreading support
directly into C++ and improved smart pointers that will simplify memory management for those who
aren't already using features like boost::shared_ptr.

I've started using several new C++11 features professionally and I'm loving it. Some of the new
features I'm fond of include the new meaning of the auto keyword, simplifications like better handling
of right angle brackets in templates, lambda expressions and the new function declaration syntax.

How was C++11 developed?


I can't go on further about C++11 without acknowledging the hard work done by the C++ standards
committee--a group of experts from academia and industry who have met many times to work
through all the edge cases and design a programming language that can be implemented across
multiple platforms by multiple compilers, producing efficient and reasonably maintainable code. The
next standard, C++11, looks to be a fantastic addition to the flexibility and power of C++.

What is C++11 about?

Language usability

Having started to use C++11, I'd say that the most fundamental way of looking at it is that it makes
C++ a much more usable language. This isn't to say that it makes it a simpler language--there are
lots of new features--but it provides a lot of functionality that makes it easier to program. Let's look at
one example, the auto keyword.

In C++11, if the compiler is able to determine the type of a variable from its initialization, you don't
need to provide the type. For example, you can write code such as

int x = 3;
auto y = x;

and the compiler will deduce that y is an int. This, of course, isn't a shining example of where auto is
really useful. Auto really comes into its own when working with templates and especially the STL. Why
is that? Imagine working with an iterator:
map<string, string> address_book;
address_book[ "Alex" ] = "[email protected]";
// add a bunch of people to address_book

Now you want to iterate over the elements of the address_book. To do it, you need an iterator:
map<string, string>::iterator itr = address_book.begin();

That's an awfully long type declaration for something that you already know the type of! Wouldn't it
be nice to simply write:
auto itr = address_book.begin();
The code is much shorter, and frankly, I think it's more readable, not less, because the template
syntax obscures everything else on that line. This is one of my favorite new features, and I find it
eliminates a lot of headaches and hard-to-track-down compiler errors, and just generally saves time
without losing expressiveness.

Ranged For Loops

Now, the iterator example is one where C++11 has come up with an even better way of handling this-
-something called a range-based for loop (which almost every language has nowadays). The idea is so
elegant, an example should suffice:

vector<int> vec;
vec.push_back( 10 );
vec.push_back( 20 );

for (int &i : vec )


{
cout << i;
}

You might also like