Getting Started

This section documents C++23 (ISO/IEC 14882:2024), as published by ISO/IEC JTC1/SC22/WG21 (wg21), verified against the freely available working draft N5046 (eel.is/c++draft) and cppreference.com.

This content was generated with the assistance of AI and should be verified against the working draft and cppreference.com before being relied on in production.

This section’s bibliography lists the reference material consulted while preparing these pages.

C++ is a general-purpose, statically-typed, compiled language standardized by ISO/IEC JTC1/SC22 Working Group 21 (WG21). It gives direct control over memory and layout (like C) while adding zero-overhead abstractions — classes, templates, RAII — that cost nothing at run time compared to hand-written C. This section targets C++23 (ISO/IEC 14882:2024), the edition current at the time of writing, and flags any feature that is C++20/23-only alongside its C++17 fallback.

The Standard Editions

WG21 ships a new edition roughly every three years. Each is informally named after the year it was ratified:

Edition Headline additions

C++98/03

The original ISO standard; the STL (containers, iterators, algorithms).

C++11

auto, lambdas, move semantics, nullptr, range-for, smart pointers, <thread>.

C++14

Generic lambdas, generalized constexpr, variable templates.

C++17

if/switch with init, structured bindings, std::optional/variant/any, <filesystem>, fold expressions.

C++20

Concepts, ranges, coroutines, modules, <⇒, std::span, std::format (specification only).

C++23

std::print/std::println, std::expected, std::mdspan, std::flat_map, deducing this, if consteval.

C++26

Not yet ISO-published at time of writing — see C++ Standards and C++26.

Compilers

Three toolchains track the standard closely and are what this section’s examples are verified against:

  • GCC (g++) — the GNU Compiler Collection, paired with the libstdc++ standard library.

  • Clang (clang++) — LLVM’s compiler, usually paired with libc++ (though it can also target libstdc++).

  • MSVC (cl.exe) — Microsoft’s compiler on Windows, shipped with Visual Studio.

None of the three has finished every C++23 library feature yet; cppreference’s C++23 compiler support table is the definitive, continuously updated source for what’s implemented where. This section’s own examples were checked against GCC 13 / Clang 18 with libstdc++, which accepts every C++23 language feature used here but does not yet provide the <print>, <generator>, <flat_map> or <mdspan> headers; the pages that use those call it out where it matters.

"Hello, World"

C++23 adds std::println (header <print>), which formats and writes a line in one call — no manual "\n", no std::endl flush semantics to reason about:

#include <print>

int main() {
    std::println("Hello, World!");
}
<print> is standard-conformant C++23 (verified against cppreference and the working draft) but is not yet shipped by every standard library — it needs GCC 14+, a recent libc++, or MSVC; it is not available in this environment’s libstdc++ 13. The portable C++17 fallback below compiles everywhere, including in this environment:
#include <iostream>

int main() {
    std::cout << "Hello, World!\n";
}

Compiling

Turning a .cpp file into a running program is four stages — preprocess, compile, assemble, link — that clang++/g++ run in one invocation:

Preprocess

This section’s examples are written to compile clean under:

clang++ -std=c++23 -Wall -Wextra -o hello hello.cpp
./hello

-std=c++23 selects the language edition; -Wall -Wextra turns on the warnings that catch most beginner mistakes (unused variables, sign comparisons, uninitialized reads). Add -Werror in CI once a codebase is warning-clean, so new warnings fail the build instead of accumulating.

Compiler Explorer

Compiler Explorer ("Godbolt") compiles a snippet against dozens of compiler versions/-std= combinations in the browser and shows the generated assembly side by side — the fastest way to check whether a given compiler actually implements a specific C++20/23 feature before committing to it in a real project.

See Also