Skip to content

Latest commit

 

History

History
129 lines (90 loc) · 4.8 KB

File metadata and controls

129 lines (90 loc) · 4.8 KB

🌎 中文 | English

English Title

<One-paragraph intro: this feature was introduced in C++NN to solve …, making …>

Book Video Code X
cppreference / markdown Video Explanation Practice Code

Why was it introduced?

  • <motivation 1>
  • <motivation 2>

How does it differ from …?

  • <contrast 1>
  • <contrast 2>

I. Basic Usage and Scenarios

<explanation + short code blocks; comment the wrong vs. correct form inline>

// example code

II. Real-World Case - in the STL

Corroborates how the feature is actually used in production-grade code. The snippet is taken from the in-repo MSVC STL reference basis msvc-stl/ (source file stl/inc/<header>); _NODISCARD / _CONSTEXPR17 / _STD are internal library macros — ignore them when reading

<one line: why the standard library must use the feature here — un-writable / awkward by hand>

// MSVC STL · stl/inc/<header> (abridged)
// <verbatim excerpt of the real code; mark omissions with (abridged), never paraphrase from memory>

<tie it back to the toy example in section I: you write it this way → the standard library writes it this way too — one of the core motivations for introducing the feature>

III. Notes and Caveats

<pitfall / migration advice>

IV. Practice Code

Practice Topics

Auto-Checker Commands

Don't have d2x yet? Click to expand setup
# 1. Install xlings (Linux / macOS)
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash
# Windows PowerShell:
# irm https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.ps1 | iex

# 2. Install d2x and fetch this tutorial
xlings install d2x -y
d2x install d2mcpp

# 3. Enter the project directory & run the checker
cd d2mcpp
d2x checker <name>

Exercise Discussion

Feature Evolution

Introduced in: C++NN Later improvements:

Teaching note: <cross-standard behavior differences / deprecation / why this exercise uses an exception standard>

V. Additional Resources