C++: TODO List#
Structural#
Move C++03 and C++11, and “C++: Miscellaneous Live-Hacking” into new group, “C++”
Depend c++11 on c++03, topic by topic
Bring pieces of C++: Miscellaneous Live-Hacking to where they belong
STL, Containers and Algorithms#
Misc:
make UserDB_Map exercise refer to multimap<>
extract back-insert-iterator thing, and link to copy<>, reverse_copy<>: Copying and Reversing
OO#
Make an exercise out of UserDB
/UserDB_Vector
/UserDB_Map
Operator Overloading#
Using class Point
Templates/Overloading#
Exceptions#
C style error handling. One return value and one output parameter. Ugly. jfasch/2021-12-06
Only slightly better: pack both into one
std::pair<>
. jfasch/2021-12-06Throwing
std::exception
, uncaught (⟶ terminates). jfasch/2021-12-06Handling
std::exception
. jfasch/2021-12-06Custom exceptions; order of handling. jfasch/2021-12-06
Functors: Overloading the Function Call Operator#
(Better not use integers, better use custom class. User?)
Function with 3 parameters: “How to order 2 numbers”. jfasch/2021-12-06
… but want only two ⟶ class with
operator()()
. jfasch/2021-12-06Sort takes comparison function with two arguments. Hardcode one (and be hardcoded to one particular sort order). jfasch/2021-12-06
Functor given to
std::sort<>()
: jfasch/2021-12-06Doing all this with Lambda. jfasch/2021-12-06
Threads#
Basics: thread-basics.cpp
Start parameters: thread-with-start-parameters.cpp
Lost increment (aka “Mother of All Race Conditions”): thread-lost-increment.cpp
Using a mutex (“toilet door lock”): thread-no-lost-increment-mutex.cpp
Same, but encapsulating the racy integer together with a mutex in a class that behaves like an integer: thread-no-lost-increment-mutex-beautiful.cpp
For integers, though, there is a better way to safety - atomics: thread-no-lost-increment-atomic-fast.cpp
Deadlock. jfasch/2021-12-06
C++ >= 11#
Building a sum in 1000 different ways (from completely old-school to range based for to
std::accumulate<>()
. jfasch/2021-12-06Same with strings. jfasch/2021-12-06
Smart Pointers#
Dependencies#
Exercise series#
point in C
point in C++, members and ctors
shapes, based upon point (circle, triangle, rectangle, …)
access methods
const correctness
operator overloading
Miscellaneous#
Split More Constructors, Destructors in two.
Plain ctor, initializer list.
Exercise
circle
,sphere
,rect
in the middle.Resource management separated, as a preparation to what follows: Object Copy (And Resource Management): There Be Dragons