Modern C++
May 01, 2016
C-style C++
#include <cstdio>
// TODO array of struct* manually allocated
-
manual memory allocation
-
C standard library functions
-
lack of structure
Modern C++
#include <vector>
// TODO vector of RAII*
-
RAII
-
STL
-
Object-Oriented
Modern C++
- smart pointers / nullptr
- rvalue / move semantics
- uniform initialization syntax
- defaulted and delete functions
-
compile-time type tools
- automatic type deduction
- asserts and constexpr
-
Standard Template Library
- iterators
- algorithms
- concurrency
- lambdas
C++11 / C++14
Initialization and Memory
RAII
Resource Acquisition Is Initialization
-
hide resource acquisition in class constructor
-
memory allocation
-
network connections
-
file loading
-
mutex locking
-
-
throw exception on error
-
no naked new/delete
// TODO RAII class
// TODO RAII class usage
Initialization
// TODO vector, map, and object {} init
// TODO class member init
Smart Pointers
- shared_ptr
- unique_ptr
- nullptr
// TODO shared, unique, nullptr, make_shared, new allocation
Move Semantics
-
rvalue vs lvalue
-
std::move
-
std::forward
-
Rule of 5
rvalue
Rule of 5
std::move
Casting
- static_cast
- when to use
- dynamic_cast
- when to use
Compile-Time Programming
Templates and Types
Templates
Generic Programming
// TODO template class
// TODO template function
Variadic Templates
// TODO template class
// TODO template function
auto
// TODO auto assignment
Other Compile-time Goodness
-
constexpr
-
static_assert
// TODO constexpr
// TODO static_assert
STL
Standard Template Library
PRL Modern C++
By Clint Liddick
PRL Modern C++
- 699