Colin's Blog

Recent content on Colin's Blog

马上订阅 Colin's Blog RSS 更新: https://blog.oyyko.com/index.xml

Value_categories_in_Cpp

finalwind42@gmail.com (Oyyko)
2022年8月23日 15:20

Intro

1#define IS_XVALUE(expr) \2(is_rvalue_reference<decltype((expr))>{})3#define IS_PRVALUE(expr) \4(!is_reference<decltype((expr))>{})5#define IS_LVALUE(expr) \6(is_lvalue_reference<decltype((expr))>{})

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...

剩余内容已隐藏

查看完整文章以阅读更多