diff --git a/3-Operators/0-main.ipynb b/3-Operators/0-main.ipynb index c5ceb635ccc2bb1d23fe80a95205ac110840cb9d..289ba8868df46ad3573794f9752d0de6fb8cc7b3 100644 --- a/3-Operators/0-main.ipynb +++ b/3-Operators/0-main.ipynb @@ -4,21 +4,21 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# [Getting started in C++](/) - [Operators](/notebooks/3-Operators/0-main.ipynb)" + "# [Getting started in C++](/) - [Operators](./0-main.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "* [Introduction to the concept of operator overload](/notebooks/3-Operators/1-Intro.ipynb)\n", - " * [TP 9](/notebooks/3-Operators/1b-TP.ipynb)\n", - "* [Comparison operators](/notebooks/3-Operators/2-Comparison.ipynb)\n", - "* [Stream operators](/notebooks/3-Operators/3-Stream.ipynb)\n", - " * [TP 10](/notebooks/3-Operators/3b-TP.ipynb)\n", - "* [Affectation operator and the canonical form of a class](/notebooks/3-Operators/4-CanonicalForm.ipynb)\n", - "* [Functors](/notebooks/3-Operators/5-Functors.ipynb)\n", - " * [TP 11](/notebooks/3-Operators/5b-TP.ipynb)" + "* [Introduction to the concept of operator overload](./1-Intro.ipynb)\n", + " * [TP 9](./1b-TP.ipynb)\n", + "* [Comparison operators](./2-Comparison.ipynb)\n", + "* [Stream operators](./3-Stream.ipynb)\n", + " * [TP 10](./3b-TP.ipynb)\n", + "* [Affectation operator and the canonical form of a class](./4-CanonicalForm.ipynb)\n", + "* [Functors](./5-Functors.ipynb)\n", + " * [TP 11](./5b-TP.ipynb)" ] }, { @@ -26,7 +26,7 @@ "metadata": {}, "source": [ "\n", - "© _CNRS 2016_ - _Inria 2018-2019_ \n", + "© _CNRS 2016_ - _Inria 2018-2020_ \n", "_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) 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/)_ \n", "_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_" ] @@ -36,14 +36,14 @@ "kernelspec": { "display_name": "C++17", "language": "C++17", - "name": "xeus-cling-cpp17" + "name": "xcpp17" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".cpp", "mimetype": "text/x-c++src", "name": "c++", - "version": "-std=c++17" + "version": "17" }, "latex_envs": { "LaTeX_envs_menu_present": true, @@ -83,5 +83,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/3-Operators/1-Intro.ipynb b/3-Operators/1-Intro.ipynb index ab5bb5a14c61b9ff6eae2133027b3028e82bb6ea..b47c8a89e16f4927651ea1eb4d627d2157875aa1 100644 --- a/3-Operators/1-Intro.ipynb +++ b/3-Operators/1-Intro.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# [Getting started in C++](/) - [Operators](/notebooks/3-Operators/0-main.ipynb) - [Introduction](/notebooks/3-Operators/1-Intro.ipynb)" + "# [Getting started in C++](/) - [Operators](./0-main.ipynb) - [Introduction](./1-Intro.ipynb)" ] }, { @@ -535,8 +535,8 @@ "\n", "````\n", "= \n", - ". -> .* ->*\n", - "new delete sizeof\n", + "-> ->*\n", + "new delete\n", "\n", "````\n", "\n", @@ -651,7 +651,7 @@ "metadata": {}, "source": [ "\n", - "© _CNRS 2016_ - _Inria 2018-2019_ \n", + "© _CNRS 2016_ - _Inria 2018-2020_ \n", "_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) 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/)_ \n", "_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_" ] @@ -661,14 +661,14 @@ "kernelspec": { "display_name": "C++17", "language": "C++17", - "name": "xeus-cling-cpp17" + "name": "xcpp17" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".cpp", "mimetype": "text/x-c++src", "name": "c++", - "version": "-std=c++17" + "version": "17" }, "latex_envs": { "LaTeX_envs_menu_present": true, @@ -703,5 +703,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/3-Operators/2-Comparison.ipynb b/3-Operators/2-Comparison.ipynb index 36796c788b0d342c8bfbabcef7db7f04d643c9ad..6d84e709f5c2b0857f6dd09b8a0e79d9e4f36a6f 100644 --- a/3-Operators/2-Comparison.ipynb +++ b/3-Operators/2-Comparison.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# [Getting started in C++](/) - [Operators](/notebooks/3-Operators/0-main.ipynb) - [Comparison operators](/notebooks/3-Operators/2-Comparison.ipynb)" + "# [Getting started in C++](/) - [Operators](./0-main.ipynb) - [Comparison operators](./2-Comparison.ipynb)" ] }, { @@ -90,7 +90,7 @@ "\n", "* `operator>(lhs, rhs)` is `operator<(rhs, lhs)`\n", "* `operator>=(lhs, rhs)` is `!operator<(lhs, rhs)`\n", - "* `operator<=(lhs, rhs)` is `!operator<(rhs, lhs)`\n", + "* `operator<=(lhs, rhs)` is `!operator>(rhs, lhs)`\n", "\n", "\n", "As always with operators overloading, make sure your implementation is consistent: it's not because you might define an operator `<` which is not the negation of `>=` that you should do it!\n", @@ -187,7 +187,7 @@ "metadata": {}, "source": [ "\n", - "© _CNRS 2016_ - _Inria 2018-2019_ \n", + "© _CNRS 2016_ - _Inria 2018-2020_ \n", "_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) 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/)_ \n", "_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_" ] @@ -197,14 +197,14 @@ "kernelspec": { "display_name": "C++17", "language": "C++17", - "name": "xeus-cling-cpp17" + "name": "xcpp17" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".cpp", "mimetype": "text/x-c++src", "name": "c++", - "version": "-std=c++17" + "version": "17" }, "latex_envs": { "LaTeX_envs_menu_present": true, @@ -239,5 +239,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/3-Operators/3-Stream.ipynb b/3-Operators/3-Stream.ipynb index 867f8964031d45419b4797e35d31e60781538707..121e06496bc733f7f8e87d1dc6bbc1cfde8cd746 100644 --- a/3-Operators/3-Stream.ipynb +++ b/3-Operators/3-Stream.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# [Getting started in C++](/) - [Operators](/notebooks/3-Operators/0-main.ipynb) - [Stream operators](/notebooks/3-Operators/3-Stream.ipynb)" + "# [Getting started in C++](/) - [Operators](./0-main.ipynb) - [Stream operators](./3-Stream.ipynb)" ] }, { @@ -14,14 +14,14 @@ }, "source": [ "<h1>Table of contents<span class=\"tocSkip\"></span></h1>\n", - "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Operators-<<\" data-toc-modified-id=\"Operators-<<-1\">Operators <<</a></span></li><li><span><a href=\"#Operator>>\" data-toc-modified-id=\"Operator>>-2\">Operator>></a></span></li></ul></div>" + "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Operator-<<\" data-toc-modified-id=\"Operator-<<-1\">Operator <<</a></span></li><li><span><a href=\"#Operator->>\" data-toc-modified-id=\"Operator->>-2\">Operator >></a></span></li></ul></div>" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Operators <<\n", + "## Operator <<\n", "\n", "So far, we have very often defined methods and/or functions named `Print()` to provide a visual printing of the content of a class.\n", "\n", @@ -72,7 +72,7 @@ "\n", "std::ostream& operator<<(std::ostream& out, const Rational& r)\n", "{\n", - " r.Print(out); // see how the buk of the work is done by the 'Print()' method!\n", + " r.Print(out); // see how the bulk of the work is done by the 'Print()' method!\n", " return out;\n", "}\n", "\n", @@ -120,7 +120,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Operator>>\n", + "## Operator >>\n", "\n", "Operator>> might be overloaded in a similar way; it might be used for instance to create an object from data readin a file. As usual with `operator>>`, you should be cautious and handle well the case in which the flux becomes invalid:" ] @@ -241,7 +241,7 @@ "metadata": {}, "source": [ "\n", - "© _CNRS 2016_ - _Inria 2018-2019_ \n", + "© _CNRS 2016_ - _Inria 2018-2020_ \n", "_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) 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/)_ \n", "_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_" ] @@ -251,14 +251,14 @@ "kernelspec": { "display_name": "C++17", "language": "C++17", - "name": "xeus-cling-cpp17" + "name": "xcpp17" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".cpp", "mimetype": "text/x-c++src", "name": "c++", - "version": "-std=c++17" + "version": "17" }, "latex_envs": { "LaTeX_envs_menu_present": true, @@ -298,5 +298,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/3-Operators/4-CanonicalForm.ipynb b/3-Operators/4-CanonicalForm.ipynb index 2cc788ed2671c932ac5da0964a6fe2b235ea1cac..9affdb088b2711c53918b4e4274367e55e15f0c6 100644 --- a/3-Operators/4-CanonicalForm.ipynb +++ b/3-Operators/4-CanonicalForm.ipynb @@ -291,7 +291,7 @@ "source": [ "### Uncopyable class\n", "\n", - "In fact when I said by default an affectation operator is made available for the class, I was overly simplifying the issue. Lets consider for instance a class with a reference data attribute:" + "In fact when I said by default an affectation operator is made available for the class, I was overly simplifying the issue. Let's consider for instance a class with a reference data attribute:" ] }, { @@ -436,10 +436,10 @@ "Copy construction may in fact be quite dangerous:\n", "\n", "* As we've just seen, affectation and construction may differ in implementation, which is not a good thing. There are ways to define one in function of the other (see for instance item 11 of \\cite{Meyers2005}) but they aren't that trivial.\n", - "* Depending on complicated rules, some might or might not be defined implicitly.\n", + "* Depending on somewhat complicated rules that have evolved with standard versions, some might or might not be defined implicitly.\n", "* More importantly, affectation operators may be a nightmare to maintain. Imagine you have a class for which you overload manually the affectation operator and/or the copy constructor. If later you add a new data attribute, you have to make sure not to forget to add it in both implementations; if you forget once you will enter the real of undefined behaviour... and good luck for you to find the origin of the bug!\n", "\n", - "To avoid that I took the extreme rule to never overload those myself:\n", + "To avoid that I took the extreme rule to (almost) never overload those myself:\n", "\n", "* As explained briefly above, using appropriate container may remove the need. `Vector3` could be written with a `std::array` instead of the dynamic array, and the STL object will be properly copied with default behaviour!\n", "* I define explicitly in my classes the behaviour of these operators with `= default` or `= delete` syntaxes. More often than not, my objects have no business being copied and `= delete` is really my default choice (this keyword indicates to the compiler the operator should not be provided for the class).\n", @@ -550,7 +550,7 @@ "metadata": {}, "source": [ "\n", - "© _CNRS 2016_ - _Inria 2018-2019_ \n", + "© _CNRS 2016_ - _Inria 2018-2020_ \n", "_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) 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/)_ \n", "_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_" ] @@ -560,14 +560,14 @@ "kernelspec": { "display_name": "C++17", "language": "C++17", - "name": "xeus-cling-cpp17" + "name": "xcpp17" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".cpp", "mimetype": "text/x-c++src", "name": "c++", - "version": "-std=c++17" + "version": "17" }, "latex_envs": { "LaTeX_envs_menu_present": true, @@ -602,5 +602,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/3-Operators/5-Functors.ipynb b/3-Operators/5-Functors.ipynb index 631237c2198115bd88d2bfc8552aaaed5825e517..53f4ca9d3e3af97cfa722b992aa8672ef47a0858 100644 --- a/3-Operators/5-Functors.ipynb +++ b/3-Operators/5-Functors.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# [Getting started in C++](/) - [Operators](/notebooks/3-Operators/0-main.ipynb) - [Functors](/notebooks/3-Operators/5-Functors.ipynb)" + "# [Getting started in C++](/) - [Operators](./0-main.ipynb) - [Functors](./5-Functors.ipynb)" ] }, { @@ -94,7 +94,7 @@ "\n", "## Functors in STL\n", "\n", - "STL itself defines some functors: imagine you want to sort a `std::vector` decreasingly; you can't directly put `>` as the comparison operation in sort and use the STL-defined `greater`: " + "STL itself defines some functors: imagine you want to sort a `std::vector` decreasingly; you can't directly put `>` as the comparison operation in `sort` and therefore may use a specific STL-defined `greater`: " ] }, { @@ -121,7 +121,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "C++ 11 and above limits the need for functors with lambda functions, but in older codes functors were one of the way to pass your own rules to some STL algorithms, along with pointer to functions." + "C++ 11 and above limits the need for functors with lambda functions (see [earlier](../1-ProceduralProgramming/4-Functions.ipynb#Lambda-functions)), but in older codes functors were one of the way to pass your own rules to some STL algorithms, along with pointer to functions." ] }, { @@ -129,7 +129,7 @@ "metadata": {}, "source": [ "\n", - "© _CNRS 2016_ - _Inria 2018-2019_ \n", + "© _CNRS 2016_ - _Inria 2018-2020_ \n", "_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) 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/)_ \n", "_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_" ] @@ -139,14 +139,14 @@ "kernelspec": { "display_name": "C++17", "language": "C++17", - "name": "xeus-cling-cpp17" + "name": "xcpp17" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".cpp", "mimetype": "text/x-c++src", "name": "c++", - "version": "-std=c++17" + "version": "17" }, "latex_envs": { "LaTeX_envs_menu_present": true, @@ -181,5 +181,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }