From 8cb6a7689a9216346cf389e97250040c63baec73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gilles?= <sebastien.gilles@inria.fr> Date: Wed, 28 Sep 2022 18:42:25 +0200 Subject: [PATCH] Minor changes in Appendix. --- 7-Appendix/0-main.ipynb | 4 ++-- 7-Appendix/HomemadeException.ipynb | 4 ++-- 7-Appendix/StringView.ipynb | 18 +++++++++--------- 7-Appendix/Switch.ipynb | 2 +- 7-Appendix/WeakPtr.ipynb | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/7-Appendix/0-main.ipynb b/7-Appendix/0-main.ipynb index 082a176..3aed159 100644 --- a/7-Appendix/0-main.ipynb +++ b/7-Appendix/0-main.ipynb @@ -13,10 +13,10 @@ "source": [ "This appendix groups some stuff just mentioned in earlier tutorials but that I have chosen not to speak longly about because the lecture is already long enough as it is and they might be a tiny bit more complex for some of them.\n", "\n", - "* [Breaking circular definition of shared pointers with weak pointers](./WeakPtr.ipynb) explains how to set up properly a circular relationship shared/weak pointers (unfortunately the way to set it up properly is often coyly mentioned but not explained); this is a follow-up of the notebook about [smart pointers](../5-UsefulConceptsAndSTL/6-SmartPointers.ipynb).\n", - "\n", "* [CRTP](./Crtp.ipynb) is one of my favourite idiom to provide a same functionality to utterly different classes; it was teased in the [notebook](../4-Templates/5-MoreAdvanced.ipynb) about advanced features with templates.\n", "\n", + "* [Breaking circular definition of shared pointers with weak pointers](./WeakPtr.ipynb) explains how to set up properly a circular relationship shared/weak pointers (unfortunately the way to set it up properly is often coyly mentioned but not explained); this is a follow-up of the notebook about [smart pointers](../5-UsefulConceptsAndSTL/6-SmartPointers.ipynb). An existing CRTP from STL is used there at some point so you should probably consider reading it after the one explaining CRTP, but it is by no means a hard prerequisite.\n", + "\n", "* [Homemade exceptions](./HomemadeException.ipynb) just provides the instantiation of the class I personally use when I want to raise an exception; it's a direct follow-up of the section that [mentioned it](../5-UsefulConceptsAndSTL/1-ErrorHandling.ipynb#The-exception-class-I-use).\n", "\n", "* [Switch](./Switch.ipynb) is the less important one: it just explains `switch` statement and the syntax caveats you might encounter with them. It was mentioned in the [early notebook](../1-ProceduralProgramming/2-Conditions-and-loops.ipynb#switch-statement) about conditions.\n", diff --git a/7-Appendix/HomemadeException.ipynb b/7-Appendix/HomemadeException.ipynb index 0509f12..a5ddc92 100644 --- a/7-Appendix/HomemadeException.ipynb +++ b/7-Appendix/HomemadeException.ipynb @@ -93,7 +93,7 @@ "\n", "### Indicating the file and line\n", "\n", - "If your code is huge, knowing the exception itself is not enough, if this exception may be thrown from several locations in your code. To identify where the exception was thrown, I use the `__FILE__` and `__LINE__` macro which gives the file and line where they were found in the code (better alternative [may appear](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4562.html#reflection.src_loc) in C++ 20).\n", + "If your code is huge, knowing the exception itself is not enough, if this exception may be thrown from several locations in your code. To identify where the exception was thrown, I use the `__FILE__` and `__LINE__` macro which gives the file and line where they were found in the code (better alternative `std::source_location` is present in C++ 20 but is unfortunately [not well supported yet](https://en.cppreference.com/w/cpp/compiler_support)).\n", "\n", "So my constructor looks like:\n", "\n", @@ -348,5 +348,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/7-Appendix/StringView.ipynb b/7-Appendix/StringView.ipynb index d5cc586..1e0887b 100644 --- a/7-Appendix/StringView.ipynb +++ b/7-Appendix/StringView.ipynb @@ -29,7 +29,7 @@ "#include <string_view>\n", "#include <iostream>\n", "\n", - "void print(std::string_view content)\n", + "void Print(std::string_view content)\n", "{\n", " std::cout << \"Content is '\" << content << \"'\" << std::endl;\n", "}\n", @@ -37,9 +37,9 @@ "\n", "std::string hello(\"Hello world from std::string!\");\n", "\n", - "print(hello);\n", + "Print(hello);\n", "\n", - "print(\"Hello world!\");" + "Print(\"Hello world!\");" ] }, { @@ -60,7 +60,7 @@ "#include <string>\n", "#include <iostream>\n", "\n", - "void print_with_const_ref(const std::string& content)\n", + "void PrintWithConstRef(const std::string& content)\n", "{\n", " std::cout << \"Content is '\" << content << \"'\" << std::endl;\n", "}\n", @@ -68,8 +68,8 @@ "\n", "std::string hello(\"Hello world from std::string!\");\n", "\n", - "print_with_const_ref(hello);\n", - "print_with_const_ref(\"Hello world!\");" + "PrintWithConstRef(hello);\n", + "PrintWithConstRef(\"Hello world!\");" ] }, { @@ -100,12 +100,12 @@ "#include <string>\n", "#include <iostream>\n", "\n", - "void print_with_ref(std::string& content)\n", + "void PrintWithRef(std::string& content)\n", "{\n", " std::cout << \"Content is '\" << content << \"'\" << std::endl;\n", "}\n", "\n", - "print_with_ref(\"Hello world!\"); // COMPILATION ERROR!" + "PrintWithRef(\"Hello world!\"); // COMPILATION ERROR!" ] }, { @@ -159,7 +159,7 @@ "metadata": {}, "source": [ "\n", - "© _Inria 2021-2022_ \n", + "© _Inria 2021_ \n", "_This notebook is released under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ " ] } diff --git a/7-Appendix/Switch.ipynb b/7-Appendix/Switch.ipynb index 4b550a6..db7f3ee 100644 --- a/7-Appendix/Switch.ipynb +++ b/7-Appendix/Switch.ipynb @@ -302,5 +302,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/7-Appendix/WeakPtr.ipynb b/7-Appendix/WeakPtr.ipynb index 99eea7d..7056799 100644 --- a/7-Appendix/WeakPtr.ipynb +++ b/7-Appendix/WeakPtr.ipynb @@ -225,7 +225,7 @@ "\n", "It is only used for storage; you can't use the object underneath directly and have to build a `shared_ptr` from it before use with the method `lock()`. \n", "\n", - "There are just two modifications to do (used to be done here but circa 2021 Xeus emit a link so the code will be put instead [@Coliru](http://coliru.stacked-crooked.com/a/2013674aee9983d5):" + "There are just two modifications to do (used to be done here but circa 2021 Xeus emit a link so the code will be put instead [@Coliru](http://coliru.stacked-crooked.com/a/2013674aee9983d5)):" ] }, { @@ -314,7 +314,7 @@ "source": [ "This code causes an issue (which might be a crash or an error depending on your platform): the vector still includes `Yoda` as a child of `Darth Vader`, whereas the object no longer exists (we're once again in undefined behavior territory).\n", "\n", - "There is a method `expired()` that returns `true` if the underlying object no longer exists; but in fact lock gets a return value that may be used to the same purpose (see [@Coliru](http://coliru.stacked-crooked.com/a/fcdb5cf21897e4ef)):" + "There is a method `expired()` that returns `true` if the underlying object no longer exists; but in fact `lock()` gets a return value that may be used to the same purpose (see [@Coliru](http://coliru.stacked-crooked.com/a/fcdb5cf21897e4ef)):" ] }, { @@ -741,5 +741,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } -- GitLab