{
  "schema_version": "1.0",
  "codex": "thecodex.expert/coding",
  "type": "language-reference",
  "slug": "languages/cpp",
  "name": "C++",
  "section": "Languages",
  "canonical_definition": "C++ is a general-purpose, statically typed, compiled programming language that extends C with classes, templates, RAII-based resource management, and the Standard Template Library \u2014 providing zero-overhead abstractions for systems programming, game engines, and high-performance applications.",
  "confidence": "high",
  "last_verified": "2026-06-01",
  "url": "https://thecodex.expert/coding/languages/cpp/",
  "current_standard": "C++23 (ISO/IEC 14882:2024)",
  "widely_deployed": "C++17, C++20",
  "created": "1979 (C with Classes); C++98 standardised",
  "creator": "Bjarne Stroustrup (Bell Labs)",
  "typing": "static, strong",
  "execution": "native compiled (GCC, Clang, MSVC)",
  "memory_management": "manual + RAII (smart pointers: unique_ptr, shared_ptr)",
  "paradigms": [
    "procedural",
    "object-oriented",
    "generic (templates)",
    "functional"
  ],
  "key_concepts": {
    "RAII": "Resource Acquisition Is Initialisation \u2014 resources tied to object lifetimes; destructors guarantee cleanup",
    "templates": "Compile-time generic programming; Turing-complete; reified (unlike Java generics)",
    "move_semantics": "Transfer resource ownership without copying; enabled by rvalue references (&&)",
    "rule_of_five": "If any of destructor/copy-ctor/copy-assign/move-ctor/move-assign is defined, define all five",
    "smart_pointers": "unique_ptr (single owner), shared_ptr (ref-counted), weak_ptr (non-owning)",
    "vtable": "Virtual dispatch via hidden vptr + vtable of function pointers",
    "concepts": "C++20 template constraints with readable error messages"
  },
  "critical_notes": {
    "c_vs_cpp": "C and C++ are different languages; not all C is valid C++",
    "no_raw_new": "new/delete are obsolete in modern C++ \u2014 use make_unique/make_shared",
    "templates_reified": "Templates are reified at compile time \u2014 compiler generates code per type; unlike Java erasure",
    "exceptions_cost": "Exceptions have near-zero cost when not thrown, but significant cost when thrown",
    "undefined_behaviour": "Inherits C's undefined behaviour; compiler actively uses UB for optimisation"
  },
  "standard_versions": {
    "C++98": "First standard \u2014 classes, templates, STL, exceptions, namespaces",
    "C++03": "Defect fixes",
    "C++11": "auto, range-for, lambdas, move semantics, smart pointers, constexpr, thread, nullptr",
    "C++14": "Generic lambdas, variable templates",
    "C++17": "Structured bindings, if constexpr, std::optional, std::variant, std::filesystem, parallel algorithms",
    "C++20": "Concepts, ranges, coroutines, modules, std::format, span, <=>",
    "C++23": "std::expected, std::print, std::stacktrace, std::generator, import std"
  },
  "notable_uses": [
    "Unreal Engine",
    "Unity runtime",
    "Chromium",
    "Firefox",
    "GCC",
    "Clang",
    "MySQL",
    "MongoDB",
    "HFT systems",
    "PlayStation/Xbox SDKs"
  ],
  "sources": [
    {
      "num": 1,
      "citation": "ISO/IEC 14882:2020. C++20 Standard. iso.org/standard/79358.html.",
      "tier": 1
    },
    {
      "num": 2,
      "citation": "Stroustrup, B. (2013). The C++ Programming Language (4th ed.). Addison-Wesley.",
      "tier": 1
    },
    {
      "num": 3,
      "citation": "Meyers, S. (2014). Effective Modern C++. O'Reilly Media.",
      "tier": 1
    },
    {
      "num": 4,
      "citation": "Stroustrup, B. & Sutter, H. C++ Core Guidelines. github.com/isocpp/CppCoreGuidelines.",
      "tier": 1
    },
    {
      "num": 5,
      "citation": "cppreference.com. C++ reference. en.cppreference.com.",
      "tier": 1
    }
  ]
}