C++ / Tour
-
C++20 Ranges: Composable Views for Filtering and Transforming Sequences
C++20 ranges treats a sequence as a lightweight view so filtering, transforming, and sorting can be composed without copying elements.
-
Using std::jthread and stop_token for Cooperative Thread Cancellation
C++20 std::jthread automatically calls join() on destruction and carries an internal std::stop_source for cooperative cancellation. This note covers auto-join behavior and how to pass and check a stop_token.
-
A Tour of C++ 1.1 — What to grasp first when reading C++
A Tour of C++ §1.1 Introduction. Before memorizing syntax, hold notation, types, memory and computation models, and the mechanisms that build programs.
-
A Tour of C++ 2.6 — Advice: Choosing struct, class, enum, and variant
When built-in types are insufficient in C++, design and choose the appropriate user-defined type to group related data and prevent invalid states. This post summarizes when to use struct, class, enum class, and std::variant from Chapter 2.
-
A Tour of C++ 3.1 — Introduction: Declarations vs Definitions
In C++, a declaration tells the compiler enough to use a name, while a definition provides the actual implementation body. This post introduces the separation of interface and implementation from Chapter 3.
-
A Tour of C++ 3.2 — Separate Compilation: Headers vs C++20 Modules
Traditional #include headers cause repeated parsing and dependency leaks in separate compilation, while C++20 modules solve these overheads through single-time compilation and macro isolation.
-
A Tour of C++ 1.8 — Tests: Conditions, Short-Circuit, and Control Flow
A Tour of C++ §1.8 covers how C++ expresses selection and looping with if, switch, while, and for. This post clarifies truthiness, short-circuit evaluation, if-initialization, switch fall-through, and common control-flow mistakes.
-
A Tour of C++ 2.5 — Unions: Active Members and std::variant
A union lets several members share one block of memory to save space, but the programmer must track which member is currently valid. This post explains union hazards and why std::variant offers a type-safe alternative since C++17.
-
A Tour of C++ 1.10 — Advice: C++ Coding Habits
C++ coding habits are not just new syntax—they are rules for consistently handling comments, initialization, naming, scope, and constants. This post concludes Chapter 1 with practical advice from Bjarne Stroustrup's study notes.
-
A Tour of C++ 1.9 — Mapping to Hardware: Pointers vs References
The core of C++ mapping to hardware is that basic operations translate directly into single machine instructions without extra runtime overhead. This article explains the memory model and the differences between pointers and references.
-
A Tour of C++ 2.1–2.2 — User-Defined Types and struct Vector
Built-in types are low-level tools that mirror hardware capabilities; user-defined types layer abstraction on top. This post covers the first step—grouping data with struct—and introduces the Tour's Vector example.
-
A Tour of C++ 2.3 — Classes: Enforcing Invariants with Constructors
A C++ class separates the public interface from private implementation and enforces invariants immediately upon object creation using a constructor. This article covers why struct Vector was insufficient and how a class fixes it.
-
A Tour of C++ 1.8 — Tests: Conditions, Short-Circuit, and Control Flow
A Tour of C++ §1.8 covers how C++ expresses selection and looping with if, switch, while, and for. This post clarifies truthiness, short-circuit evaluation, if-initialization, switch fall-through, and common control-flow mistakes.
-
Formatting Output with C++ std::format
In C++20, std::format takes a format string, substitutes the supplied arguments, and returns formatted text. A safe, extensible alternative to printf and a complement to iostreams.