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. https://github.com/jfasch/2021-12-06/blob/main/live-hacking/exceptions/exceptions.cpp
Only slightly better: pack both into one
std::pair<>
. https://github.com/jfasch/2021-12-06/blob/main/live-hacking/exceptions/exception-pair.cppThrowing
std::exception
, uncaught (⟶ terminates). https://github.com/jfasch/2021-12-06/blob/main/live-hacking/exceptions/exception-exc.cppHandling
std::exception
. https://github.com/jfasch/2021-12-06/blob/main/live-hacking/exceptions/exception-handling.cppCustom exceptions; order of handling. https://github.com/jfasch/2021-12-06/blob/main/live-hacking/exceptions/exceptions-custom.cpp
Functors: Overloading the Function Call Operator¶
(Better not use integers, better use custom class. User?)
Function with 3 parameters: “How to order 2 numbers”. https://github.com/jfasch/2021-12-06/blob/main/live-hacking/functors/calloperator-problem.cpp
… but want only two ⟶ class with
operator()()
. https://github.com/jfasch/2021-12-06/blob/main/live-hacking/functors/calloperator-solution.cppSort takes comparison function with two arguments. Hardcode one (and be hardcoded to one particular sort order). https://github.com/jfasch/2021-12-06/blob/main/live-hacking/functors/sort-problem.cpp
Functor given to
std::sort<>()
: https://github.com/jfasch/2021-12-06/blob/main/live-hacking/functors/sort-solution.cppDoing all this with Lambda. https://github.com/jfasch/2021-12-06/blob/main/live-hacking/functors/sort-lambda.cpp
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. https://github.com/jfasch/2021-12-06/blob/main/live-hacking/deadlock.cpp
C++ >= 11¶
https://github.com/jfasch/2021-12-06/blob/main/live-hacking/range-based-for.cpp
Building a sum in 1000 different ways (from completely old-school to range based for to
std::accumulate<>()
. https://github.com/jfasch/2021-12-06/blob/main/live-hacking/sum-ints.cppSame with strings. https://github.com/jfasch/2021-12-06/blob/main/live-hacking/sum-strings.cpp
Smart Pointers¶
UserDB Exercise¶
Add boost test
Define requirement: add interface
UserDB
, letUserDB_Vector
derive from it.Define requirement:
UserDB_Map
Miscellaneous¶
References: bring
swap()
example from livehackingWrite down
const
exerciseUser
: how to transform pointers into references.
Complete Transcription of C++11¶
Many of the chapters from the LaTex deck haven’t yet been transcribed.
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