C++: A New Language Starting In 2011

Metadata

Course Preparation

We will be doing a number of exercises and trainer livehacking sessions. All this is done starting from a skeleton Github project.

Please try and get the skeleton project, create an environment that works for you, and test-build that project.

Work Environment

I suggest you use the Windows Subsystem For Linux (WSL2) (Microsoft documentation here). This sets up a virtualized Ubuntu inside Windows, together with all interoperability wazoo.

It is also possible to setup a Linux-like environment on native Windows, using the following emulation layers

  • Cygwin

  • MinGW (known to have problems when it comes to threading)

Skeleton Project

The project uses CMake and googletest. Ideal work anvironment is Linux(-like). If you have such an environment, then the steps to build the project are,

  • Clone and massage the project source

    $ pwd
    $ /home/jfasch/src       # <--- your mileage will vary
    $ git clone https://github.com/jfasch/2022-07-26.git
    $ cd 2022-07-26/
    $ git submodule init
    $ git submodule update
    
  • Create build directory, and chdir there

    $ mkdir /tmp/2022-07-26-build
    $ cd /tmp/2022-07-26-build
    
  • Use CMake to create makefiles

    $ pwd
    /tmp/2022-07-26-build
    $ cmake /home/jfasch/src/2022-07-26
    
  • Build

    $ pwd
    /tmp/2022-07-26-build
    $ make
    
  • Test

    $ pwd
    /tmp/2022-07-26-build
    $ ./exercises/exercises-suite
    Running main() from /home/jfasch/tmp/2022-07-26/googletest/googletest/src/gtest_main.cc
    [==========] Running 1 test from 1 test suite.
    [----------] Global test environment set-up.
    [----------] 1 test from dummy_suite
    [ RUN      ] dummy_suite.fail
    /home/jfasch/tmp/2022-07-26/exercises/fail.cpp:5: Failure
    Failed
    [  FAILED  ] dummy_suite.fail (0 ms)
    [----------] 1 test from dummy_suite (0 ms total)
    
    [----------] Global test environment tear-down
    [==========] 1 test from 1 test suite ran. (0 ms total)
    [  PASSED  ] 0 tests.
    [  FAILED  ] 1 test, listed below:
    [  FAILED  ] dummy_suite.fail
    
     1 FAILED TEST
    

Introduction

Pythonicity (Thank You: Readablility and Writability)

Range Based for Loops

Tuple Unpacking (err, Structured Binding)

Duck Typing (err, auto) Without A Duck

Exercise

Things That Simply Deserved Fixing Since Ages

Brace Initialization

From Brace Initialization (Uniform Initialization)

New OO keywords: override, final, default, delete

Strongly Typed enum

Delegating Constructor

nullptr

Smart Pointers

From Smart Pointers (std::unique_ptr, std::shared_ptr):

Moving, “RValue References”

Functions (std::bind<>, std::function<>, Lambdas)

From Functions, Functions:

From Lambda

Multithreading

From Multithreading:

Miscellaneous

TODO: Important

Topic

Description

std::any<>, std::optional<>, std::variant<>

vector<>::emplace_back()

forward

array

ref, cref

TODO: Optional

Topic

Description

new containers and algorithms (next to beginning somewhere)

File system library

chrono += how to sleep

Done in various live hacking session on the way; add to slide material

Regular expression library

(Raw) string literal

constexpr, constexpr if (since C++17)