正常
Complete Beginner Tutorial
This directory contains the complete beginner tutorial for the OnceCallback component — 13 articles in total, covering the full learning path from a review of core C++ features to implementing and testing the component.
Prerequisites
First, master the core C++ features that OnceCallback relies on:
OnceCallback prerequisite cheat sheet: a review of C++11/14/17 core featuresOnceCallback prerequisite (I): function types and template partial specializationOnceCallback prerequisite (II): std::invoke and the uniform calling protocolOnceCallback prerequisite (III): advanced lambda featuresOnceCallback prerequisite (IV): Concepts and requires constraintsOnceCallback prerequisite (V): std::move_only_function (C++23)OnceCallback prerequisite (VI): Deducing this (C++23)
Hands-on Practice
With the prerequisites covered, we move on to implementing OnceCallback:
OnceCallback hands-on (I): motivation and API designOnceCallback hands-on (II): building the core skeletonOnceCallback hands-on (III): implementing bind_onceOnceCallback hands-on (IV): designing the cancellation tokenOnceCallback hands-on (V): chaining with thenOnceCallback hands-on (VI): tests and performance comparison
Companion Code
The standalone C++ example code covered in the prerequisite chapters has been distilled into a compilable minimal project, located at:
text
code/volumn_codes/vol9/full_tutorial_codes/chrome_design/| Example | Topic | Source Article | Minimum C++ Standard |
|---|---|---|---|
01_move_semantics.cpp | Move semantics, perfect forwarding, variadic templates | pre-00 | C++17 |
02_smart_pointers.cpp | unique_ptr, shared_ptr | pre-00 | C++17 |
03_atomic_memory_order.cpp | atomic, memory_order, enum class | pre-00 | C++17 |
04_lambda_basics.cpp | Capture modes, generic lambda, [[nodiscard]] | pre-00 | C++17 |
05_lambda_advanced.cpp | mutable lambda, init capture, C++17/C++20 bind | pre-03 | C++20 |
06_type_traits.cpp | type traits, if constexpr, decltype(auto), ref-qualifier | pre-00 | C++17 |
07_function_type_specialization.cpp | Function types, FuncTraits, primary template + partial specialization | pre-01 | C++17 |
08_invoke.cpp | std::invoke, std::invoke_result_t | pre-02 | C++17 |
09_concepts_requires.cpp | concept, requires, not_the_same_t, template constructor hijacking | pre-04 | C++20 |
10_move_only_function.cpp | std::move_only_function construction/move/empty check/SBO | pre-05 | C++23 |
11_deducing_this.cpp | deducing this deduction rules, lvalue interception | pre-06 | C++23 |
Build instructions:
bash
cd code/volumn_codes/vol9/full_tutorial_codes/chrome_design
mkdir build && cd build
cmake ..
make -j$(nproc)