Questions tagged [c++14]

C++14 is the name of the C++ standard, approved in 2014. It builds upon the previous C++11 standard, improving the core language and standard library and adding some features.

C++14 is the name of the C++ standard, approved in 2014. It builds upon the previous standard, improving the core language and standard library and adding some features. Before the standard was approved, C++14 was commonly referred to as C++1y, following the pattern from C++0x, the pre-standardization name for C++11.

The ISO Standard, International Standard ISO/IEC 14882:2014(E) Programming Language C++, is available for purchase from the ISO website. The final draft was approved by the C++ working group on the 18th of August 2014. The draft closest to C++14 is N3936 (git), which will have only editorial differences from the full standard. It has been withdrawn from free distribution. The preceding draft N3797 remains available. The announcement of balloting mentions the set of final changes between these two documents will be minimal.

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


New features

Core language

  • Polymorphic and variadic lambdas
  • Lambda capture initialization
  • Expanded return type deduction and decltype(auto)
  • Separators in numeric literals, ' (single quote) being the separator.
  • Relaxed constexpr functions and non-const constexpr member functions


8473 questions
3 answers

How to implement classic sorting algorithms in modern C++?

The std::sort algorithm (and its cousins std::partial_sort and std::nth_element) from the C++ Standard Library is in most implementations a complicated and hybrid amalgamation of more elementary sorting algorithms, such as selection sort, insertion…
  • 69,038
  • 19
  • 164
  • 304
8 answers

Lambda capture as const reference?

Is it possible to capture by const reference in a lambda expression? I want the assignment marked below to fail, for example: #include #include using namespace std; int main() { string strings[] = { "hello", …
John Dibling
  • 99,718
  • 31
  • 186
  • 324
2 answers

Can modern C++ get you performance for free?

It is sometimes claimed that C++11/14 can get you a performance boost even when merely compiling C++98 code. The justification is usually along the lines of move semantics, as in some cases the rvalue constructors are automatically generated or now…
  • 2,162
  • 2
  • 13
  • 14
2 answers

What are some uses of decltype(auto)?

In c++14 the decltype(auto) idiom is introduced. Typically its use is to allow auto declarations to use the decltype rules on the given expression. Searching for examples of "good" usage of the idiom I can only think of things like the following…
Nikos Athanasiou
  • 29,616
  • 15
  • 87
  • 153
6 answers

Does C++11, 14, 17 or 20 introduce a standard constant for pi?

There is a rather silly problem with the number pi in C and C++. As far as I know M_PI defined in math.h is not required by any standard. New C++ standards introduced a lot of complicated math in the standard library - hyperbolic functions,…
  • 6,217
  • 8
  • 34
  • 62
4 answers

Differences between std::make_unique and std::unique_ptr with new

Does std::make_unique have any efficiency benefits like std::make_shared? Compared to manually constructing std::unique_ptr: std::make_unique(1); // vs std::unique_ptr(new int(1));
  • 5,304
  • 6
  • 32
  • 37
2 answers

Advantages of using std::make_unique over new operator

What are the advantages of using std::make_unique over the new operator for initializing a std::unique_ptr? In other words, why is std::unique_ptr a = std::make_unique(SomeObject(...)) better than doing std::unique_ptr a =…
  • 2,384
  • 3
  • 19
  • 20
3 answers

How do we use void_t for SFINAE?

I watched Walter Brown's talk at Cppcon14 about modern template programming (Part I, Part II) where he presented his void_t SFINAE technique. Example: Given a simple variable template that evaluates to void if all template arguments are well…
  • 3,627
  • 6
  • 28
  • 41
7 answers

When should I use C++14 automatic return type deduction?

With GCC 4.8.0 released, we have a compiler that supports automatic return type deduction, part of C++14. With -std=c++1y, I can do this: auto foo() { //deduced to be int return 5; } My question is: When should I use this feature? When is it…
  • 60,560
  • 13
  • 143
  • 205
3 answers

Is it safe to link C++17, C++14, and C++11 objects

Suppose I have three compiled objects, all produced by the same compiler/version: A was compiled with the C++11 standard B was compiled with the C++14 standard C was compiled with the C++17 standard For simplicity, let's assume all headers were…
  • 2,697
  • 4
  • 23
  • 28
2 answers

Is #pragma once part of the C++11 standard?

Traditionally, the standard and portable way to avoid multiple header inclusions in C++ was/is to use the #ifndef - #define - #endifpre-compiler directives scheme also called macro-guard scheme (see code snippet below). #ifndef…
  • 41,839
  • 11
  • 94
  • 168
1 answer

Copy/move assignment in std::vector::erase() and std::deque::erase()

In the process of answering another question I stumbled upon slightly different wordings for std::vector::erase() and std::deque::erase(). This is what C++14 says about std::deque::erase ([deque.modifiers]/4-6, emphasis mine): Effects:…
Anton Savin
  • 40,838
  • 8
  • 54
  • 90
4 answers

How does generic lambda work in C++14?

How does generic lambda work (auto keyword as an argument type) in C++14 standard? Is it based on C++ templates where for each different argument type compiler generates a new function with the same body but replaced types (compile-time…
  • 14,395
  • 10
  • 44
  • 68
4 answers

What are transparent comparators?

In C++14, associative containers seem to have changed from C++11 – [associative.reqmts]/13 says: The member function templates find, count, lower_bound, upper_bound, and equal_range shall not participate in overload resolution unless the type…
Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084
6 answers

error::make_unique is not a member of ‘std’

I am trying to compile the following thread pool program posted on code review to test it. But I am getting the errors threadpool.hpp: In member function…
  • 4,687
  • 7
  • 38
  • 60
2 3
99 100