Back to Basics: Understanding Value Categories - Ben Saks - CppCon 2019

CppCon · 48K views · 2019 · 53:48

Open on YouTube

C, C++, Rust, Go & systems languagestalk

Why Stack Overflow recommends it

Stack Overflow users link it in answers and comments whenever someone is confused about lvalues, rvalues, xvalues and references, calling it one of the best explanations of value categories.

Recommended by 5 people across 5 different months, 2020 to 2025.

What it is

A CppCon 2019 Back to Basics talk by Ben Saks explaining C++ value categories: lvalues, rvalues and xvalues. It covers why the language distinguishes them, how they affect built-in operators and compiler errors, and how lvalue and rvalue references behave.

What people said

Strong rec Jesper Juhl · 2025-04 · Stack Overflow · on “Is this an l-value or an r-value?”

This is one of the best explanations of value categories I know of: Back to basics: Understanding Value Categories - Ben Saks - CppCon 2019 [this video] - I highly recommend watching the video.

Strong rec Jesper Juhl · 2025-04 · Stack Overflow · on “Is this local an rvalue?”

One of the best explanations of value categories I know of: Back to basics: Understanding Value Categories - Ben Saks - CppCon 2019 [this video] - I highly recommend watching the video.

Recommends Wagner Patriota · 2020-03 · Stack Overflow · on “Why can we only initialize structs with primitive types or pointers?”

@lollercoaster, here [this video] ... there are many good videos in this channel for improving your C++ skills ;-)

Recommends Goswin von Brederlow · 2022-03 · Stack Overflow · on “Contradicting definition of references”

@SolvedGames A variable is always an object, anything with a name is an object. But you can also return a reference from a function and the return value is not an object but an rvalue. You have to assign it to some variable for it to become an object. But sometimes such rvalues can become objects implicitly, e.g. when they are converted to another type in a function call: `foo(bar())` where foo takes a reference and bar returns a reference of another type that is implicitly converted. Watch this talk [this video]

Recommends ofkilmurray · 2023-08 · Stack Overflow · on “Why are string literals lvalues and not xvalues?”

Ben Saks in his lesson "Understanding Value Categories" at the 2019 CppCon in Aurora (CO) (great lesson btw) said: "Character string literals, such as "examplestring", are lvalues because they are basically arrays and they need to be stored in memory." At the end of the lesson a person ask this question to Ben: "Did you really mean that string literals are lvalues? because, if they are, why I can't assign to a string literal?" He answered "yes, because they act like array and they need a place in memory" This confused me a little bit So I have some questions: If the only reason why string literals are lvalues is that, why they cannot be temporary rvalues? During that lesson he explained that

Recommends kingsjester · 2024-11 · Stack Overflow · on “Are literal strings and function return values lvalues or rvalues?”

A good video on the subject : Back to Basics : Understanding Value categories - Ben Saks - cppCon 2019 : [this video]