Skip to content

Latest commit

Β 

History

History
76 lines (51 loc) Β· 2.77 KB

File metadata and controls

76 lines (51 loc) Β· 2.77 KB

πŸ“˜ C++ Value Categories β€” Visual Study Guide

A comprehensive, beginner-friendly PDF guide to understanding lvalue, prvalue, and xvalue in modern C++ β€” with move semantics, perfect forwarding, copy elision, and comparisons with Rust, Python & Java.


πŸ—‚ What's Inside

The guide covers 12 sections in a dark-themed, pedagogical PDF format:

# Section Topics
01 Why does it matter? Move semantics, perfect forwarding, copy elision
02 Glossary 18 technical terms explained in plain language
03 Taxonomy Visual diagram of all 5 value categories
04 lvalue Named entities, stable identity, classic pitfalls
05 prvalue Pure values, temporary materialization, RVO
06 xvalue std::move internals, use-after-move danger
07 glvalue & rvalue The two super-categories explained
08 Move Semantics Copy vs move constructors, Rule of Five
09 Perfect Forwarding std::forward, universal references, reference collapsing
10 decltype & parentheses The subtle return (x) vs return x trap
11 Other languages Rust ownership, Python references, Java/C# comparison
12 Quiz + Cheat Sheet 6 annotated questions + express recap table

πŸ“₯ Download

πŸ‘‰ cpp_value_categories_guide.pdf


🧠 Who Is This For?

  • Developers learning C++ who want to understand value categories properly
  • Experienced programmers coming from Python, Java, or Rust looking for cross-language context
  • Anyone preparing for a C++ technical interview
  • Developers who want to understand why std::move works the way it does

πŸ”‘ Key Concepts Covered

lvalue    β†’  Has identity, not movable   (e.g. named variables)
prvalue   β†’  No identity, movable        (e.g. literals, temporaries)
xvalue    β†’  Has identity, movable       (e.g. std::move(x))
glvalue   β†’  lvalue βˆͺ xvalue            (anything with identity)
rvalue    β†’  prvalue βˆͺ xvalue           (anything movable)

πŸ’‘ The Core Intuition

Instead of thinking "left side / right side of =", think in terms of two independent questions:

  1. Does this expression have a stable memory address? β†’ Identity
  2. Can we steal its internal resources? β†’ Movability

Every C++ expression answers these two questions β€” and that determines everything about how the compiler handles copies, moves, and optimizations.


πŸ›  Built With

  • Python + ReportLab for PDF generation
  • C++11 / C++14 / C++17 / C++23 standard references
  • Examples tested with GCC and Clang

πŸ“„ License

MIT β€” feel free to share, adapt, and redistribute with attribution.