Questions tagged [c++11]

Use this tag for code that must compile as C++11 (not using any features introduced in C++14 or later).

C++11 is the name of a version of the C++ standard approved in the year 2011. It replaced the previous standard, C++03, adding various core language changes and fixes, and an improved and expanded standard library. C++11 had earlier been referred to as C++0x, because it was originally expected to be published before 2010.

The ISO standard, 14882:2011, is withdrawn from the ISO website. The final draft was approved by the C++ working group on the 25th of March 2011. The publicly-available draft closest to C++11 is N3337, which has only editorial differences from the full standard.

Later versions of the language standard were approved and published in 2014 and 2017 (C++14 and C++17 respectively), and questions related to them bear the tags and here on StackOverflow. Each of these supersedes the previous, just as C++11 superseded C++03.

Please tag questions about C++11 with the tag, along with the tag.

Resources

New and Changed Features

53784 questions
2023
votes
8 answers

C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?

C++11 introduced a standardized memory model, but what exactly does that mean? And how is it going to affect C++ programming? This article (by Gavin Clarke who quotes Herb Sutter) says that, The memory model means that C++ code now has a…
Nawaz
  • 327,095
  • 105
  • 629
  • 812
1954
votes
14 answers

What is a smart pointer and when should I use one?

What is a smart pointer and when should I use one?
Alex Reynolds
  • 91,635
  • 50
  • 223
  • 320
1846
votes
12 answers

What is move semantics?

I just finished listening to the Software Engineering radio podcast interview with Scott Meyers regarding C++0x. Most of the new features made sense to me, and I am actually excited about C++0x now, with the exception of one. I still don't get move…
dicroce
  • 41,038
  • 26
  • 94
  • 136
1718
votes
22 answers

Why should I use a pointer rather than the object itself?

I'm coming from a Java background and have started working with objects in C++. But one thing that occurred to me is that people often use pointers to objects rather than the objects themselves, for example this declaration: Object *myObject = new…
gEdringer
  • 14,619
  • 3
  • 12
  • 24
1594
votes
9 answers

What is a lambda expression in C++11?

What is a lambda expression in C++11? When would I use one? What class of problem do they solve that wasn't possible prior to their introduction? A few examples, and use cases would be useful.
Nawaz
  • 327,095
  • 105
  • 629
  • 812
1460
votes
12 answers

What are rvalues, lvalues, xvalues, glvalues, and prvalues?

In C++03, an expression is either an rvalue or an lvalue. In C++11, an expression can be an: rvalue lvalue xvalue glvalue prvalue Two categories have become five categories. What are these new categories of expressions? How do these new…
James McNellis
  • 327,682
  • 71
  • 882
  • 954
1008
votes
7 answers

What is the difference between 'typedef' and 'using' in C++11?

I know that in C++11 we can now use using to write type alias, like typedefs: typedef int MyInt; Is, from what I understand, equivalent to: using MyInt = int; And that new syntax emerged from the effort to have a way to express "template…
Klaim
  • 60,771
  • 31
  • 121
  • 186
901
votes
7 answers

push_back vs emplace_back

I'm a bit confused regarding the difference between push_back and emplace_back. void emplace_back(Type&& _Val); void push_back(const Type& _Val); void push_back(Type&& _Val); As there is a push_back overload taking a rvalue reference I don't quite…
ronag
  • 43,567
  • 23
  • 113
  • 204
887
votes
4 answers

What does T&& (double ampersand) mean in C++11?

I've been looking into some of the new features of C++11 and one I've noticed is the double ampersand in declaring variables, like T&& var. For a start, what is this beast called? I wish Google would allow us to search for punctuation like…
paxdiablo
  • 772,407
  • 210
  • 1,477
  • 1,841
766
votes
8 answers

What is std::move(), and when should it be used?

What is it? What does it do? When should it be used? Good links are appreciated.
Basilevs
  • 18,490
  • 15
  • 51
  • 98
682
votes
10 answers

Difference between `constexpr` and `const`

What's the difference between constexpr and const? When can I use only one of them? When can I use both and how should I choose one?
MBZ
  • 22,515
  • 41
  • 105
  • 182
633
votes
13 answers

Are the days of passing const std::string & as a parameter over?

I heard a recent talk by Herb Sutter who suggested that the reasons to pass std::vector and std::string by const & are largely gone. He suggested that writing a function such as the following is now preferable: std::string do_something (…
Benj
  • 29,382
  • 17
  • 72
  • 119
598
votes
14 answers

What exactly is nullptr?

We now have C++11 with many new features. An interesting and confusing one (at least for me) is the new nullptr. Well, no need anymore for the nasty macro NULL. int* x = nullptr; myclass* obj = nullptr; Still, I am not getting how nullptr works.…
AraK
  • 87,541
  • 35
  • 171
  • 230
590
votes
6 answers

What are Aggregates and PODs and how/why are they special?

This FAQ is about Aggregates and PODs and covers the following material: What are Aggregates? What are PODs (Plain Old Data)? How are they related? How and why are they special? What changes for C++11?
Armen Tsirunyan
  • 120,726
  • 52
  • 304
  • 418
579
votes
6 answers

Iterator invalidation rules

What are the iterator invalidation rules for C++ containers? Preferably in a summary list format. _(Note: This is meant to be an entry to [Stack Overflow's C++ FAQ](https://stackoverflow.com/questions/tagged/c++-faq). If you want to critique the…
Lightness Races in Orbit
  • 358,771
  • 68
  • 593
  • 989
1
2 3
99 100