Skip to content

Commit b45ee7d

Browse files
update cheat sheet _All by _TheEssentials
1 parent 5d14cca commit b45ee7d

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

code/ExercisesCheatSheet_All.md

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -194,33 +194,24 @@ It can then be tried with e.g. reverse ordering of strings or an order of Comple
194194
195195
Level 3 : use the genericity of the Complex class and play with Complex of integers or Complex of Complex
196196
197-
### Standard algorithms (directory: `stl`)
197+
### Smart pointers (directory: `smartPointers`)
198+
199+
Here we have four code snippets that will benefit from using smart pointers.
200+
201+
- `problem1` is a simple case of usage of `make_unique` with an observer pattern where the raw pointer should be used.
202+
- `problem2` is an example of a collection of pointers. Move semantic has to be used to transfer ownership of newly created objects to the container (alternatively, `emplace_back`).
203+
- `problem3` is an example of shared ownership where `std::shared_pointer` should be used.
204+
- `problem4` demonstrates the usage of `shared_ptr` as class members. It has a second part where a `weak_ptr` can be used, but can be skipped if not enough time.
205+
206+
### Standard algorithms and lambdas (directory: `stl`)
198207
199208
The goal is to use STL algorithms. I would advise to start in this order :
200209
201210
- random_shuffle
202211
- adjacent_difference
203212
- first accumulate (the one for sums)
204-
- second accumulate (sum of squares) with usage of "sumsquare<T>()" as BinaryOperation
205-
- generate
206-
207-
One may want to only do the first 3 and go to next exercise to directly use lambdas for step 4 and 5;
208-
209-
### Lambda functions (directory: `lambdas`)
210-
211-
Can be merged into previous exercise as the easy (and modern) solution to step 4 and 5 where functors were needed in the STL exercises.
212-
213-
The accumulate lambda is a simple one, the one for generate involves a state to be captured by reference.
214-
215-
### Smart pointers (directory: `smartPointers`)
216-
217-
Here we have four code snippets that will benefit from using smart pointers.
218-
219-
- `problem1` is a simple case of usage of `make_unique` with an observer pattern where the raw pointer should be used.
220-
- `problem2` is an example of a collection of pointers. Move semantic has to be used to transfer ownership of newly created objects to the container (alternatively, `emplace_back`).
221-
- `problem3` is an example of shared ownership where `std::shared_pointer` should be used.
222-
- `problem4` demonstrates the usage of `shared_ptr` as class members. It has a second part where a `weak_ptr` can be used, but can be skipped if not enough time.
223-
213+
- second accumulate (using lambda to compute sum of squares)
214+
- generate (involves a state to be captured by reference)
224215
225216
### Move semantic (directory: `move`)
226217

0 commit comments

Comments
 (0)