Value category taxonomy & rvalue references
Split expressions along identity and movability into glvalue, prvalue, and xvalue so rvalue references (T&&) can steal resources safely from expiring objects.
#include <utility>
struct Buffer {
int* ptr = nullptr;
Buffer() = default;
Buffer(Buffer&& other) noexcept : ptr(other.ptr) {
other.ptr = nullptr;
}
};
Buffer make_buffer();
void consume(Buffer b) {
(void)b;
}
void transfer_resource() {
Buffer named;
consume(std::move(named)); // std::move casts lvalue -> xvalue so Buffer&& runs
}