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.


New and Changed Features

56486 questions
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…
  • 353,942
  • 115
  • 666
  • 851
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
  • 95,983
  • 54
  • 240
  • 345
11 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…
  • 45,396
  • 28
  • 101
  • 140
23 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…
  • 16,284
  • 3
  • 14
  • 27
10 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.
  • 353,942
  • 115
  • 666
  • 851
14 answers

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

In C++03, an expression is either an rvalue or an lvalue. In C++11, the two value categories have become five: rvalue lvalue xvalue glvalue prvalue What are these new categories of expressions, and why are they needed? How do these new categories…
James McNellis
  • 348,265
  • 75
  • 913
  • 977
8 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…
  • 67,274
  • 36
  • 133
  • 188
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…
  • 49,529
  • 25
  • 126
  • 221
9 answers

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

What is it? What does it do? When should it be used? Good links are appreciated.
  • 22,440
  • 15
  • 57
  • 102
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…
  • 854,327
  • 234
  • 1,573
  • 1,953
10 answers

What's the 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?
  • 26,084
  • 47
  • 114
  • 191
9 answers

When should I really use noexcept?

The noexcept keyword can be appropriately applied to many function signatures, but I am unsure as to when I should consider using it in practice. Based on what I have read so far, the last-minute addition of noexcept seems to address some important…
  • 14,247
  • 11
  • 43
  • 61
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 (…
  • 31,668
  • 17
  • 78
  • 127
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
  • 130,161
  • 59
  • 324
  • 434
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.…
Khaled Alshaya
  • 94,250
  • 39
  • 176
  • 234
2 3
99 100