Skip to content

Instantly share code, notes, and snippets.

@loderunner
Last active February 7, 2017 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loderunner/8194e388db3f700f4d0e448e92a6ea08 to your computer and use it in GitHub Desktop.
Save loderunner/8194e388db3f700f4d0e448e92a6ea08 to your computer and use it in GitHub Desktop.

C++11

Reference doc http://www.learncpp.com/cpp-tutorial/b-6-new-virtual-function-controls-override-final-default-and-delete/

auto & decltype

Description

Example

Quiz

nullptr

Description

int *p = 0; // legal, 0 has a special meaning as a null pointer
int *q = 1; // illegal, can't assign an int to an int* variable

Example

Enum Classes

Description

  • Type-safe
  • Scoped

Example

Range-based for

Description

Example

static_assert

Description

Example

static_assert(__cplusplus > 199711L, "Program requires C++11 capable compiler");

Quiz

  • Source file with old C++
  • Ask if they see anything we can modernize
  • Reveal full C++11 file

Initializer lists

Description

Example

Uniform initialization

Description

Example

Implicit variables

  • Pass & return implicit variables with uniform initialization
  • Works with const ref

Initializer lists vs initialization lists

MyStruct(int x, int y): m_nX(x), m_nY(y) {}; // m_nX and m_nY are part of the initialization list
Mystruct foo {3, 4}; //// foo initialized using an initializer_list

Back to quiz

  • Create and use an initializer list constructor
  • Pass & return some implicit objects using uniform initialization

Constructor delegation

Description

  • DRY
  • The problem with init()
  • Delegate constructors!

Example

Pattern: Designated constructor

override

Description

Example

final

Description

Example

default

Description

Example

delete

Description

Example

Lambda expressions

Description

Example

C++ lambas aren't closures!

Concurrency

References:

Threads

Locks

Atomics

Pointer semantics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment