Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

The C++ reference that explains itself

All 6,587 pages of cppreference, with 115 deep-dive topics, 12 interactive debuggers and 876 quiz questions that cite the standard.

value-categories.quiz
Warm-up

Given int x = 10;, what are the deduced types of a and b below?

int x = 10;
decltype(x)   a = x;
decltype((x)) b = x;

The whole language on one map

Explore 4 continents, 13 countries, and 115 towns across C++, trace prerequisite routes between ideas, or open the full-screen world atlas.

Language basicsBuilding abstractionsThe machineLibrary and C++26ProgramstructureTypes andinitializationValuesemanticsExpressionsand functionsClassesTemplatesExceptionsand errorhandlingMemory modelConcurrencyContainersand stringsIterators,algorithmsand rangesLibraryutilitiesC++26
  • Not read yet
  • Read
  • Debugger
  • Next up
  • Land route
  • Sea crossing

115 topics in 13 tracks

Browse all 115 topics

Inside every town: Read it. See it. Trace it.

Every topic is an article and a concept map, and some add a live debugger.

value-categories/article.md

Traditional C textbooks define lvalues and rvalues by where they sit around an assignment operator. In modern C++, that rule collapses immediately: a const int cannot sit on the left of =, yet it is an lvalue; meanwhile, a class rvalue like std::string{} = "ok" is allowed on the left of =, yet it is a prvalue. Every expression in C++—never a variable declaration—belongs to a value category governed by two independent properties.

Expressions have value categories, not variables

A variable has a declared type, such as int, const Widget&, or Widget&&. An expression appearing in code has both a non-reference type (references are stripped during expression analysis) and a value category ([basic.lval]). Keeping those two dimensions separate resolves the single biggest source of confusion around move semantics:

snippet.cpp
#include <utility>

struct Widget {};
void consume(Widget& w);
void consume(Widget&& w);

void relay(Widget&& param) {
    // param's declared type is Widget&&, yet the expression `param` is an lvalue
    consume(param);            // calls consume(Widget&)
    consume(std::move(param)); // std::move returns unnamed Widget&& -> xvalue
}

Inside relay, param has a name and an addressable stack location, so the expression param is an lvalue, selecting consume(Widget&). Calling std::move(param) produces an unnamed Widget&&, which is an xvalue, selecting consume(Widget&&).

All of cppreference, at the same addresses

5,971 C++ pages and 616 C pages, each at the path you already know.

No account, nothing to install

Your progress stays in your browser, and every page is also plain Markdown.

115 topics and 6,587 reference pages