Skip to content

Commit 12768e8

Browse files
committed
Simplify smart pointers exercise for essentials course.
Suggest to only work on part 1 and 2 in the essentials course. Part 3 is optional in the essentials.
1 parent 63c1a6a commit 12768e8

File tree

6 files changed

+23
-6
lines changed

6 files changed

+23
-6
lines changed

code/ExerciseSchedule_EssentialCourse.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ Day 3 - Modern C++ Exercises
4949

5050
### Generic programming / templates (directory: [`templates`](templates), [CheatSheet](ExercisesCheatSheet.md#generic-programming--templates-directory-templates))
5151

52-
### Smart pointers (directory: [`smartPointers`](smartPointers), [CheatSheet](ExercisesCheatSheet.md#smart-pointers-directory-smartpointers))
52+
### Smart pointers part 1 and 2 (directory: [`smartPointers`](smartPointers), [CheatSheet](ExercisesCheatSheet.md#smart-pointers-directory-smartpointers))
5353

5454
### Standard algorithms and lambdas (directory: [`stl`](stl), [CheatSheet](ExercisesCheatSheet.md#standard-algorithms-and-lambdas-directory-stl))

code/ExercisesCheatSheet.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ The goal is to use STL algorithms. I would advise to start in this order :
134134
### Smart pointers (directory: [`smartPointers`](smartPointers))
135135
136136
Here we have four code snippets that will benefit from using smart pointers.
137+
**Essentials**: Work on part 1 and 2
138+
**Advanced**: Try all parts
137139
138140
- `problem1` is a simple case of usage of `make_unique` with an observer pattern where the raw pointer should be used.
139141
- `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`).

code/smartPointers/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ and make most cleanup code unnecessary.
2121
```
2222
valgrind --leak-check=full --track-origins=yes ./smartPointers
2323
```
24-
* Go through `problem1()` to `problem3()` and fix the leaks using smart pointers.
25-
* `problem4()` is the most difficult. Skip if not enough time.
24+
* In the **essentials course**, work on `problem1()` and `problem2()`, and fix the leaks using smart pointers.
25+
* In the **advanced course**, work on `problem1()` to `problem4()`. Skip `problem4()` if you don't have enough time.

code/smartPointers/smartPointers.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
* Please fix all memory leaks / ownership problems using smart pointers.
1515
* (Verify by running the program with valgrind!)
1616
*
17-
* In main() at the bottom, comment in all parts as you progress through the exercise.
17+
* In the *essentials course*:
18+
* - Work on problem1() and problem2()
19+
* - You can have a look at problem3() if interested
20+
*
21+
* In the *advanced course*:
22+
* - Work on problem1() to problem4()
23+
*
24+
* In main() at the bottom, comment in the different parts as you progress through the exercise.
1825
*
1926
* Remember that:
2027
* - The unique ownership of data is expressed using unique_ptr.

code/smartPointers/solution/smartPointers.sol.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
* Please fix all memory leaks / ownership problems using smart pointers.
1616
* (Verify by running the program with valgrind!)
1717
*
18-
* In main() at the bottom, comment in all parts as you progress through the exercise.
18+
* In the *essentials course*:
19+
* - Work on problem1() and problem2()
20+
* - You can have a look at problem3() if interested
21+
*
22+
* In the *advanced course*:
23+
* - Work on problem1() to problem4()
24+
*
25+
* In main() at the bottom, comment in the different parts as you progress through the exercise.
1926
*
2027
* Remember that:
2128
* - The unique ownership of data is expressed using unique_ptr.

talk/morelanguage/raii.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@
438438
$ valgrind --leak-check=full --track-origins=yes ./smartPointers
439439
\end{minted}
440440
}
441-
\item Go through {\ttfamily problem1()} to {\ttfamily problem3()} and fix the leaks using smart pointers.
441+
\item In the \emph{essentials course}, go through {\ttfamily problem1()} and {\ttfamily problem2()} and fix the leaks using smart pointers.
442+
\item In the \emph{advanced course}, go through {\ttfamily problem1()} to {\ttfamily problem4()} and fix the leaks using smart pointers.
442443
\item {\ttfamily problem4()} is the most difficult. Skip if not enough time.
443444
\end{itemize}
444445
\end{exercise}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy