Tag: C++20
24 posts
-
C++20 Template Lambdas: []<typename T> Syntax, Concept Constraints and When They Beat auto
C++20 template lambdas: `[]<typename T>(T a, T b)`, concepts constraints, parameter packs, and when they beat generic `auto` lambdas.
-
C++ Generic Lambdas — auto Parameters and Template Lambdas
Generic lambdas in C++14: auto makes operator() a template, C++20 template lambdas, STL patterns, deduction rules, performance, and common pitfalls.
-
C++20 Concepts | Making Template Error Messages Readable
C++20 Concepts: clearer errors than SFINAE/enable_if—standard concepts, requires clauses, overloads, and practical C++20 examples.
-
C++ Custom Ranges
C++ custom ranges: satisfy std::ranges::range with begin/end, iterators, adaptors, sentinels, view_interface, pitfalls, and production patterns.
-
C++20 Calendar and Time Zones: year_month_day, zoned_time and DST Pitfalls
C++20 chrono dates and time zones: calendar vs day arithmetic, the Jan 31 + 1 month problem, weekdays, zoned_time conversion, DST gaps and overlaps.
-
Modern C++ Syntax Cheatsheet: C++11 to C++20 Features and Their Pitfalls
Scannable modern C++ reference: each C++11/14/17/20 feature with the standard that added it, a snippet verified on g++ 10.3, and the pitfall that bites.
-
C++20 std::latch and std::barrier: Start Gates, Phased Work and Clean Exits
When to use C++20 std::latch vs std::barrier: start gates, phase loops with a completion step, arrive_and_drop, exception-safe count_down and count bugs.
-
C++ Branch Prediction: Measuring Mispredictions, cmov, [[likely]] and PGO
How branch mispredictions slow C++ loops, why the sorted-array trick depends on your compiler, and when cmov, [[likely]], partitioning or PGO actually help.
-
C++20 Views: How Lazy Pipelines Evaluate, and the Lifetime and Caching Traps
C++20 std::views explained by how they evaluate: filter, transform, take, and drop pipelines, why adapter order changes results, why transform before filter runs twice, and the dangling and const-iteration traps.
-
C++20 operator<=>: Defaulted Comparisons, Ordering Categories and Migration
How C++20 operator<=> synthesizes ==, <, >, strong vs weak vs partial ordering, why a custom <=> does not give you ==, and pitfalls when migrating old types.
-
C++ std::span | Contiguous Memory View (C++20)
std::span for arrays and vectors: non-owning view, subspan, bounds, const correctness, lifetime pitfalls, and C API interop.
-
C++20 Coroutines from Scratch: co_yield Generators, co_await and Coroutine Lifetimes
C++20 coroutines from the ground up: co_yield generators, co_await async flow, promise_type, coroutine_handle, lifetimes, pitfalls, and production.
-
C++20 Modules: export/import, Partitions and Building with GCC, Clang, MSVC and CMake
C++20 modules: export/import, partitions, global fragments, GCC/Clang/MSVC, CMake 3.28+—parse once, reuse BMIs, faster builds than plain headers.
-
C++ constexpr Functions and Variables: Compute at Compile
Compute values at compile time with constexpr: C++14/20 rule changes, constexpr vs const, a CRC32 lookup table, and fixes for ten common constexpr errors.
-
What Is C++? History, Standards , Use Cases, and How to
C++ overview for beginners: evolution from C, C++11/17/20/23, game/systems/finance use cases, pros and cons, myths, learning roadmap, and production.
-
C++20 Range Adaptors: Composing Reusable Pipelines Without Fighting the Types
C++20 range adaptors as objects: calling vs piping, storing and composing adaptor closures, why a function cannot return two different pipelines, lifetime rules for returned views, and writing your own adaptor.
-
C++20 std::jthread: Auto-Join, Cooperative Cancellation with stop_token, and Its Limits
C++20 std::jthread explained: why std::thread terminates without join, how jthread requests stop and joins in its destructor, how stop_token, stop_callback, and condition_variable_any make waits cancellable, and the cases where auto-join still hangs.
-
C++20 Coroutines: promise_type, co_await Awaiters, Generators, and Task Types
C++20 coroutines: coroutine_handle, promise_type, co_await, generators, Task patterns, and compiler support for async-style control flow.
-
C++20 Date Parsing and Formatting: chrono::parse, std::format, Time Zones and DST Pitfalls
Parse and format dates in C++20 chrono and std::format, plus the IANA tzdata, DST ambiguity, and locale pitfalls that break naive implementations.
-
C++20 Constraints in Practice: requires Expressions, Subsumption, and Overload Selection
How C++20 constraints actually behave: what a requires expression checks (syntax, not meaning), why only named concepts subsume each other, how constrained overloads are ranked, and the mistakes that make a concept accept the wrong types.
-
C++ std::chrono::duration: Units, Literals, and Safe Conversions
Working with std::chrono::duration in C++ - representing time intervals, chrono literals like 500ms and 2h, converting between units safely, C++20 calendar literals, and avoiding truncation bugs.
-
C++ Constant Initialization: constexpr, constinit, and the Static Initialization Order Problem
How C++ decides whether a constant is initialized at compile time or run time, and why that distinction matters for static and global variables.
-
C++20 consteval: Forcing Compile-Time Evaluation Where constexpr Only Allows It
C++20 consteval explained: immediate functions vs constexpr, why a constexpr wrapper cannot pass its parameter, if consteval, C++23 propagation, and real diagnostics.
-
C++ Aggregate Initialization: What Counts as an Aggregate, C++17/20 Rule Changes, and Designated Initializers
Which structs and arrays are aggregates, why a defaulted constructor stops counting in C++20, base classes, designated initializers, parenthesized init, and narrowing errors.