2021 update

This commit is contained in:
federico-busato
2021-03-04 22:54:21 +01:00
parent 2b0c1c4388
commit 81e2668e52
19 changed files with 169 additions and 218 deletions

358
README.md
View File

@@ -1,5 +1,173 @@
# Modern C++ Programming #
## C++11/C++14/C++17 ##
## C++11 / C++14 / C++17 / (C++20) ##
## TOPICS ##
**[1. Introduction](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/01.Introduction.pdf)**
* **A Little History of C/C++ Programming Languages**
* **Areas of Application and Popularity**
* **C++ Philosophy**
* **Books and References**
* **The Course**
**[2. Basic Concepts I - Fundamental Types](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/02.Basic_Concepts_I.pdf)**
* **Preparation**: What compiler should I use?, What editor/IDE compiler should I use?, How to compile?
* **Hello World**: I/O Stream
* **C++ Fundamental Types Overview**: Arithmetic Types, Other Arithmetic Types, Pointer Type
* **Conversion Rules**
* **Math Operators**
* **Integral Data Types**: Fixed Width Integers, When Use Signed/Unsigned Integer?, Promotion, Truncation, Undefined Behavior
* **Floating-point Types and Arithmetic**: Normal/Denormal Values, Summary, Not a Number (`NaN`), Infinity, Properties
* **Floating-point Issues**: Floating-point Comparison, Catastrophic Cancellation
**[3. Basic Concepts II - Entities and Control Flow](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/03.Basic_Concepts_II.pdf)**
* **Enumerators**
* **`struct`, `union`, and Bitfield**
* **`using`, `decltype`, and `auto`**
* **Control Flow**: `if` Statement, `for` Loop, `switch`, `goto`
**[4. Basic Concepts III - Memory Management](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/04.Basic_Concepts_III.pdf)**
* **Heap and Stack**: Stack Memory, `new`, `delete`, Memory Leak
* **Initialization**: Uniform Initialization
* **Pointers and References**: Pointer, Address-of operator `&`, Reference
* **`const`, `constexpr`, `consteval`, `constinit`**
* **Explicit Type Conversion**: `static_cast`, `const_cast`, `reinterpret_cast`, Type Punning
* `sizeof` Operator
**[5. Basic Concepts IV - Functions and Preprocessing](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/05.Basic_Concepts_IV.pdf)**
* **Declaration and Definition**
* **Functions**: Pass by-Value, Pass by-Pointer, Pass by-Reference, Overloading, Default Parameters, `inline` Declaration, Attributes
* **Function Objects and Lambda Expressions**: Function Pointer, Function Object (or Functor), Capture List, Other Features, Capture List and Classes
* **Preprocessing**: Preprocessors, Common Errors, Useful Macro, Stringizing Operator (`#`), `#pragma` and `#error`, Token-Pasting Operator (`##`), Variadic Macro
**[6. C++ Object Oriented Programming I](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/06.Object_Oriented_I.pdf)**
* **C++ Classes**: RAII, Class Hierarchy, Inheritance Attributes
* **Class Constructor**: Default Constructor, Delegate Constructor, `explicit` Keyword
* **Copy Constructor**
* **Class Destructor**
* **Initialization and Defaulted Members**: Initialization List, Uniform Initialization, Defaulted Constructor
* **Class Keywords**: `this`, `static`, `const`, `mutable`, `using`, `friend`, `delete`
**[7. C++ Object Oriented Programming II](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/07.Object_Oriented_II.pdf)**
* **Polymorphism**: `virtual` Methods, Virtual Table, `override` Keyword, `final` Keyword, Common Errors, Pure Virtual Method, Abstract Class and Interface
* **Operator Overloading**: Overview, Subscript Operator, Comparison Operator, Function Call Operator, Conversion Operator, Increment and Decrement Operators, Assignment Operator, Stream Operator, Operator Notes
* **C++ Special Objects**: Aggregate, Trivial Class, Standard-Layout Class, Plain Old Data (POD), Hierarchy
**[8. C++ Templates and Meta-programming I](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/08.Templates_I.pdf)**
* **Function Templates**: Overview, Template Parameters, Template Parameter - Default Value, Specialization, Overloading, `auto` Deduction
* **Compile-Time Utilities**: `static_assert`, `decltype` Keyword, `using` Keyword
* **Type Traits**: Overview, Type Traits Library, Type Manipulation, Type Relation and Transformation
* **Template Parameters**: Overview, Special Cases
**[9. C++ Templates and Meta-programming II](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/9.Templates_II.pdf)**
* **Class Template**: Class Specialization, Class + Function - Specialization, `friend` Keyword, Dependent Names, Template Variable
* **Template Meta-Programming**
* **SFINAE: Substitution Failure Is Not An Error**: Function SFINAE, Class SFINAE, Class + Function SFINAE
* **Variadic Template**: Folding Expression, Variadic Class Template
**[10. Translation Units](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/10.Translation_Units.pdf)**
* **Basic Concepts**: Translation Unit, Local and Global Scopes
* **Linkage**: `static` and `extern` Keywords, Internal/External Linkage Example, Linkage of `const` and constexpr, Linkage of `inline` Functions/Variables
* **Variables Storage**: Storage Class, Storage Duration
* **Dealing with Multiple Translation Units**: One Definition Rule (ODR), Class in Multiple Translation Units, Global Constant
* **Function Template**
* **Class Template**
* **Undefined Behavior and Summary**
* **`#include` Issues**: Forward Declaration, Include Guard, Circular Dependencies, Common Linking Errors
* **Namespace**: Namespace Functions vs. `static` Methods, Namespace Alias, Anonymous Namespace, `inline` Namespace
* **How to Compile**: Compile Strategies, Compile with Libraries, Build Static/Dynamic Libraries, Find Dynamic Library Dependencies, Analyze Object/Executable Symbols
**[11. Code Conventions](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/11.Code_Convention.pdf)**
* **C++ Project Organization**: Project Directories, Project Files, `src/include` directories
* **Coding Styles and Conventions**
* `**#include**`
* **Macro and Preprocessing**
* **Namespace**
* **Variables**
* **Functions**
* **Structs and Classes**
* **Modern C++ Features**
* **Maintainability**
* **Naming and Formatting**
* **Code Documentation**
**[12. Ecosystem](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/12.Ecosystem.pdf)**
* **Debugging**: Assertion, Execution Debugging (`gdb`)
* **Memory Debugging**: `valgrind`
* **Sanitizers**: Address Sanitizer, Leak Sanitizer, Memory Sanitizers, Undefined Behavior Sanitizer
* **Debugging Summary**
* **Code Checking and Analysis**: Compiler Warnings, Static Analyzers
* **Code Testing**: Unit Test, Code Coverage, Fuzz Testing
* **Code Quality**: `clang-tidy`
* **CMake**
* **Code Documentation**: `doxygen`
* **Code Statistics**: Count Lines of Code, Cyclomatic Complexity Analyzer
* **Other Tools**: Code Formatting - `clang-format`, `Compiler Explorer`, Code Transformation - `CppInsights`, Code Autocompletion - `TabNine/Kite`, Local Code Search - `ripgrep`, Code Search Engine - `searchcode/grep.app`, Code Exploration - `SourceTrail`, Code Benchmarking - `Quick-Bench`, Font for Coding
**[13. Utilities](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/13.Utilities.pdf)**
* **I/O Stream**: Manipulator, `ofstream/ifstream`
* **Math Libraries**
* **Strings**: `std::string`, Conversion from/to Numeric Values, `std::string view`, `std::format`
* **Algorithm Library**
* **Random Number**: Basic Concepts, C++ `<random>`, Seed, PRNG Period and Quality, Distribution
Quasi-random
* **Time Measuring**: Wall-Clock Time, User Time, System Time
* **Std Template Classes**: `std::pair`, `std::tuple`, `std::variant`, `std::optional`, `std::any`
* **Filesystem Library**: Query Methods, Modify Methods
**[14. Containers, Iterators, and Algorithms](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/14.Iterators_Containers_Alg.pdf)**
* **Containers and Iterators**
* **Sequence Containers**: `std::array`, `std::vector`, `std::list`, `std::deque`, `std::forward_list`
* **Associative Containers**: `std::set`, `std::map`
* **Container Adaptors**: `std::stack`, `std::queue`, `std::priority_queue`
* **Implement a Custom Iterator**: Semantic, Implement a Simple Iterator
* **Iterator Utility Methods**: `std::advance`, `std::next`, `std::prev`, `std::distance`, Range Access Methods, Iterator Traits
* **Algorithms Library**: `std::find_if`, `std::sort`, `std::accumulate`, `std::generate`, `std::remove_if`
**[15. Advanced Topics](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/15.Advanced_Topics.pdf)**
* **Move Semantic**: `lvalues` and `rvalues` references, Move Semantic, Compiler Implicitly Declared, `std::move`
* **Universal Reference and Perfect Forwarding**: Universal Reference, Reference Collapsing Rules, Perfect Forwarding
* **Value Categories**
* **Copy Elision and RVO**
* **Type Deduction**: Pass-by-Reference, Pass-by-Pointer, Pass-by-Value
* **`const` Correctness**
* **C++ Idioms**: Rule of Zero/Three/Five, Singleton, PIMPL, CRTP, Template Virtual Functions
* **Smart pointers**: `std::unique_ptr`, `std::shared_ptr`, `std::weak_ptr`
* **Concurrency**: Thread Methods, Mutex, Atomic, Task-based parallelism
**[16. Optimization I](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/16.Optimization_I.pdf)**
* **General Concepts**: Asymptotic Complexity, Optimization Cycle, Ahmdal Law, Performance Bounds, Arithmetic Intensity, Instruction-Level Parallelism, Littles Law, Time-Memory Trade-off, Roofline Model
* **I/O Operations**: `printf`, Memory Mapped I/O, Speed Up Raw Data Loading
* **Locality and Memory Access Patterns**: Memory Hierarchy, Memory Locality, Internal Structure Alignment, External Structure Alignment
* **Arithmetic**: Data Types, Operations, Conversion, Floating-Point, Compiler Intrinsic Functions, Value in a Range, Lookup Table
* **Control Flow**: Loop Hoisting, Loop Unrolling, Branch Hints, Recursion
* **Functions**: Function Call Cost, Argument Passing, Function Optimizations, Inlining Constrains, Pointers Aliasing
* **C++ Objects**: C++ Objects Optimizations
**[17. Optimization II](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/17.Optimization_II.pdf)**
* **Compiler Optimizations**: About the Compiler, Architecture Flags, Optimization Flags, Help the Compiler to Produce Better Code, Profile Guided Optimization (PGO)
* **Compiler Transformation Techniques**
* **Libraries and Data Structures**: External Libraries, Std Library
* **Profiling**: `gprof`, `uftrace`, `callgrind`, `cachegrind`, `perf` Linux profiler
* **Performance Benchmarking**: What to Test?, Workload/Dataset Quality, Cache Behavior, Stable CPU Performance, Program Memory Layout
* **Parallel Computing**: Concurrency vs. Parallelism, Performance Scaling, Gustafsons Law, Parallel Programming Languages
### Essential Tool ###
@@ -7,162 +175,6 @@ Online compiler and execution: [CompilerExplorer](https://godbolt.org/)
* for code execution: [Add new..] -> [execution only]
## TOPICS ##
**[1. Introduction](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/01.Introduction.pdf)**
* A Little History of C/C++ Programming Languages
* Areas of Application and Popularity
* C++ Philosophy
* Books and References
* The Course
**[2. Basic Concepts I](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/02.Basic_Concepts_I.pdf)**
* Prerequirements: Compiler, editor, etc.
* Hello World
* C++ Primitive Types
* Integral Data Types
* Floating-point Arithmetic
* Floating-point Issues
**[3. Basic Concepts II](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/03.Basic_Concepts_II.pdf)**
* Enumerators
* `union` and Bitfield
* `using`, `decltype`, and `auto`
* Math Operators
* Statements and Control Flow
**[4. Basic Concepts III](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/04.Basic_Concepts_III.pdf)**
* Memory Management: Heap and Stack
* Initialization
* Pointers and References
* `sizeof` Operator
* `const` and `constexpr`
* Explicit Type Conversion
**[5. Basic Concepts IV](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/05.Basic_Concepts_IV.pdf)**
* Declaration and Definition
* Functions
* Preprocessing
**[6. C++ Object Oriented Programming I](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/06.Object_Oriented_I.pdf)**
* C++ Classes
* Class Constructor
* Copy Construcor
* Class Destructor
* Initialization and Defaulted Members
* Class Keywords
**[7. C++ Object Oriented Programming II](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/07.Object_Oriented_II.pdf)**
* Polymorphism
* Operator overloading
* Special Objects
**[8. C++ Templates and Meta-programming I](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/08.Templates_I.pdf)**
* Function Templates
* Compile-Time Utilities
* Type Traits
* Template Parameters
**[9. C++ Templates and Meta-programming II](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/9.Templates_II.pdf)**
* Class Templates
* Template Meta-Programming
* SFINAE: Substitution Failure Is Not An Error
* Variadic Template
**[10. Translation Units](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/10.Translation_Units.pdf)**
* Basic Concepts
* Linkage
* Variables Storage
* Function Template
* Class Template
* Undefined Behavior and Summary
* `#include` Issues
* Namespace
* How to Compile: static and dynamic libraries
**[11. Code Conventions](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/11.Code_Convention.pdf)**
* C++ Project Organization
* Coding Styles and Conventions
* `#include` and `namespace`
* Variables and Prepossessing
* Functions and Classes
* Modern C++ Features
* Control Flow
* Naming and Formatting
**[12. Ecosystem](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/12.Ecosystem.pdf)**
* Execution Debugging: `gdb` and `assert`
* Memory Debugging: `valgrind`
* Sanitizers: `address`, `leak`, `memory`, `undefined behavior`
* Debugging Summary
* CMake
* Code Checking and Analysis: `warnings` and `static analyzers`
* Code Quality: `linters`
* Code Testing: `unit test`, `coverage`
* Code Commenting: `doxygen`
* Code Statistics: `lines count`, `cyclomatic complexity`
* Other Tools: code `formatting`, `exploring`, `benchmarking`
**[13. Utilities](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/13.Utilities.pdf)**
* I/O Stream
* STD Template Utility
* Filesystem Library
* Math Functions
* Algorithm Library
* `std::string` and `std::string_view`
* Random Numbers
* Time Measuring
**[14. Containers, Iterators, and Algorithms](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/14.Iterators_Containers_Alg.pdf)**
* Containers and Iterators
* Sequence Containers: `array`, `vector`, `list`, `deque`, `forward_list`
* Associative Containers: `set`, `map`
* Container Adaptors: `stack`, `queue`, `priority_queue`
* Implement a Custom Iterator
* Iterator Utility Methods
* Algorithms Library
* Lambda Expressions
**[15. Advanced Topics](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/15.Advanced_Topics.pdf)**
* Move Semantic
* Copy Elision and RVO
* Type deduction
* C++ Idioms: `rule of zero/three/five`, `singleton`, `PILP`, `CRTP`
* Smart Pointers
* Concurrency: `std::thread`
**[16. Optimization I](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/16.Optimization_I.pdf)**
* General Concepts: asymptotic complexity, optimization cycle, Ahmdal Law, etc.
* I/O Operations
* Locality and Memory Access Patterns
* Arithmetic
* Control Flow
* Functions
* C++ Objects
**[17. Optimization II](https://github.com/federico-busato/Modern-CPP-Programming/blob/master/17.Optimization_II.pdf)**
* Compiler Optimizations
* Libraries and Data Structures
* Profiling
* Parallel Computing
### Reporting bugs and contributing ###
If you find any typos, conceptual errors, or sections to improve, please report them by writing directly to me or by using the `issue` panel
@@ -172,35 +184,3 @@ If you find any typos, conceptual errors, or sections to improve, please report
* `Federico Busato`,<br/>
Nvidia Corporation ([fbusato@nvidia.com](mailto:fbusato@nvidia.com))<br/>
Dept. of Computer Science, University of Verona (Italy) [federico.busato@univr.it](mailto:federico.busato@univr.it)
## License ##
> BSD 3-Clause License
>
> Copyright (c) 2020, Modern C++ Programming
> All rights reserved.
>
> Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are met:
>
> * Redistributions of source code must retain the above copyright notice, this
> list of conditions and the following disclaimer.
>
> * Redistributions in binary form must reproduce the above copyright notice,
> this list of conditions and the following disclaimer in the documentation
> and/or other materials provided with the distribution.
>
> * Neither the name of the copyright holder nor the names of its
> contributors may be used to endorse or promote products derived from
> this software without specific prior written permission.
>
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.