C++ 11
Quick overview
delete - prohibit to auto generate a method
override - declares a method that redefines a base
counterpart
final - forbids any descendant to override the method
from this class
Class declaration
It is required to code:
move semantics
perfect forwarding
Used by default when returning the value.
RValue references
It is used to auto discover types.
Replaces typedef for code clarity.
Could be used to calculate a return type.
Examples:
auto i = 42;
auto p = new foo();
for(auto it = begin(map); it != end(map); ++it)
auto
It solves the ambiguity of NULL macro that has a type
int and confuses templated methods
It has to be used to initialize pointers
nullptr has type std::nullptr_t
nullptr
Foreach concept when indexes and iterators are
irrelevant.
Example:
for(const auto &kvp: map)
{
std::cout << kvp.first << std::endl;
}
Range-based loops
Classical enums had multiple drawbacks:
polluted global namespace
could not hold custom objects but integers
New enum is declared using “enum class”
Example:
enum class Options {None, One, All};
Options o = Options::All;
Strongly-typed enums
unique_ptr - can not be copied
shared_ptr - contains a reference counter
weak_ptr - does not contain a reference counter while
multiple copies are possible. Solves cyclic references
issue.
Smart pointers
This construction is used to create anonymous functions
in place.
Example:
std::for_each(std::begin(v), std::end(v),
[ ](int n) {std::cout << n << std::endl;});
Lambda Functions
This data type is used by methods to return arbitrary
number of values.
Example:
std::tuple<> getTwoValues() {
return make_tuple(2, 3);
}
std::tie (a, b) = getTwoValues();
Tuple data type
Modern C++ by Bo Qian
A Brief Introduction to Rvalue References from B.
Stroustrup
C++ Rvalue References Explained
References

C++ 11

  • 1.
  • 2.
    delete - prohibitto auto generate a method override - declares a method that redefines a base counterpart final - forbids any descendant to override the method from this class Class declaration
  • 3.
    It is requiredto code: move semantics perfect forwarding Used by default when returning the value. RValue references
  • 4.
    It is usedto auto discover types. Replaces typedef for code clarity. Could be used to calculate a return type. Examples: auto i = 42; auto p = new foo(); for(auto it = begin(map); it != end(map); ++it) auto
  • 5.
    It solves theambiguity of NULL macro that has a type int and confuses templated methods It has to be used to initialize pointers nullptr has type std::nullptr_t nullptr
  • 6.
    Foreach concept whenindexes and iterators are irrelevant. Example: for(const auto &kvp: map) { std::cout << kvp.first << std::endl; } Range-based loops
  • 7.
    Classical enums hadmultiple drawbacks: polluted global namespace could not hold custom objects but integers New enum is declared using “enum class” Example: enum class Options {None, One, All}; Options o = Options::All; Strongly-typed enums
  • 8.
    unique_ptr - cannot be copied shared_ptr - contains a reference counter weak_ptr - does not contain a reference counter while multiple copies are possible. Solves cyclic references issue. Smart pointers
  • 9.
    This construction isused to create anonymous functions in place. Example: std::for_each(std::begin(v), std::end(v), [ ](int n) {std::cout << n << std::endl;}); Lambda Functions
  • 10.
    This data typeis used by methods to return arbitrary number of values. Example: std::tuple<> getTwoValues() { return make_tuple(2, 3); } std::tie (a, b) = getTwoValues(); Tuple data type
  • 11.
    Modern C++ byBo Qian A Brief Introduction to Rvalue References from B. Stroustrup C++ Rvalue References Explained References