Value categories in Cpp - Colin Zhang
Home Blog About Resume Value categories in Cpp 2022-08-23 Table of Contents IntroTemporary materializationDecltype and value categoriesstd::move Intro#define IS_XVALUE(expr) \(is_rvalue_reference{})#define IS_PRVALUE(expr) \(!is_reference{})#define IS_LVALUE(expr) \(is_lvalue_reference{})This is a method I recently discovered to determine which value category an expression is. I'll explain why it works later.First, let's take a look at value categories in C++.One of the most important things you should notice before you start is that value categories are not a property about values, but rather a property about expressions. Actually it depends on how you understand value, I looked through the C++ standard but it seems they don't define what the term value means. However, we all know what an expression is. (in case you don't know, you can refer to cppreference)Anyway, there are 3 kinds of value categories. They are called LVALUE, PRVA...