Moving Up to Modern C++: An Overview of C++11/14/17

01

Course Overview

This introduction to Modern C++ surveys additions to the C++ language introduced in C++11, C++14 and C++17, featuring support for

  • Increased code clarity (lambdas, uniform initialization, auto, new OOD control)
  • Improved performance (rvalue references, move semantics and perfect forwarding)
  • Concurrency (multiple threads, synchronization techniques, asynchronous task support, condition variables and atomic types).
02

Key Learning Areas

Also covered are all of the language’s miscellaneous new convenience features and a look at some of the key new standard library components (smart pointers, tuples, new STL containers, std::function, type traits, etc.).

03

Course Outline

C++ Timeline

Goals for C++11/14

Part I: The Simpler Core Language Features

    • auto, decltype, trailing return types
    • Non-member begin()/end()
    • nullptr
    • Generalized function return type deduction (C++14)
    • auto vs. decltype(auto) (C++14)
    • Range for
    • >> in class template specializations
    • static_assert
    • extern template
    • noexcept
    • New initialization features
      • Initializer lists
      • Uniform initialization
      • Prevention of narrowing
    • Variadic templates
      • Fold expressions (C++17)
    • constexpr functions and data
    • Template alias
    • Variable templates (C++14)
    • The return of file scope static variables
    • Character- and String-related functionality
      • New unicode character types
      • String literals and const
      • Raw string literals
      • User-defined literals (UDLs)
    • inline namespaces
    • Attributes
    • Fixed-width integer types
    • New features of enums
      • Scoped enums
      • Specifying the underlying type
      • Forward-declared enums
    • long long
    • alignas / alignof
    • Generalized PODs
    • Binary literals (C++14)
    • Single quotes as digit separators (C++14)
    • Class template argument deduction (C++17)
    • Guaranteed copy elision (C++17)
    • Order of expression evaluation guarantees (C++17)
    • inline variables (C++17)
    • if constexpr (C++17)
    • Structured bindings (C++17)
    • New if and switch initializer syntax (C++17)
    • Nested namespaces (C++17)
    • Language features removed in C++17

Part II: Larger Language Features

    • Lambdas
      • Lambda expressions and closures
      • Capture modes
        • Avoid default capture modes
      • Lambdas as “local functions”
      • Generic lambdas (C++14)
      • Generalized lambda capture (C++14)
    • Move semantics
      • Lvalues and rvalues (the modern view)
      • Rvalue references
      • “move” operations
      • Reference collapsing and universal (“forwarding”) references
      • Perfect forwarding
      • When move-enable a type?
      • The Rule of 5

Part III: Features Supporting Better Class Design

    • Generated functions,  =default, =delete
    • Override control: override / final
    • Delegating constructors
    • Increased flexibility for in-class initializers
    • Inheriting constructors
    • Explicit conversion operators
    • Reference-qualified member functions

Part IV: Concurrency

    • Threads
    • join() and detach()
    • Passing arguments to threads
    • Data lifetime considerations
    • Synchronization with mutexes and locking
      • Avoiding deadlock
      • mutex and mutex-wrapper types
      • lock_guard, unique_lock and shared_lock
    • Returning values from threads
      • async()
      • Launch policies
      • Futures
      • Querying future status
    • Condition variables
    • Thread-local storage
    • Thread-safe block-scope static initialization
    • Atomics

Part V: New Library Components

    • std::tuple
    • Type Traits
      • Traits classes and tag dispatch
      • Standard type traits
      • std::enable_if
    • New Function/Function Object Facilities
      • std::function
      • std::bind
    • Smart Pointers
      • std::unique_ptr
      • std::shared_ptr
      • Custom deleters
      • std::weak_ptr
      • make_shared and make_unique
    • Fixed-length Array
      • std::array
    • Hash-based Containers
      • std::unordered_*
    • Performance enhancements
    • Library components removed in C++17

Epilogue: Is C++ Too Complicated?

References / Resources

Lab Exercises

    • New initialization rules
    • Lambdas
    • Performance characteristics of moving vs. copying
    • Implementing a variadic function template
04

Who Benefits

The presentation is designed for those who need a quick overview of the new C++, so the focus is on how to use the new language features and library components, where writing new code or migrating older C++ code to the Modern dialect.

Whenever practical, Modern C++ features are presented in a style showcasing how they contrast with and improve over their “Legacy” C++ counterparts.

05

Prerequisites

Attendees should have extensive prior development experience with C++98/C++03, including Standard Template Library components (standard containers, algorithms, iterators and function objects). A list of the specific STL components the course assumes familiarity with is available upon request.

Want this course for your team?

Atmosera can provide this course virtually or on-site. Please reach out to discuss your requirements.

Atmosera is thrilled to announce that we have been named GitHub AI Partner of the Year.

X