Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Modern C++ Programming Course (C++11/14/17/20)

NotificationsYou must be signed in to change notification settings

theKcoder/Modern-CPP-Programming

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++11 / C++14 / C++17 / C++20 / (C++23)

Thisopen-access course is directed at those who are already familiar with C and object-oriented programming towards a proficiency level of C++ programming. The course covers the basics of C++ programming and moves on to advanced C++ semantics and concepts.

Key features:

  • Free and frequently updated
  • Include thelast language standard concepts and features
  • Practical teaching: small structured descriptions associated to code
  • Minimal code examples for showing just a specific feature or issue without digressing
  • Complementary language aspects: tools, coding conventions, project organization, and code optimization
  • Experience-based: many aspects, examples, and problems come from real-world cases faced during my work as software engineer

If you enjoy the course or you find it useful, please add aStar

stars - Modern-CPP-Programming

CHAPTERS

TITLEMAIN FOCUS
1IntroductionHistory of C/C++, Areas of Applications, Course introduction
2Basic Concepts I - Fundamental TypesIntegral data types, floating-point, operators, and conversion
3Basic Concepts II - Entities and Control FlowEnumerators, structures, control flow statements
4Basic Concepts III - Memory ManagementHeap, Stack, pointers, references, const properties, conversion operators
5Basic Concepts IV - Functions and PreprocessingFunctions, lambda expressions, preprocessing directives
6C++ Object Oriented Programming I - Class ConceptsClass hierarchy, constructor, destructor, class keywords
7C++ Object Oriented Programming II - Polymorphism and Operator OverloadingPolymorphism, operators overloading
8C++ Templates and Meta-programming I - Function Templates and Compile-Time UtilitiesFunction template, type traits
9C++ Templates and Meta-programming II - Class Templates and SFINAEClass template, SFINAE
10Translation Units ILinkage and One Definition Rule
11Translation Units IIDealing with multiple translation units and files,  #include, and modules
12Code ConventionsProject organization and main code conventions
13Ecosystem IDebugging, and testing
14Ecosystem IICmake, documenting, and other Tools
15UtilitiesMainstd libraries
16Containers, Iterators, and AlgorithmsContainers, iterators, algorithms, ranges
17Advanced Topics IMove semantics, universal reference, type deduction
18Advanced Topics IIError handling, C++ idioms, smart pointers
19Optimization I - Basic ConceptsAhmdal Law, performance bounds, architecture concepts (ILP, SIMD, etc.), memory hierarchy
20Optimization II - Code OptimizationArithmetic optimizations, memory optimizations, etc.
21Optimization III - Non-Coding Optimizations and BenchmarkingCompiler optimizations, profiling and benchmarking tools

TOPICS IN DETAILS

1. Introduction

  • A Little History of C/C++ Programming Languages
  • Areas of Application and Popularity
  • C++ Philosophy
  • C++ Weakness
  • Books and References
  • The Course

2. Basic Concepts I - Fundamental Types

  • 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, Non-standard arithmetic types,void type, Pointer type andnullptr
  • Conversion Rules
  • auto declaration
  • C++ Operators: Operators precedence, Prefix/Postfix increment/decrement, Assignment, Compound , and comma operators, Spaceship operator<=> , Safe Comparison Operators
  • Integral Data Types: Fixed width integers andsize_t, When use signed/unsigned integer? Promotion, Truncation, Undefined behavior
  • Floating-point Types and Arithmetic: Normal/Denormal values, Infinity, Not a Number (NaN), Summary, Properties
  • Floating-point Issues: Catastrophic cancellation, Floating-point comparison

3. Basic Concepts II - Entities and Control Flow

  • Enumerators
  • struct, Bitfield,union
  • Control Flow:if Statement,for Loop, Range-basefor loop,switch,goto

4. Basic Concepts III - Memory Management

  • Heap and Stack: Stack Memory,new,delete, Non-allocating placement allocation, Non-throwing allocation, Memory leak
  • Initialization: Variable initialization, Uniform initialization, Fixed-size array initialization, Structure initialization, Dynamic array initialization
  • Pointers and References: Pointer Operations, Address-of operator&, Reference
  • Constant and Literals,const,constexpr,consteval,constinit
  • Explicit Type Conversion:static_cast,const_cast,reinterpret_cast, Type punning
  • sizeof Operator

5. Basic Concepts IV - Functions and Preprocessing

  • Declaration and Definition
  • Functions: Pass by-value, Pass by-pointer, Pass by-reference, Function signature and Overloading, Default parameters, 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 - Class Concepts

  • C++ Classes: RAII Idiom
  • Class Hierarchy: Access specifiers, Inheritance access specifiers
  • Class Constructor: Default constructor, Class initialization, Uniform initialization, Delegate constructor,explicit keyword
  • Copy Constructor
  • Class Destructor
  • Defaulted Members (= default)
  • Class Keywords:this,static,const,mutable,using,friend,delete

7. C++ Object-Oriented Programming II - Polymorphism and Operator Overloading

  • Polymorphism:virtual methods, Virtual table,override keyword,final keyword, Common errors, Pure virtual method, Abstract class and interface
  • Inheritance Casting and Run-time Type Identification
  • Operator Overloading: Overview, Subscript operator[], Comparison operator<, Spaceship operator<=>, Function call operator(), Conversion operatorT(), Return type overloading resolution, 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 - Function Templates and Compile-Time Utilities

  • Function Template: Overview, Template parameters, Template parameter - default value, Specialization, Overloading
  • Template Variable
  • Template Parameter Types: Template Parameter Types, Generic Type Notes,auto Placeholder, Class template parameter type, Array and pointer types, Function type
  • Compile-Time Utilities:static_assert,decltype Keyword,using Keyword
  • Type Traits: Overview, Type traits library, Type manipulation

9. C++ Templates and Meta-programming II -  - Class Templates and SFINAE

  • Class Template: Class specialization
  • Class Template - Advanced Concepts: Class + Function - Specialization, Dependent Names -typename andtemplate Keywords,friend Keyword, Template Template Arguments
  • Template Meta-Programming
  • SFINAE: Substitution Failure Is Not An Error: Function SFINAE, Class SFINAE, Class + Function SFINAE
  • Variadic Template: Folding Expression, Variadic class template
  • C++20 Concepts: Overview,concept Keyword,requires Clause,requires Expression,requires Expression + Clause,requires Clause + Expression,requires andconstexpr, Nestedrequires

10. Translation Units I

  • Basic Concepts: Translation unit, Local and global scope, Linkage
  • Storage Class and Duration: Storage duration, Storage class,static andextern keywords, Internal/External linkage examples
  • Linkage ofconst andconstexpr: Static Initialization Order Fiasco
  • Linkage Summary
  • Dealing with Multiple Translation Units: Class in multiple translation units
  • One Definition Rule (ODR): Global variable issues, ODR - Point 3,inline functions/variables,constexpr andinline
  • ODR - Function Template: Cases,extern keyword
  • ODR - Class Template: Cases,extern keyword
  • ODR Undefined Behavior and Summary

11. Translation Units II

  • #include Issues: Forward declaration, Include guard, Circular dependencies, Common linking errors
  • C++20 Modules: Overview, Terminology, Visibility and Reachability, Module unit types, Keywords, Global module fragment, Private module gragment, Header module unit, Module partitions
  • Namespace: Namespace functions vs.static methods, Namespace alias, Anonymous namespace,inline namespace, Attributes and namespace
  • Compiling Multiple Translation Units: Fundamental compiler flags, Compile Methods, Deal with libraries, Build static/dynamic libraries, Find dynamic library dependencies, Analyze object/executable symbols

12. Code Conventions

  • C++ Project Organization: Project directories, Project files,src/include directories
  • Coding Styles and Conventions
  • #include
  • Macro and Preprocessing
  • Namespace
  • Variables
  • Functions
  • Structs and Classes
  • Control Flow
  • Modern C++ Features
  • Maintainability
  • Naming and Formatting
  • Code Documentation

13. Ecosystem I

  • Debugging
  • Assertion
  • Execution debugging
  • Memory Debugging:valgrind, Stack protection
  • Sanitizers: Address sanitizer, Leak sanitizer, Memory sanitizers, Undefined behavior sanitizer
  • Debugging Summary
  • Code Checking and Analysis: Compiler warnings, Static analyzers
  • Code Testing: Unit test, Test-Driven Development (TDD), Code coverage, Fuzz testing
  • Code Quality:clang-tidy

14. Ecosystem II

  • CMake:cmake andctest
  • 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 -GitHub Co-Pilot/TabNine/Kite, Local code search -ripgrep, Code search engine -searchcode/grep.app, Code benchmarking -Quick-Bench, Font for Coding

15. Utilities

  • I/O Stream: Manipulator,ofstream/ifstream
  • Math Libraries
  • Strings:std::string, Conversion from/to numeric balues,std::string_view,std::format
  • 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::bytestd::pair,std::tuple,std::variant,std::optional,std::any
  • Filesystem Library: Query methods, Modify methods

16. Containers, Iterators, and Algorithms

  • Containers and Iterators
  • Sequence Containers:std::array,std::vector,std::list,std::deque,std::forward_list
  • Associative Containers:std::set,std::map,std::multiset
  • Container Adaptors:std::stack,std::queue,std::priority_queue
  • View:std::span
  • Implement a Custom Iterator: Semantic, Implement a simple Iterator
  • Iterator Utility Methods:std::advance,std::next,std::prev,std::distance, Container access methods, Iterator traits
  • Algorithms Library:std::find_if,std::sort,std::accumulate,std::generate,std::remove_if
  • C++20 Ranges: Key concepts, Range view, Range adaptor, Range factory, Range algorithms, Range actions

17. Advanced Topics I

  • Move Semantic:lvalues andrvalues references, Move semantic, Compiler implicitly declared,std::move
  • Universal Reference and Perfect Forwarding: Universal reference, Reference collapsing rules, Perfect forwarding
  • Value Categories
  • &,&& Overloading - Ref-qualifiers
  • Copy Elision and RVO
  • Type Deduction: Pass by-reference, Pass by-pointer, Pass by-value,auto deduction
  • const Correctness

18. Advanced Topics II

  • Undefined Behavior
  • Error Handling: C++ Exceptions, Defining custom exceptions,noexcept keyword, Memory allocation issues, Alternative error handling approaches
  • 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

19. Optimization I - Basic Concepts

  • Overview
  • Basic Concepts: Asymptotic complexity, Time-Memory Trade-off, Developing Cycle, Ahmdal's law, Throughput, Bandwidth, Latency, Performance bounds, Arithmetic intensity
  • Basic Architecture Concepts: Instruction-level parallelism, Little’s law, Data-level parallelism, Thread-level parallelism, RISC, CISC Instruction sets
  • Memory Hierarchy: Memory hierarchy concepts, Memory locality

20. Optimization II - Code Optmization

  • I/O Operations:printf, Memory mapped I/O, Speed up raw data loading
  • Memory Optimizations: Heap memory, Stack memory, Cache utilization, data alignment, memory prefecth
  • Arithmetic: Data types, Operations, Conversion, Floating-point, Compiler intrinsic functions, Value in a range, Lookup table
  • Control Flow: Loop hoisting, Loop unrolling, Branch hints, Compiler hints, Recursion
  • Functions: Function call cost, Argument passing, Function optimizations, Function inlining, Pointers aliasing
  • C++ Objects: Object RAII optimizations

21. Optimization III - Non-Coding Optimizations and Benchmarking

  • Compiler Optimizations: About the compiler, Architecture flags, Optimization flags, Help the Compiler to produce better code, Profile guided optimization (PGO), Post-Processing Binary Optimizer
  • Compiler Transformation Techniques
  • Libraries and Data Structures: External libraries, Std library
  • Performance Benchmarking: What to test?, Workload/Dataset quality, Cache behavior, Stable CPU performance, Program memory layout, Measurement overhead and compiler Optimizations, Metric evaluation
  • Profiling:gprof,uftrace,callgrind,cachegrind,perf Linux profiler
  • Parallel Computing: Concurrency vs. Parallelism, Performance scaling, Gustafson’s Law, Parallel programming languages

Roadmap

  1. Software Design Chapter
  2. Build Aspects Chapter (e.g. reducing build time)

Essential Tool

Online compiler and execution:CompilerExplorer

  • for code execution: [Add new..] -> [execution only]

Reporting bugs and contributing

If you find any typo, conceptual error, or section to improve, please report them by writing directly to me or by using theissue panel

Author

Federico Busato

About

Modern C++ Programming Course (C++11/14/17/20)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp