GitHub - cybersecurity-dev/awesome-cpp-programming-language: Awesome C++ Programming Language
📖 Contents
- Containers
- C++ Initialization
- Pointers and References
- Expressions
- Functions
- Type Casting
- Idioms
- Specifiers
- Compile Time Specifiers
- Language Concepts
- Concurrency & Parallelism & Multithreading
- Framework and Libraries
- Performance Analysis and Debugging Tool
- Package Managers
- Severals
- Standarts
- My Other Awesome Lists
- Contributing
- Contributors
Containers
Vector
Except for the std::vector<bool> partial specialization, the elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets to regular pointers to elements.
std::vector<int> ivec = { 1, 2, 3, 4, 5 };
You can find more details at the link.
List
std::list is a container that supports constant time insertion and removal of elements from anywhere in the container. Fast random access is not supported. It is usually implemented as a doubly-linked list. Compared to std::forward_list this container provides bidirectional iteration capability while being less space efficient.
std::list<int> ilist = { 5, 7, 11, 13 };
You can find more details at the link
Deque
You can find more details at the link
Array
std::array is a container that encapsulates fixed size arrays.
std::array<int, 4> iarray1{ {5, 2, 3, 7} };
You can find more details at the link
Forward List
You can find more details at the link
Inplace Vector
You can find more details at the link
🧠 C++ Initialization
| Initialization Type | Syntax Example | Description | Key Notes |
|---|---|---|---|
| Direct Initialization | int ival(10); | Value passed using parentheses | Used in constructors |
| Copy Initialization | int ival = 10; | Value assigned at creation | Most common style |
| List Initialization | int ival{10}; | Uses {} braces | Prevents narrowing conversions |
| Value Initialization | int ival{}; | Initializes to default value | int → 0, float → 0.0 |
| Default Initialization | int ival; | No initialization | Contains garbage value (local var) |
| Reference Initialization | int &rival = ival; | Reference bound to variable | Must be initialized |
| Pointer Initialization | int *ptr = nullptr; | Pointer set to safe null | Avoids garbage addresses |
You can find more details at the link
🔷 Pointers and References
Smart Pointers
Smart pointers enable automatic, exception-safe, object lifetime management.
unique_ptr
std::unique_ptr is a smart pointer that owns (is responsible for) and manages another object via a pointer and subsequently disposes of that object when the unique_ptr goes out of scope.
{
unique_ptr<ClassName> uptr(new ClassName);
uptr -> method_name();
//....using
} //destructing uptr destroys the ClassName object.shared_ptr
weak_ptr
Expressions
Lambda Expressions
Lambda expression in computer programming, also called an anonymous function, is a defined function not bound to an identifier.
auto make_function(int& iparam) { return [&] { std::cout << iparam << std::endl; }; } int main() { int ival = 2; auto f = make_function(ival); // the use of iparam in f binds directly to ival f(); ival = 3; f(); return 0; }
Value Categories
- a
glvalue("generalized" lvalue) is an expression whose evaluation determines the identity of an object or function. - a
prvalue("pure" rvalue) is an expression whose evaluation. - an
xvalue(an "eXpiring" value) is a glvalue that denotes an object whose resources can be reused. - an
lvalueis a glvalue that is not an xvalue.
lvalue
Some programming languages use the idea of l-values and r-values, deriving from the typical mode of evaluation on the left and right-hand side of an assignment statement. An l-value refers to an object that persists beyond a single expression. An r-value is a temporary value that does not persist beyond the expression that uses it.
void foo(); int main() { int ivala; // Expression 'ivala' is lvalue int &ivalb{ivala}; // Expression 'ivalb' is lvalue // Expression 'foo' is lvalue // address may be taken by built-in address-of operator void (*ptrfoo)() = &foo;
rvalue
glvalue
a glvalue ("generalized" lvalue) is an expression whose evaluation determines the identity of an object or function.
prvalue
xvalue
Class
Class/Struct Types
Union Types
A union is a special class type that can hold only one of its non-static data members at a time.
Injected-class-name
Class property specifiers (C++26)
Members
Data members
Static members
The this pointer
Nested classes
Member templates
Bit-fields
using-declarations
Member functions
Member access specifiers
Constructors and member initializer lists
Default member initializer (C++11)
friend specifier
explicit specifier
Converting constructor
Special member functions
Default constructor
Copy constructor
Move constructor (C++11)
Copy assignment operator
Move assignment operator (C++11)
Destructor
Inheritance
Base and derived classes
Empty base optimization (EBO)
Virtual member functions
Pure virtual functions and abstract classes
override specifier (C++11)
final specifier (C++11)
Multithreading
Template Metaprogramming
Exception Handling
Functions
Coroutines
A coroutine is a function that can suspend execution to be resumed later. Coroutines are stackless: they suspend execution by returning to the caller, and the data that is required to resume execution is stored separately from the stack. This allows for sequential code that executes asynchronously (e.g. to handle non-blocking I/O without explicit callbacks), and also supports algorithms on lazy-computed infinite sequences and other uses.
Type Casting
static_cast
Converts between types using a combination of implicit and user-defined conversions.
dynamic_cast
Safely converts pointers and references to classes up, down, and sideways along the inheritance hierarchy.
const_cast
Converts between types with different cv-qualification.
reinterpret_cast
Idioms
You can find more details at the link
RAII (Resource acquisition is initialization)
Resource Acquisition Is Initialization or RAII, is a C++ programming technique which binds the life cycle of a resource that must be acquired before use (allocated heap memory, thread of execution, open socket, open file, locked mutex, disk space, database connection—anything that exists in limited supply) to the lifetime of an object. RAII guarantees that the resource is available to any function that may access the object. It also guarantees that all resources are released when the lifetime of their controlling object ends, in reverse order of acquisition.
PIMPL (Pointer to Implementation)
"Pointer to implementation" or "pImpl" is a C++ programming technique that removes implementation details of a class from its object representation by placing them in a separate class, accessed through an opaque pointer. The PIMPL idiom is used to:
- hide implementation details from the header,
- reduce compile-time dependencies,
- provide binary compatibility,
- keep your class ABI stable.
You can find more details at the link
CRTP (Curiously recurring template pattern)
Erase-Remove
Copy on Write
Rule of N
The Rule of Three
The Rule of Three in C++ says: If a class manages a resource (e.g., raw new-allocated memory, file handle, socket), and you need to define any one of these:
- Destructor
- Copy constructor
- Copy assignment operator
The Rule of Five
The Rule of Five (C++11 and later) extends the Rule of Three. If your class manages a resource (e.g., heap memory, file descriptors, sockets, mutexes), and you define any of the special member functions, you typically need to implement all five:
- Destructor
- Copy constructor
- Copy assignment operator
- Move constructor
- Move assignment operator
The Rule of Zero
If your class doesn’t manage resources directly (no raw new/delete, no manual file handles, etc.), you don’t need to write any of the special member functions (destructor, copy/move ctor, copy/move assignment).
SFINAE (Substitution failure is not an error)
// Primary template: enabled only if T::size() is valid template <typename T> auto print_size(const T& x, int) -> decltype(x.size(), void()) //SFINAE - based return type checks. Try to evaluate x.size() //If x.size() is valid -> the whole expression becomes void //If x.size() is NOT valid -> substitution fails -> SFINAE kicks in { std::cout << "x.size() = " << x.size() << "\n"; } // Fallback overload: used if above substitution fails template <typename T> void print_size(const T&, ...) // ellipsis = lowest priority match { std::cout << "No size() available.\n"; } int main() { std::vector<int> ivec{ 2, 3, 5, 7, 11 }; std::string str = "Hello World!."; int ival = 42; print_size(ivec, 0); // has size() -> prints size print_size(str, 0); // has size() -> prints size print_size(ival, 0); // no size() -> fallback return 0; }
Specifiers
Typedef
Inline
The inline specifier, when used in a function's decl-specifier-seq, declares the function to be an inline function. A function defined entirely inside a class/struct/union definition, whether it's a member function or a non-member friend function, is implicitly an inline function unless it is attached to a named module (since C++20)
Virtual Function Specifier
Specifies that a non-static member function is virtual and supports dynamic dispatch. It may only appear in the decl-specifier-seq of the initial declaration of a non-static member function
Explicit Function Specifier
Friend
The friend declaration appears in a class body and grants a function or another class access to private and protected members of the class where the friend declaration appears.
-
Friend Function Example
class Point2D { private: int x, y; public: Point2D(int x, int y) : x(x), y(y) {} // Friend function can access private members friend void printPoint(const Point2D &p); }; void printPoint(const Point2D &p) { std::cout << "Point(" << p.x << ", " << p.y << ")\n"; } int main() { Point2D p(3, 4); printPoint(p); // friend function can access }
-
Friend Class Example
class Engine { private: int hp = 100; // Car can access private members of Engine friend class Car; public: Engine() = default; }; class Car { public: void showEnginePower(const Engine& e) { std::cout << "Engine horsepower: " << e.hp << "\n"; } }; int main() { Engine eW; Car cW; cW.showEnginePower(eW); return 0; }
Compile Time Specifiers
Constexpr (C++11)
The constexpr specifier declares that it is possible to evaluate the value of the entities at compile time.
constexpr int factorial(int n) { return n <= 1 ? 1 : (n * factorial(n - 1)); }
constexpr int fac5 = factorial(5); static constexpr int const& fac10 = 3628800; static_assert(fac10 == factorial(10), "factorial failed\n");
Consteval (C++20)
Constinit (C++20)
Language Concepts
auto (Automatic Type Deduction)
auto tells the compiler: "Deduce the variable's type automatically from the initializer."
- Iterators (most common)
std::vector<int> v = {2,3,5}; auto it = v.begin(); // replaces vector<int>::iterator
- Lambda functions
auto printType = [](auto t) { std::cout << typeid(t).name() << std::endl; };
- Range-based loops
std::vector<int> ivec = {2,3,5}; for (auto v : ivec) { std::cout << v << std::endl; }
- Working with templates
template <typename T> void printType(T param) { std::cout << typeid(param).name() << std::endl; }
ADL (Argument Dependent Lookup)
Name Mangling
RTTI (Run-time type information)
Virtual Methods
Virtual functions enable runtime polymorphism (dynamic dispatch). When you call a virtual function through a base class pointer or reference, C++ decides at runtime which overridden function to execute based on the actual (dynamic) type of the object.
struct Basev1 { void speak() { cout << "Base v1 speaks\n"; } // NOT virtual }; struct Derivedv1 : Basev1 { void speak() { cout << "Derived v1 speaks\n"; } // hides Base::speak }; struct Basev2 { virtual void speak() { cout << "Base v2 speaks\n"; } // virtual }; struct Derivedv2 : Basev2 { void speak() override { cout << "Derived v2 speaks\n"; } // override }; int main() { Derivedv1 dv1; Basev1* ptrv1 = &dv1; // base pointer to a derived object ptrv1->speak(); // calls Base::speak (static dispatch) /*-------------------------------*/ Derivedv2 dv2; Basev2* ptrv2 = &dv2; ptrv2->speak(); // calls Derived::speak (dynamic dispatch) return 0; }
Virtual Tables
Forward Declaration
-
Basic Forward Declaration of
a Class#include <iostream> // Forward declaration class Engine; class Car { public: void run(Engine* en); // OK: pointer doesn't require full definition }; // Full definition of Engine class Engine { public: void print_spec() { std::cout << "Engine Spec:..\n"; } }; void Car::run(Engine* e) { e->print_spec(); // OK now, since Engine is fully defined } int main() { Car c1; Engine e1; c1.run(&e1); return 0; }
-
Forward Declaration of
Functionsvoid foo(); // forward declaration void bar() { foo(); // valid because foo is declared } void foo() { bar(); } int main() { foo(); bar(); return 0; }
Special Member Functions
- (Default) Constructor:
- Copy Constructor:
- Move Constructor:
- Copy Assignment Operator:
- Move assignment Operator:
- Destructor:
Signatures of the special member functions:
| Function | Syntax for class MyClass |
|---|---|
| (Default) constructor | MyClass(); |
| Copy constructor | MyClass(const MyClass& other); |
| Move constructor | MyClass(MyClass&& other) noexcept; |
| Copy assignment operator | MyClass& operator=(const MyClass& other); |
| Move assignment operator | MyClass& operator=(MyClass&& other) noexcept; |
| Destructor | virtual ~MyClass(); |
Concurrency & Parallelism & Multithreading
Framework and Libraries
Algorithm
| Category | Description | Reference |
|---|---|---|
| Non‑modifying sequence operations | Algorithms that read but do not change data | Non‑modifying |
| modifying sequence operation | Algorithms that modify elements | Modifying |
| Swap operations | swap, iter_swap, swap_ranges | Swap operations |
| Transformation operations | replace, replace_if, transform | Transformation |
| Generation operations | fill, fill_n, generate, generate_n | Generation |
| Removing operations | remove, remove_if, unique, unique_copy | Removing |
| Order‑changing operations | reverse, rotate, shuffle, shift_left… | Order‑changing |
| Partitioning operations | partition, is_partitioned, partition_point | Partitioning |
| Sorting operations | sort, stable_sort, partial_sort, nth_element | Sorting |
| Binary search operations | lower_bound, upper_bound, equal_range | Binary search |
| Min/Max operations | min, max, clamp, minmax_element | Min/Max |
| Numeric operations | iota, inner_product, reduce, transform_reduce | Numeric Operations |
| Uninitialized memory ops | uninitialized_copy, uninitialized_fill… | Uninitialized memory |
| C library algorithms | qsort, bsearch | C library algorithms |
Testing and Mocking Framework
- Catch2 - A modern, C++ native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later.
- Google Test - Google Testing and Mocking Framework
Network
- POCO - The POCO C++ Libraries are powerful cross-platform open-source C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
RPC (Remote Procedure Call)
- gRPC - A high performance, open source universal RPC framework.
Performance Analysis and Debugging Tool
- Orbit - Orbit is a standalone profiler and debugging tool for Windows and Linux. Its main purpose is to help developers understand and visualize the execution flow of a complex application.
- Tracy Profiler - A real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications.
Package Managers
- vcpkg - vcpkg is a free C/C++ package manager for acquiring and managing libraries.
- Conan - The open-source C and C++ package manager.
Severals
- Doxygen - Doxygen is a widely-used documentation generator tool in software development.
- {fmt} - A modern formatting library.
- JSON for Modern C++ - JSON for Modern C++.
- pybind11 - Seamless operability between C++11 and Python.
- spdlog - Fast C++ logging library.
Standarts
std::variant
std::basic_string_view
std::any
Modules
std::atomic_ref
std::barrier
std::jthread
std::latch
std::generator
std::mdspan
Contracts
Compiler/Debugger
- MSVC & GCC & Clang - installation step of MSVC/GCC/Clang compiler in Windows
- GCC & Clang - installation step of GCC/Clang compiler in Linux
- OnlineGDB - Online compiler and debugger for C/C++
My Other Awesome Lists
You can access the my other awesome lists here
Contributing
Contributions of any kind welcome, just follow the guidelines!
Contributors
Thanks goes to these contributors!

