C++11 is the name of the C++ standard, approved in 2011. It replaces the previous C++03 standard, adding various core language changes and fixes, and an improved and expanded standard library.
Questions tagged [c++11]
174 questions
186
votes
3 answers
Is C++11 Uniform Initialization a replacement for the old style syntax?
I understand that C++11's uniform initialization solves some syntactical ambiguity in the language, but in a lot of Bjarne Stroustrup's presentations (particularly those during the GoingNative 2012 talks), his examples primarily use this syntax now…

void.pointer
- 4,983
- 8
- 30
- 40
147
votes
14 answers
Does auto make C++ code harder to understand?
I saw a conference by Herb Sutter where he encourages every C++ programmer to use auto.
I had to read C# code some time ago where var was extensively used and the code was very hard to understand—every time var was used I had to check the return…

Mircea Ispas
- 1,603
- 2
- 11
- 7
144
votes
11 answers
Should I stop using the term C/C++?
I understand C and C++ are different languages but when I was learning C++ I was always told that C is a subset of C++ or C++ is C with classes. And that was quite true until the appearance of C++x0, C++11 (or the modern C++ 11/14/17 in general). In…

rkachach
- 1,219
- 2
- 9
- 9
74
votes
7 answers
Using scoped enums for bit flags in C++
An enum X : int (C#) or enum class X : int (C++11) is a type that has a hidden inner field of int that can hold any value. In addition, a number of predefined constants of X are defined on the enum. It is possible to cast the enum to its integer…

Daniel A.A. Pelsmaeker
- 2,715
- 3
- 22
- 27
70
votes
9 answers
std::shared_ptr as a last resort?
I was just watching the "Going Native 2012" streams and I noticed the discussion about std::shared_ptr. I was a bit surprised to hear Bjarne's somewhat negative view on std::shared_ptr and his comment that it should be used as a "last resort" when…

ronag
- 1,179
- 1
- 10
- 18
64
votes
13 answers
Philosophy behind Undefined Behavior
C\C++ specifications leave out a large number of behaviors open for compilers to implement in their own way. There are a number of questions that always keep getting asked here about the same and we have some excellent posts about…

Alok Save
- 1,138
- 7
- 12
54
votes
3 answers
C++ strongly typed typedef
I've been trying to think of a way of declaring strongly typed typedefs, to catch a certain class of bugs in the compilation stage. It's often the case that I'll typedef an int into several types of ids, or a vector to position or velocity:
typedef…

Kian
- 643
- 1
- 5
- 5
43
votes
1 answer
C++11 includes std::stoi, why not std::itos?
I noticed to my glee that C++11 has a std::sto@ family of functions for easily unpacking ints/floats/longs whatever from strings. I'm surprised however, that the opposite isn't implemented. Why didn't the standards committee include a std::itos…

Doug T.
- 11,642
- 5
- 43
- 69
40
votes
10 answers
I am a beginner. Can I directly start learning C++11? or I have to learn old C++?
I'm a beginner and have only little knowledge in programming.
Would it be good if I directly learn C++ from books which cover new C++11 or should I study through the old best C++ books?
Should I have little knowledge about C++ before learning C++11?…

Dhananjay
- 595
- 1
- 4
- 7
36
votes
4 answers
How to make the switch to C++11?
I've been programming in C++ for a while now, but mostly things centered around the low-level features of C++. By that I mean mostly working with pointers and raw arrays. I think this behavior is known as using C++ as C with classes. Despite this, I…

Overv
- 1,170
- 1
- 9
- 15
34
votes
3 answers
Did C++11 address concerns passing std lib objects between dynamic/shared library boundaries? (ie dlls and so)?
One of my major complaints about C++ is how hard in practice it is to pass std library objects outside of dynamic library (ie dll/so) boundaries.
The std library is often header-only. Which is great for doing some awesome optimizations. However,…

Doug T.
- 11,642
- 5
- 43
- 69
33
votes
2 answers
Is it ever bad to mark a C++ function constexpr?
Given a very trivial function,
int transform(int val) {
return (val + 7) / 8;
}
It should be very obvious that it's easy to turn this function into a constexpr function, allowing me to use it when defining constexpr variables, like…

Xirema
- 513
- 1
- 5
- 9
31
votes
5 answers
Is passing arguments as const references premature optimization?
"Premature optimization is the root of all evil"
I think this we can all agree upon. And I try very hard to avoid doing that.
But recently I have been wondering about the practice of passing parameters by const Reference instead of by Value. I have…

CharonX
- 1,633
- 1
- 11
- 23
31
votes
3 answers
Is GCC dying without threads support on Windows?
I need some opinion. GCC was always a very good compiler, but recently it is losing "appeal".
I have just found that on Windows GCC does not have std::thread support, forcing Windows users to use another compiler because the most exciting feature is…

CoffeDeveloper
- 551
- 1
- 4
- 10
30
votes
5 answers
Style guide for C++
Right now I am using Google C++ Style Guide in my C++ code and I was pretty happy with it.
Recently I was told that this guide is very bad: it is used internally by Google (I knew that), is outdated, and promotes some very bad practices. So I want…

bolov
- 456
- 1
- 5
- 10