Commit 7f710e59 authored by Alexander Hirsch's avatar Alexander Hirsch

ex02: Replace RAII exercise

parent c8f6470a
......@@ -4,27 +4,11 @@
## Task 1 (4 Points)
This task focuses on the correct implementation of RAII as well as copy and move semantics.
You are asked to implement the concept of `unique_ptr` and `shared_ptr`.
Since we won't concern ourselves with templates for the moment your implementation will *own* an instance of the following `struct`.
struct Vec2 {
float x, y;
- Read the documentation regarding *smart pointers*, `unique_ptr`, and `shared_ptr`
- Implement your version of `unique_ptr_to_vec2` and `shared_ptr_to_vec2` fulfilling these requirements:
- *Dynamically* allocate an instance of `Vec2` in your constructor (initialise `x` and `y` to `0.0`)
- Deallocate the `Vec2` instance in your destructor
- Implement correct copy semantics (copy constructor / copy assignment)
- Implement correct move semantics (move constructor / move assignment)
- Enable access to `Vec2` via the operators `*` and `->`
- Thread-safety for `shared_ptr_to_vec2`'s reference counter is not required
- Pay attention to corner-cases like self-assignment (`v = v`)
- Prepare a few interesting test cases for your presentation
- Check your implementation for memory leaks and memory corruptions using `valgrind`
Skim over the C++ Core Guidelines and pick 5 rules you find interesting.
Prepare these 5 rules for presentation.
At this point, some things may still be a mystery to you.
Research the yet unknown concepts and techniques mentioned in the C++ Core Guidelines relevant to the bullets you picked.
Be prepared to give a short summary of these concepts and techniques in your presentation so your fellow students can follow.
## Task 2 (2 Points)
......@@ -54,6 +38,5 @@ What is really happening here?
- 🎥 [CppCon 2015 — *Give me 15 minutes & I'll change your view of GDB*](
- [Iterator Invalidation](
- [Undefined Behaviour](
- [Rule of Three](
- [Defining the undefinedness of C](
- [It's Time To Do CMake Right](
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment