Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What good programming practices will change with C++11?

Tags:

For example, "Don't return objects by value if they are expensive to copy" (RVO can't always be used). This advice might change because of rvalue references.

The same might be said about storing collections of pointers to objects, because copying them by value into the collection was too expensive; this reason might no longer be valid.

Or the use of enums might be discouraged in favour of "enum class".

What other practices or tips will change?

like image 897
Jon Avatar asked May 29 '10 13:05

Jon


People also ask

What changed in C11?

For the typical C programmer, the biggest change in C11 is its standardized multithreading support. C of course has supported multithreading for decades. However, all of the popular C threading libraries have thus far been non-standard extensions, and hence non-portable. The new C11 header file <threads.

What is the difference between C++11 and C++14?

C++11 allowed lambda functions to deduce the return type based on the type of the expression given to the return statement. C++14 provides this ability to all functions. It also extends these facilities to lambda functions, allowing return type deduction for functions that are not of the form return expression; .

What is the difference between C99 and C11?

C11 looked to address the issues of C99 and to more closely match the C++ standard, C++11. It changes some C99 features required to optional. Some of the features include variable length arrays and complex numbers. This makes it easier for compiler vendors to meet C11's required function set.


2 Answers

I expect that C++ written in a functional-like style will become more prevalent because:

  • Lambda expressions make using the standard library algorithms much easier
  • Move semantics make returning standard library or other RAII container objects significantly cheaper
like image 53
4 revs Avatar answered Sep 18 '22 20:09

4 revs


Improved code locality by using lambda expressions.

like image 21
Pavel Radzivilovsky Avatar answered Sep 22 '22 20:09

Pavel Radzivilovsky