hacking C++
Recent changes and new articles on hackingcpp.com
Latest posts
C++20/23 Range Views - Visualizations and Examples
Added Some C++23 Standard Algorithms
Small Updates and Fixes
New List of Useful Command Line Tools
Updated Resource Lists
List of Educational C++ Videos (Talks, Tutorials,...)
A list of over 1,000 videos of talks, tutorials and explanations related to C++ organized by topics.
std::unordered_map Cheat Sheet
New cheat sheet: std::unordered_map's member functions
std::map Cheat Sheet
New cheat sheet: std::map's member functions
std::unordered_set Cheat Sheet and List of Coding Fonts
New cheat sheet: std::unordered_set's member functions; New article: comprehensive list of monospace coding fonts
std::set Cheat Sheet
New cheat sheet: std::set's member functions
Arithmetic Conversions Cheat Sheet
New cheat sheet that summarizes all rules governing the "usual arithmetic conversions".
std::forward_list Cheat Sheet
New cheat sheet: std::forward_list's member functions
std::deque Cheat Sheet
New cheat sheet: std::deque's member functions
std::list Cheat Sheet
New cheat sheet: std::list's member functions
std::vector Cheat Sheet
New cheat sheet: std::vector's member functions
std::span Cheat Sheet
New cheat sheet: std::span interface and usage
std::string_view Cheat Sheet
New cheat sheet: std::string_view interface and usage
Printing and Formatting with the {fmt} Library
Beginner-friendly introduction and overview of the {fmt} printing and formatting library with lots of code examples and new cheat sheets.
New Cheat Cheats
Added four new cheat sheets about lambdas, lambda syntax, standard random distributions and time/date formatting with the {fmt} library.
Runnable Code Examples
Most code examples can now be copied to the system clipboard by and opened/run in Compiler Explorer.
Update: Blogs About C++
An opinionated list of C++ blogs in 2021 that are of good quality, useful to C++ learners and more or less regularly updated.
Update: Package Managers for C++
An opinionated list of popular package managers for C++.
Update: Build Systems For C++
An opinionated list of popular build systems for C++.
Update: Unit Testing Frameworks For C++
An opinionated list of testing frameworks and libraries for C++.
Recipe: Reproducible Random Number Sequence
How to generate random number sequences that are either reproducible or non-predictable using the C++ standard library.
Recipe: Fast (Uninitialized) Allocation Uninitialized Numeric Arrays
How to allocate (large) uninitialized numeric arrays / vectors without costly zero-initialization. The approaches presented vary in their degrees of convenience, safety and ISO standard support.
Recipe: Which Function Parameter Type For Strings?
Explains which function parameter types should be used for taking strings. Four different scenarios are shwon: 1) read-only access in C++17, 2) read-only access in C++98 to C++14, 3) when a copy of the input string is always needed inside the function, 4) in-place modification of the input string.
Recipe: Making A Random Generator (Combining Engine + Distribution)
How to make a single random number generator object from a standard library random distribution and a random engine. Two solutions are presented: one using a mutable lambda and one using a custom function class.
Exceptions
How to handle exceptions, common usages, pitfalls and why exception guarantees are a critical part of designing C++ functions, types and libraries. How to use RAII to make code exception-safe and why you should never let exceptions escape from destructors.
Diagnostic Basics: Warnings, Assertions, Testing
The basic techniques for ensuring correctness: important compiler warnings (gcc/clang/MSVC), assertions (assert/static_assert) and testing (with some doctest examples).
Standard Library Algorithms
An overview of the C++ standard library algorithms with one small picture per algorithm.
Macro __cplusplus
Overview of values for the __cplusplus standard macro.
Value Semantics vs. Reference Semantics
A short summary with examples (in C++ and Python) explaining the meaning of the programming paradigms known as "value semantics" and "reference semantics".
Standard Library Special Iterators
Short overview of special purpose iterators in the C++ standard library.
Standard Library Range Utilities
Introduction, examples and visual explanations of s++ standard library utilities for ranges of elements.
Container Traversal
Overview of container traversal approaches in C++: range-based for loops, std::for_each, explicit iterator traversal, index traversal.
Pointers
A short introduction to pointers in C++. Syntax, semantics, 'const' pointers, 'this' pointer, forward declarations and some guidelines.
Attributes
Overview (table with examples) of all C++ standard attributes as of \date/month; \date/year;: [[nodiscard]], [[fallthrough]], [[likely]], [[unlikely]], [[maybe_unused]], [[noreturn]], [[no_unique_address]], [[carries_dependency]]
Tools Ecosystem
An overview of the C++ tooling ecosystem: compilers, build systems, debuggers, sanitizers, analyzers, profilers, package managers and online tools.
C++ Standard Library Algorithms Introduction
Introduction, examples and visual explanations of the basic principles behind C++ standard library algorithms.
Argument Dependent Lookup
What Argument Dependent Lookup (ADL) does, how it works and common C++ idioms involving ADL (2-step/fallback, hidden friends, niebloids, CPOs).
Standard Library Removal Algorithms
Introduction, examples and visual explanations of standard algorithms for removing elements from ranges.
Standard Library Range Object Algorithms
An overview of the C++20 standard library constrained algorithms that can take a single object as input range (as opposed to an iterator pair) showing one small picture per algorithm.
Standard Library Element-Wise Range Modifications
Introduction, examples and visual explanations of standard algorithms for modifying ranges of elements.
Standard Library Numeric Operations
Introduction, examples and visual explanations of numeric standard algorithms operating on ranges.
Standard Library Sequence Reordering Algorithms
Introduction, examples and visual explanations of standard algorithms for reordering elements in ranges.
Standard Library Finding Algorithms
Introduction, examples and visual explanations of standard algorithms for finding elements in ranges.
Standard Library Existence Queries
Introduction, examples and visual explanations of standard algorithms for querying value existence in ranges.
Source Control Management
An opinionated list of source control management tools.
