And sadly it is wrong on many points cause he does exactly what he said we should not do: Try to come up with his own definitions for l/r-values. For example assigning to r-values is allowed and normal. So 6:20 and on are by the standard wrong. C++11 defined that L-values have identity, rvalues can be moved from. And an object can fall into both categories - so called xvalue.
@@ABaumstumpf but I don't understand L-Values o R-Values. If I have for example: -> double&& rref = std::sqrt(36.0); is the same than: -> double rref=6; So the variable called "&& rref" I can use it as a normal variable. So whats the point with L-Values o R-Values??? at the end both variables are the same.
@@jd_bruce It's actually really useful. every time you do "vector[2] = 4" you're essentially assigning a value to the result of std::vector::operator[]
My first thought was why should somebody need that, than he said it's useful with std::move etc... mindblown. Would have saved me some trouble with moving smart pointers
Yan! You rock! Even though this video was posted 4 years ago it is still relevant and to the point. There is still no resource on the whole internet who can explain it smoothly. Love the videos! You rock!
lvalue has two components 1) value 2) address rvalue has only 1) value ----- rvalue is allowed only on right hand side on assignment only lvalue is allowed on left hand side of assignment lvalue is allowed on right hand side of assignment ----- On right hand side of assignment 1. As rvalue only has value, it's value is used 2. As lvalue has both value and address, what gets used depends on left hand side expression On left hand side of assignment 1. Only address part of lvalue is used 2. As rvalue doesn't have address, it cannot be used ----- rvalue reference is just an optimization hack.
Speaking of operator overloading: If you have two string variables x and y, then the rvalue x+y can also appear on the left hand side of an assignment, i.e. x+y="wat" is perfectly valid (albeit nonsensical) C++.
@@fredoverflow it has nothing to do with lvalue or rvalue. It's just syntactic sugar for calling function named "operator=". lvalue/rvalue distinction is applicable for assignments only, and not for overloaded = operator.
*My takeaways:* 1. lvalues vs rvalues 4:25 2. Main advantages 11:35 3. lvalues are variables with some kinds of storage backing them, rvalues are temporary values 12:25
Hey Yan, just wanted to say that thanks to you I got a final 95 grade in Systems Programming course in my university (Computer Science BSc). Thanks a lot! I'm 100% sure that you have the best programming series. period. As a side note, no one EVER got me this excited to code and study :)
I am not a programmer/software developer/coder. I'm not even sure I am referring to the right profession. I got here because I watched the reaction to unreal engine 5 and the ps5 (part 1). The way you explained things in those two videos got me hooked and now I'm watching a video on C++. I am a doctor and a lawyer and C++ is totally alien to me. But I found myself watching this video and "understanding" the main concepts you wanted to get across, which is a testament to how well you can grasp the important lessons and convey them to your audience. Made me want to study programming now (my wife would kill me). I went to a high school in the Philippines and back in 1982, it was one of the first high schools in my country which taught programming. We were taught how to program in "basic". A lot of my classmates became programmers and are now working in the US or have their own software companies. I went down a different path but if I had you as a teacher, who knows, I might now be working on dynamic global illumination and triangles, etc. You should try to fit in a teaching job in between your project development schedules. A lot of programmers/software developers/coders would benefit from your teaching and hopefully, someday come up with something special themselves. You would have the satisfaction of having a hand in shaping the minds of these future superstar developers.You can inspire them.
@@TWiStErRob it's only 4 minutes of video lmao. rest of 10 minutes took me like half an hour, i was playing around with code and googled additional stuff. not much time wasted. pretty sure it was painful to read, but yo get the point
I'm actually learning c++ since 2 months now and this kind of Videos about c++ makes me happy that I decided to pick up c++ . I started with c and python because it was recommended everywhere but with python it was like owning a iPhone or working with windows. It's very simple to use and intuitive but you just don't feel satisfied. C++ is like switching to android or linux. You are overwhelmed by the freedom and possibilities and it just feels amazing to learn all the things and feel the power of that systems. I hope that makes sense.
I'm learning C++ and immediately came across this syntax. The two books I have on C++ didn't explain rvalues/lvalues as well as you did with your examples. Thanks!
Digging the covid beard Also probably the most helpful channel I've found on youtube in regard to c++. If anyone ever asks me anything about this sort of programming this is straight where they're getting sent.
There's something wrong in this explanation, and it's really easy to get wrong. I have to mention it here in case anyone get confused. *_Initialization is not assignment_* , though they share the equals sign... Assuming s is an std::string, when you do { std::string t = s; } that's *_initialization_* , calling the copy *_constructor_* std::string(const std::string&); when you do { std::string t; t = s; } that's *_assignment_* , calling the copy *_assignment operator_* std::string& operator=(const std::string&); You see, these two equals signs are calling different member functions, since they're inherently different operations. Although there should be no difference in the result, but first default construct an object an immediately reassign it is performance-wise not efficient. It's all the same when rvalue references are in the question, e.g. { std::string t = std::string("I'm a string"); } is calling the move *_constructor_* , std::string(std::string&&); on the other hand { std::string t; t = std::string("I'm a string"); } is calling the move *_assignment operator_* , std::string& operator=(std::string&&); Several videos titled "Back to Basics" in cppcon explain these basic C++ knowledge really clearly, so if anyone needs more detailed and thorough explanations please refer to those videos.
I use L and R values all the time, have dealt with move semantics, etc. Clicked the link because I knew I always learn something new from you anyway. Did not disappoint. Excellent presentation of this material.
If I remember correctly, then Titus Winter (or was it Herb Sutter?) gave a pretty good talk at CppCon some time in the past where he talked about all kind of value types. Very simply spoken, he just said: Everything that has a name is a lvalue, everything that doesn't is a rvalue. In detail it sure gets more complicated than that, but I found that explanation quite intuituve and maybe it helps somebody.
I like STL's (Stephan T. Lavavej) explanation, if you can get its address, its an lvalue, otherwise its an rvalue. This covers cases where an lvalue might not have a name, like as the result of a getter function call.
@@oracleoftroy I was going to object "you can take the address of an xvalues (which are rvalues but not prvalues)" but I wisely tested that before posting and.... you actually can't! even though an xvalue is an already constructed object that _has_ an address, turns out the compiler won't let you use the address-of operator on it.... TIL
@@MatthijsvanDuin I wouldn't be surprised if there are exceptions, the goal after all is to have a reasonable approximation that works in many situations. STL's version works remarkably well in practice.
@@rvoros No, *i* has an address on the stack that you are printing out. An rvalue like *10* does not have an address. Even change the parameter to *const int &&i* and *i* will itself be an lvalue that takes an rvalue.
Chinese is my native language, I read an article in Chinese talking about the same topic and didn't understand. But now it's almost crystal clear to me thanks to this video! How do you remember these things if you're not using them every day? This is one of my biggest headaches about learning cpp
@The Cherno, so then if lets say void setValue(const int& value) accepts both lvalue and rvalue, how come simply saying void setValue(int value) accepts both too?
@@battosaijenkins946 by passing by value you make another copy of variable which is lvalue type. The difference is present only when you are using references in order to make your code more effective by avoiding unnecessary copying especially when it comes to large objects.
@@battosaijenkins946 The parameter (the variable "value" inside setValue()) is initialized from the argument expression. In case of void setValue(int value) that means it will construct a new int, regardless of what type of expression the argument is. If you use some class instead of int then you'll see a constructor of that class will get invoked (which one will depend on what type of expression the argument is). In case of void setValue(int const &value) the caller needs to provide an object (of type int) to which the parameter will bind. This means that if your expression is an "lvalue" (technically a glvalue, any expression that designates an existing object), then no new object will be constructed and "value" will refer to that existing object. If your expression is an "rvalue" (technically a prvalue) then as he explained in the video, a new temporary object will be constructed from this expression and the parameter will bind to that.
Locator? Never heard of that. I always heard them as left-hand and right-hand values. Although as you point out they aren't always on the left or right of an equals. Then again I learned lvalue and rvalue in C first. Also really glad you decided to cover move semantics. I was left wanting after your smart pointer video. There's so much opportunity to talk about heap allocation ownership and tying lifetime to stack variables that can be moved.
Thank you so much not only for this but also this whole series. This video specifically helped me fix a bug I had been stuck on for days for those wondering I was trying to take the memory address of an r value and then after watching this I was like wait this doesnt have a memory address of course this doesnt work . Thank you so much
Agreed! I've found Scott Meyer's books to be very precise and comprehensive though. Plus it goes even deeper and addresses universal references. There are definitely worse books out there. Also, there are so many cpp talks that leave me totally confused because you have to remember code from 200 different presentation slides. But yea, these videos are great for a simple introduction to the topic.
I am studying compiler design and this came up in the book so that helped me There were also two stage mapping where the name points to location and called environment
great job, I was looking for it a long time ago and after 1 month of research I finally got all of my answers, this is really good, I want you to explain it fully so other people can save their time :D Thanks a lot.
Perfect. Fantastic topic. This topic is very tied to move semantics as you already said. C++ is a great language because a programmer can manually do whatever he wants to reduce copying, manipulate with memory, do some optimization but if there is no awareness of that, using c++ has no much sense. It is like you want to clean your bathroom but with no special reason to do that. Good job!
I've learned 10x as much about C++ in a week of watching your videos than I did in an entire semester of 'Imperative Programming in C++' in my bachelor.
Cherno: You shouldn't try to find a definition for what l value and r value mean. Also Cherno 15 seconds later: left side and right side are a good way to think of them.
I work in industry and I kept struggling with teaching a new team member who came from python what l and r values are. I ended up sending him here after trying to explain it over and over. I did some of your examples but I couldn't explain it the way he wanted to hear it. Thanks ^^
Writing const reference in a function domain, is like writing no reference but avoiding the coping of input element when the function starts, and so optimize the code for the memory.
Been watching C++ series for a while. Great stuff. Just an aside, my compliments to you and your partner (if you have one with you) for the very nice home you have. Seeing various furniture, and now the kitchen, you obviously have good taste and done some wonderful things with your home. (see? Some folks DO notice more than just your skills as a C++ tutor 😉 )
Thanks a lot for these C++ videos. They helped me out with a project at work that turned out great. I ported code from Python to C++ and saw a 10x speed improvement!
Great Video as Lvalue is passed in function refereing to same name object and extracting data and act as reference good you cleared my concept after a long long time I found a good video.
Thank you Cherno, your explanation why we use move semantics is so much better than what I have read from books. You have created a great playlist to understand C++ more.
mind blowing, especially the two ampersand operator &&. I wasn't taught this at school since I believe many teachers don't see these important. However, I understand more deeply about how c++ works
if you had a udemy course you'd sell so much. you explain stuff so quick but so well. A lot of courses will explain something for 30 minutes and not do it correctly. Your examples in live code are the best
Two main takeaways: rval - temp values. lval - saved in memory, 1. const int & : this can accept rval but int & will only accept lval. 2. int && : this can only accept rval
So taking an rvalue reference means your function owns it, while taking a lvalue reference means &mut, and a const lvalue reference is a immutable reference. Nice simulation of the ownership system.
Simulation? Rust took the core concept from C++ and gave it more explicit syntax with better defaults. In that regard, Rust was the first "C++ killer" language that actually understood what D and C# and Java and Go and all the other failed replacement languages missed: resource management is core and having a universal system to automatically manage all resources is powerful. As awesome as Rust is, and for all the improvements it offers, Rust is standing on the shoulders of giants.
Man just following along with this makes things so much easier to understand in class. Thanks again Chrono, I also learned that he is an expert grind presser.
C/C++ are my favorite programming languages. I love to learn new things about them and the way this clarifies lvalues and rvalues is absolutely fantastic, thanks a lot.
Thanks Cherno! I always wondered what the compiler was referring to in terms of l and r values. Had no idea it was actually a pretty simple concept. As always, thank you!
i programmed with c++ and c for some 3 years very young and with only some books and printed docs... from time to time, to add performance, or understand some underlaying low level code, dealing with unreal engine(have been studying it for the past 2 years). I always have to get some refresh on tge language. It is contraintuitive to see such a young dude so skilled in a language that is incredible, but kind of old school.
This was extremely helpful. I wish I found this video series earlier in my quarter, it would have helped me not bomb my first midterm lmao. Thanks to you though, there's still hope for my final. Thank you so much
rvalue does have a memory location but only temporarily, the point of && rval reference is to steal those resources before they get destroyed, which means copying is not needed. ( I know this sentence is does not make sense to someone new to this. Might edit this later) Move constructor uses this concept.
Wow, I´ve had problems in my code, and I had no idea why it didn´t work, and noticed that it only worked on saved variables. Thanks to this, you´ve basically solved my problem, and can now edit it to make my some work. Thank you very much ^^
I just watched this video on common hand positions in lectures and holy shit you went through like all of them in 15 seconds. You are a very talented lecturer.
Welcome Back Champ!! Thanks for the informative video on this topic,most of the online sites are quite confusing but you made it quite clear.Please post more videos on advanced C++ topics such as lambda function , constexpr , and new feature of C++ 17 and C++ 20....Also could you please suggest online materials for c++ that you refer usually? Thanks.STAY SAFE HOME!
I know about that topic and advanced C++ concepts like move semantics already, but have to admit you do a pretty good job at explaining stuff like that to beginners. Great work. Hope you explain one day about why passing parameters by value and letting the compiler chose what to do might be good for performance. There’s so much to learn about C++, that’s why I like it.
The C++ series is definitely my favorite.
This is the MOST clear explanation of r- and l- values I've ever heard or read
And sadly it is wrong on many points cause he does exactly what he said we should not do: Try to come up with his own definitions for l/r-values.
For example assigning to r-values is allowed and normal. So 6:20 and on are by the standard wrong.
C++11 defined that L-values have identity, rvalues can be moved from. And an object can fall into both categories - so called xvalue.
@@ABaumstumpf but I don't understand L-Values o R-Values. If I have for example:
-> double&& rref = std::sqrt(36.0);
is the same than:
-> double rref=6;
So the variable called "&& rref" I can use it as a normal variable. So whats the point with L-Values o R-Values??? at the end both variables are the same.
*adds another ampersand*
H O L Y C R A P
These videos make me feel like an absolute idiot in C++
Lmao he loved this, SAVAGE xD
It also blew my mind when he assigned a value to the result of the function... seems pretty useless though.
@@jd_bruce It's actually really useful. every time you do "vector[2] = 4" you're essentially assigning a value to the result of std::vector::operator[]
My first thought was why should somebody need that, than he said it's useful with std::move etc... mindblown. Would have saved me some trouble with moving smart pointers
condescend me daddy!
Yan! You rock! Even though this video was posted 4 years ago it is still relevant and to the point. There is still no resource on the whole internet who can explain it smoothly. Love the videos! You rock!
lvalue has two components 1) value 2) address
rvalue has only 1) value
-----
rvalue is allowed only on right hand side on assignment
only lvalue is allowed on left hand side of assignment
lvalue is allowed on right hand side of assignment
-----
On right hand side of assignment
1. As rvalue only has value, it's value is used
2. As lvalue has both value and address, what gets used depends on left hand side expression
On left hand side of assignment
1. Only address part of lvalue is used
2. As rvalue doesn't have address, it cannot be used
-----
rvalue reference is just an optimization hack.
rvalues of class type DO have and address and CAN appear on the left hand side of assignment: std::string("hello") = "bye";
@@fredoverflow ever heard of copy constructor!?
@@fredoverflow or operator overloading for that matter?
Speaking of operator overloading: If you have two string variables x and y, then the rvalue x+y can also appear on the left hand side of an assignment, i.e. x+y="wat" is perfectly valid (albeit nonsensical) C++.
@@fredoverflow it has nothing to do with lvalue or rvalue. It's just syntactic sugar for calling function named "operator=". lvalue/rvalue distinction is applicable for assignments only, and not for overloaded = operator.
*My takeaways:*
1. lvalues vs rvalues 4:25
2. Main advantages 11:35
3. lvalues are variables with some kinds of storage backing them, rvalues are temporary values 12:25
For me lvalues == "Location", rvalues == "tempoRary".
@@ikemkrueger what about a global on the right side.
@@ikemkrueger That was the first thing I was thinking when I heard about it aswel !
Hey Yan, just wanted to say that thanks to you I got a final 95 grade in Systems Programming course in my university (Computer Science BSc). Thanks a lot! I'm 100% sure that you have the best programming series. period.
As a side note, no one EVER got me this excited to code and study :)
congratulations 🥰🥰
@@richardlyman2961 yes, you asked on April 27th 2019 at around 12:37 UTC. Why?
0:21 I HEARD IT, I SWEAR I DID, 4 years before the incident, he said it
I am not a programmer/software developer/coder. I'm not even sure I am referring to the right profession. I got here because I watched the reaction to unreal engine 5 and the ps5 (part 1). The way you explained things in those two videos got me hooked and now I'm watching a video on C++. I am a doctor and a lawyer and C++ is totally alien to me. But I found myself watching this video and "understanding" the main concepts you wanted to get across, which is a testament to how well you can grasp the important lessons and convey them to your audience. Made me want to study programming now (my wife would kill me).
I went to a high school in the Philippines and back in 1982, it was one of the first high schools in my country which taught programming. We were taught how to program in "basic". A lot of my classmates became programmers and are now working in the US or have their own software companies. I went down a different path but if I had you as a teacher, who knows, I might now be working on dynamic global illumination and triangles, etc.
You should try to fit in a teaching job in between your project development schedules. A lot of programmers/software developers/coders would benefit from your teaching and hopefully, someday come up with something special themselves. You would have the satisfaction of having a hand in shaping the minds of these future superstar developers.You can inspire them.
Just checking in to see whether you've made a career switch haha
You are a doctor AND a lawyer?! AND now you are also learning programming?! Your parents must be damn proud of you.
The core explanation starts at 3:55.
Just wanted to write the same, so much of "the thing I'm going to talk about", so much time wasted.
just wanted to type the same
Thnx😂
THANK YOU
@@TWiStErRob it's only 4 minutes of video lmao. rest of 10 minutes took me like half an hour, i was playing around with code and googled additional stuff. not much time wasted. pretty sure it was painful to read, but yo get the point
Great explanation!! Thanks.
- int& a; //lvalue reference
- const int& a; //support both lvalue and rvalue(by temporary storage) reference
- int&& a; //rvalue reference
const reference in function for "temporary" rvalue, at 10:05. void Print(const std::string& name)
Everybody: blown mind
Cherno: bored so he has to fiddle with paprika
I'm actually learning c++ since 2 months now and this kind of Videos about c++ makes me happy that I decided to pick up c++ . I started with c and python because it was recommended everywhere but with python it was like owning a iPhone or working with windows. It's very simple to use and intuitive but you just don't feel satisfied. C++ is like switching to android or linux. You are overwhelmed by the freedom and possibilities and it just feels amazing to learn all the things and feel the power of that systems. I hope that makes sense.
man I hated Python, and I still sometimes do
I'm learning C++ and immediately came across this syntax. The two books I have on C++ didn't explain rvalues/lvalues as well as you did with your examples. Thanks!
Digging the covid beard
Also probably the most helpful channel I've found on youtube in regard to c++.
If anyone ever asks me anything about this sort of programming this is straight where they're getting sent.
There's something wrong in this explanation, and it's really easy to get wrong. I have to mention it here in case anyone get confused.
*_Initialization is not assignment_* , though they share the equals sign...
Assuming s is an std::string,
when you do { std::string t = s; } that's *_initialization_* , calling the copy *_constructor_* std::string(const std::string&);
when you do { std::string t; t = s; } that's *_assignment_* , calling the copy *_assignment operator_* std::string& operator=(const std::string&);
You see, these two equals signs are calling different member functions, since they're inherently different operations.
Although there should be no difference in the result, but first default construct an object an immediately reassign it is performance-wise not efficient.
It's all the same when rvalue references are in the question, e.g. { std::string t = std::string("I'm a string"); } is calling the move *_constructor_* , std::string(std::string&&); on the other hand { std::string t; t = std::string("I'm a string"); } is calling the move *_assignment operator_* , std::string& operator=(std::string&&);
Several videos titled "Back to Basics" in cppcon explain these basic C++ knowledge really clearly, so if anyone needs more detailed and thorough explanations please refer to those videos.
thx!!!!!!
Thanks. This comment definitely adds value to the video.
Definitely one of the best detailed explanation on l and r values in c++
Thanks!
I use L and R values all the time, have dealt with move semantics, etc. Clicked the link because I knew I always learn something new from you anyway. Did not disappoint. Excellent presentation of this material.
If I remember correctly, then Titus Winter (or was it Herb Sutter?) gave
a pretty good talk at CppCon some time in the past where he talked
about all kind of value types. Very simply spoken, he just said:
Everything that has a name is a lvalue, everything that doesn't is a
rvalue. In detail it sure gets more complicated than that, but I found
that explanation quite intuituve and maybe it helps somebody.
I like STL's (Stephan T. Lavavej) explanation, if you can get its address, its an lvalue, otherwise its an rvalue. This covers cases where an lvalue might not have a name, like as the result of a getter function call.
@@oracleoftroy I was going to object "you can take the address of an xvalues (which are rvalues but not prvalues)" but I wisely tested that before posting and.... you actually can't! even though an xvalue is an already constructed object that _has_ an address, turns out the compiler won't let you use the address-of operator on it.... TIL
@@oracleoftroy well...
how about this:
#include
void f(const int& i) {
const int* p = &i;
std::cout
@@MatthijsvanDuin I wouldn't be surprised if there are exceptions, the goal after all is to have a reasonable approximation that works in many situations. STL's version works remarkably well in practice.
@@rvoros No, *i* has an address on the stack that you are printing out. An rvalue like *10* does not have an address. Even change the parameter to *const int &&i* and *i* will itself be an lvalue that takes an rvalue.
Chinese is my native language, I read an article in Chinese talking about the same topic and didn't understand. But now it's almost crystal clear to me thanks to this video!
How do you remember these things if you're not using them every day? This is one of my biggest headaches about learning cpp
Mandarin is harder than C++, haha
@@AdiPrimandaGinting true that..
@@AdiPrimandaGinting Nah mother language is always the easiest. Also chinese is really easy but they just have a nightmare writing system.
很多中文翻譯的專有名詞,看得很一頭霧水。還不如直接去看原文的code說明教學,比較快理解
I really hope you won't stop there as this whole topic seems to be quite hard to understand and you make such things appear really simple.
@The Cherno, so then if lets say void setValue(const int& value) accepts both lvalue and rvalue, how come simply saying void setValue(int value) accepts both too?
@@battosaijenkins946 by passing by value you make another copy of variable which is lvalue type.
The difference is present only when you are using references in order to make your code more effective by avoiding unnecessary copying especially when it comes to large objects.
@@battosaijenkins946 The parameter (the variable "value" inside setValue()) is initialized from the argument expression. In case of void setValue(int value) that means it will construct a new int, regardless of what type of expression the argument is. If you use some class instead of int then you'll see a constructor of that class will get invoked (which one will depend on what type of expression the argument is). In case of void setValue(int const &value) the caller needs to provide an object (of type int) to which the parameter will bind. This means that if your expression is an "lvalue" (technically a glvalue, any expression that designates an existing object), then no new object will be constructed and "value" will refer to that existing object. If your expression is an "rvalue" (technically a prvalue) then as he explained in the video, a new temporary object will be constructed from this expression and the parameter will bind to that.
@@alextiga8166 So if I do setValue(const int& value) then im not copying at all as oppposed to setValue(int value), is that correct?
@@battosaijenkins946 yes, the "value" variable inside the function will be a reference to the variable you passed in this case.
Remarkable! The way you explain stuff with such clarity and ease is second to none.
This has plagued me for long, and I've been programming in C++ (03) for years. Thank you!
Locator? Never heard of that. I always heard them as left-hand and right-hand values. Although as you point out they aren't always on the left or right of an equals. Then again I learned lvalue and rvalue in C first. Also really glad you decided to cover move semantics. I was left wanting after your smart pointer video. There's so much opportunity to talk about heap allocation ownership and tying lifetime to stack variables that can be moved.
8:20 to be exact, that special rule was added to not break backwards compatibility with older systems because move-semantics were only added in C++11
Awesome video Cherno! Been coding with modern C++ for a few months now, but can FINALLY say I understand rvalues and lvalues! :D
Thank you so much not only for this but also this whole series. This video specifically helped me fix a bug I had been stuck on for days for those wondering I was trying to take the memory address of an r value and then after watching this I was like wait this doesnt have a memory address of course this doesnt work . Thank you so much
never heard this been explained so clear
Excellent explanation about l and r values ... you are genius 😍😍😍😍
I love to listen when you talk about c++ don't stop pleas. This is gold.
Just finished the chapter on the exact same topic in Scott Meyer's book Effective Modern C++. Thanks for summarising it so well!
I just started to read this book too, but books sometimes are really hard to understand while Cherno videos always make any topic sound really simple.
Agreed! I've found Scott Meyer's books to be very precise and comprehensive though. Plus it goes even deeper and addresses universal references. There are definitely worse books out there. Also, there are so many cpp talks that leave me totally confused because you have to remember code from 200 different presentation slides.
But yea, these videos are great for a simple introduction to the topic.
I am studying compiler design and this came up in the book so that helped me
There were also two stage mapping where the name points to location and called environment
Every tutorial you make is so informative and so well made. Thank you for making those videos free for all people.
great job, I was looking for it a long time ago and after 1 month of research I finally got all of my answers, this is really good, I want you to explain it fully so other people can save their time :D
Thanks a lot.
Woah, what a coincidence, I was just looking for a cohesive explanation of these yesterday! Great video, keep it up!
Extremely well explained, calling lvalues 'location values' entirely cleared up the cloudiness about this subject for me! Amazing job!
this is one thing I thought I'd never understand, but, as with most topics, you made it easy. thanks
The explanation can't be simpler than what Cherno mentioned. I am totally impressed.
Perfect. Fantastic topic. This topic is very tied to move semantics as you already said. C++ is a great language because a programmer can manually do whatever he wants to reduce copying, manipulate with memory, do some optimization but if there is no awareness of that, using c++ has no much sense. It is like you want to clean your bathroom but with no special reason to do that.
Good job!
Thank you for clarifying this topic. Well done.
This might be the only c++ tutorial TH-camr who doesn't have a shit ton of white noise in Evey video. Love this guy
I've learned 10x as much about C++ in a week of watching your videos than I did in an entire semester of 'Imperative Programming in C++' in my bachelor.
Clear to-the-point explanation. Your C++ series saves time googling a specific topic. Keep up the good work.
Cherno: You shouldn't try to find a definition for what l value and r value mean.
Also Cherno 15 seconds later: left side and right side are a good way to think of them.
I work in industry and I kept struggling with teaching a new team member who came from python what l and r values are. I ended up sending him here after trying to explain it over and over. I did some of your examples but I couldn't explain it the way he wanted to hear it. Thanks ^^
Thanks a lot Yan. This C++ series is really the best on TH-cam :)
Best sum up about glvalues and prvalues I saw, nicely described what is going on and what consequences and benefits it brings. ♥
WOW. I definitely need to watch this 5 more times and take 3 sets of notes, this is actually really useful and ingenious.
Writing const reference in a function domain, is like writing no reference but avoiding the coping of input element when the function starts, and so optimize the code for the memory.
You are seriously the only legit free video series for modern C++
Thanks a lot for partially sharing your knowledge for free!
Dude you really have a gift for explaining stuff. C++ and opengl programming has become very easy for me thank you
I had forgotten about this topic, but you made it clear and quick.
Been watching C++ series for a while. Great stuff. Just an aside, my compliments to you and your partner (if you have one with you) for the very nice home you have. Seeing various furniture, and now the kitchen, you obviously have good taste and done some wonderful things with your home. (see? Some folks DO notice more than just your skills as a C++ tutor 😉 )
Always clear, always good. Thanks
Thanks a lot for these C++ videos. They helped me out with a project at work that turned out great. I ported code from Python to C++ and saw a 10x speed improvement!
Great Video as Lvalue is passed in function refereing to same name object and extracting data and act as reference good you cleared my concept after a long long time I found a good video.
Thank you Cherno, your explanation why we use move semantics is so much better than what I have read from books. You have created a great playlist to understand C++ more.
I went from 0 to intermediate in C++ thanks to your C++ series. Keep it up! Thank you.
mind blowing, especially the two ampersand operator &&. I wasn't taught this at school since I believe many teachers don't see these important. However, I understand more deeply about how c++ works
I read a lot of articles and watched many videos about it but no one explained it clear and short like this
Thank you very much :D
This video answered so many questions that had been shelved in the back of my mind. Thank you.
if you had a udemy course you'd sell so much. you explain stuff so quick but so well. A lot of courses will explain something for 30 minutes and not do it correctly. Your examples in live code are the best
This is the BEST C++ playlist on the internet
Haven’t seen c++ since college been a while yet I still understood, strange how the mind works. Enjoyed the video.
This episodes topic reminds me of learning the Fundamental Thereom of Calculus, like it's such a fondational concept, nice job explaining.
Two main takeaways:
rval - temp values.
lval - saved in memory,
1. const int & : this can accept rval but int & will only accept lval.
2. int && : this can only accept rval
So taking an rvalue reference means your function owns it, while taking a lvalue reference means &mut, and a const lvalue reference is a immutable reference. Nice simulation of the ownership system.
Simulation? Rust took the core concept from C++ and gave it more explicit syntax with better defaults. In that regard, Rust was the first "C++ killer" language that actually understood what D and C# and Java and Go and all the other failed replacement languages missed: resource management is core and having a universal system to automatically manage all resources is powerful. As awesome as Rust is, and for all the improvements it offers, Rust is standing on the shoulders of giants.
Man just following along with this makes things so much easier to understand in class. Thanks again Chrono, I also learned that he is an expert grind presser.
Explained beautifully! appreciate the clarity it provides
C/C++ are my favorite programming languages. I love to learn new things about them and the way this clarifies lvalues and rvalues is absolutely fantastic, thanks a lot.
Thank you for explaining this concept so well! Looking forward to your video on move semantics!
Thanks Cherno! I always wondered what the compiler was referring to in terms of l and r values. Had no idea it was actually a pretty simple concept. As always, thank you!
i programmed with c++ and c for some 3 years very young and with only some books and printed docs... from time to time, to add performance, or understand some underlaying low level code, dealing with unreal engine(have been studying it for the past 2 years). I always have to get some refresh on tge language. It is contraintuitive to see such a young dude so skilled in a language that is incredible, but kind of old school.
Man, the video was great, it made lots of stuff more clear for me. Thank you for it!
This was extremely helpful. I wish I found this video series earlier in my quarter, it would have helped me not bomb my first midterm lmao. Thanks to you though, there's still hope for my final. Thank you so much
Can't find the right words of praise for you. My deepest gratitude and appreciation!
Never understood lvalue and rvalue so clearly before this video .Thank you ...very informative video
This was the clearest and most concise explanation of this topic that I have seen. Cheers!
This was a very clear explanation, thank you. I'm about to watch the move semantics video.
rvalue does have a memory location but only temporarily,
the point of && rval reference is to steal those resources before they get destroyed, which means copying is not needed. ( I know this sentence is does not make sense to someone new to this. Might edit this later)
Move constructor uses this concept.
*You just make it so simple. Thanks. BTW the large font used in IDE makes reading code easy to viewers. Nice.*
Way more clear than the articles I've tried to read.. thanks a lot!!
For the love of god, please don't stop making videos.
Btw , would like to see more on move semantics in c++. Thanks for the content.
Easily explained ... struggled to understand this two months back but when u illustrates it just seems like a peice of cake . 😁😁😁
9:11 Nice video, thank you! Just wanted to mention that according to the cpp standard string literals are lvalues actually
Cherno, thank you so much! Your videos are awesome, and I can't wait for move semantics.
I've been waiting for this! Thank You! :)
I was trying to understand this a year ago but left it there because too much information, this 10 minutes video made it crystal clear, thanks
thanks cherno, i’ve always found this topic to be confusing, but you thankfully made it clearer
I watched the ad of this videoon purpose bc you really deserve it :) thanks a lot for making this clear in my head!
Wow, I´ve had problems in my code, and I had no idea why it didn´t work, and noticed that it only worked on saved variables.
Thanks to this, you´ve basically solved my problem, and can now edit it to make my some work.
Thank you very much ^^
Yan, you are a rock star! I just subscribed to your Patreon btw.. Look forward to all your knowledge about C++ and many other things too. Take care
I just watched this video on common hand positions in lectures and holy shit you went through like all of them in 15 seconds. You are a very talented lecturer.
Thanks for the video
We are really looking forward to see your videos on design patterns 😇
Welcome Back Champ!! Thanks for the informative video on this topic,most of the online sites are quite confusing but you made it quite clear.Please post more videos on advanced C++ topics such as lambda function , constexpr , and new feature of C++ 17 and C++ 20....Also could you please suggest online materials for c++ that you refer usually?
Thanks.STAY SAFE HOME!
"lesson on skillshare and maybe a bit about c++ after"
Great explanation Mr. Черников
Rly like your way of explaining things
Thank you very much for the info and knowledge you provide : )
Thank you so much, i've only started learning C++ recently and this is just what i need
My God man. Watching C++ again brings back nightmares. Subbed!
I know about that topic and advanced C++ concepts like move semantics already, but have to admit you do a pretty good job at explaining stuff like that to beginners. Great work. Hope you explain one day about why passing parameters by value and letting the compiler chose what to do might be good for performance. There’s so much to learn about C++, that’s why I like it.