From 98c70b4c4546110ae6ab2ad36e7fee388c694f1d Mon Sep 17 00:00:00 2001 From: Vinayak Date: Wed, 10 Dec 2025 16:55:12 +0530 Subject: [PATCH] Enhance comments on lvalues and rvalues Added comments to explain lvalues and rvalues, including a memory address access tip. --- src/move_semantics.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/move_semantics.cpp b/src/move_semantics.cpp index 2f288e4..8e4f570 100644 --- a/src/move_semantics.cpp +++ b/src/move_semantics.cpp @@ -62,6 +62,9 @@ void add_three_and_print(std::vector &&vec) { int main() { // Take this expression. Note that 'a' is a lvalue, since it's a variable that // refers to a specific space in memory (where 'a' is stored). 10 is a rvalue. + // An easy trick to identify lvalues and rvalues will be whether you can + // access its address in memory i.e you can do int *ptr = &a but you can't do + // this for the literal 10. int a = 10; // Let's see a basic example of moving data from one lvalue to another.