this is the best c++ series this video was amazing
@MikeShah10 ай бұрын
Cheers, thank you for the kind words!
@RahulBochare-z5mКүн бұрын
great explanation ,Mike.Thanks
@MikeShahКүн бұрын
Cheers!
@k018512311 ай бұрын
Wow. I really enjoy how you break down these subtle concepts step by step. I came here because sometimes I am not sure about if some of my functions can return reference. I was wondering if that is related to this lvalue issue. So I didn't expect I'd learn this interesting "rvalue_reference"! This is so useful! I think sometimes it can indeed save computational time. Thank you very much for your sharing. I really love how to put everything together in one screen and smoothly control those windows. Hopefully one day I can be as professional as you! Thank you again!
@MikeShah11 ай бұрын
Cheers, thanks for the kind words! As for returning a reference -- just be careful when returning references to stack allocated data (same as with a pointer) -- as it's not clear what value will be in memory :)
@k018512311 ай бұрын
@@MikeShah Got it! Thank you for the reminder :)
@dwolrdcojp2 жыл бұрын
I appreciate the pop quizzes. Really improves the value of the lesson!
@MikeShah2 жыл бұрын
Thank you for the kind words! On lessons like this I like to throw those in to test folks understanding :)
@OzanCetinaslan6 ай бұрын
Hello Mike, you are a great teacher and lately I really enjoy your videos. Why I am watching I do not know maybe you explain really clean :) In this video I noticed a small issue at the beginning (4:30 ish) when you define Lval and Rval. You say Lval is on memory and Rval does not point to anything. I am not sure if this is really the case. If you think about how Bjarne define the object you understand what I mean. Object: a piece of memory, Variable: a named object. So, if you map this info to Lval and Rval I believe that you understand what I mean. For example, string str = string{"Mike"}. So, in here, str = variable, which is Lval, string{"Mike"} = object which is Rval and certainly points to some address, but no one really needs to know. I hope I am clear. Anyways Mike, you are great please keep up.
@MikeShah6 ай бұрын
Hmm, indeed there might be a more clear way to define rvalue -- the definitions in the link below provide a bit more strict definition. I think rvalues indeed have some location, but you cannot realistically take the address of (with &) of these values so that's the main idea :) learn.microsoft.com/en-us/cpp/cpp/lvalues-and-rvalues-visual-cpp?view=msvc-170
@mohsenzare25118 ай бұрын
I saw this video a while ago, and know I come back to watch that again! thank for your great video!
@MikeShah8 ай бұрын
Cheers! You are most welcome!
@mytech6779 Жыл бұрын
Very clean, as a hobbiest I've been struggling with this for years. At first I was thinking Local and Reference because the contexts where I fiest heard the term was talking about passing function arguments and scope. Then Left and Right [but no, I thought, it couldn't really be that simple, sometimes an L seems to be on the right or they are standing alone], and the formal technical definitions are rather cumbersome parse. But this video clears up a lot, and your example also made me realize they could be thought of as Location/Locateable [ "Loadable" from memory?] and Register because the rvalues live in the cpu registers (Ignoring some details like instruction immediates and i/o reads which live elsewhere, though the registers still generally act as their gate keeper.), eg `(A+B)`, A nd B may be loadable from memory but the sum only exists in a register prior to assignment.
@MikeShah Жыл бұрын
Cheers, glad to hear this helped!
@stupidteous3 ай бұрын
hobbyist*
@mytech67793 ай бұрын
@@stupidteous male-donkey*
@Quancept Жыл бұрын
damn! just like that I understood l-values and r-values. I don't know how to thank you enough Mike :)
@MikeShah Жыл бұрын
Cheers, happy to help!
@robertstrickland97222 жыл бұрын
I really enjoyed this explanation, even more than reading about it in the C++ Crash Course by No Starch Press. Good job.
@MikeShah2 жыл бұрын
Thank you for the kind words!
@muhammedusman726911 ай бұрын
all videos are great and excellent. Thanks
@MikeShah11 ай бұрын
Cheers!
@piotrlezanski515610 ай бұрын
You are great! Thanks
@MikeShah10 ай бұрын
Thank you for the kind words 🙏
@FadiEID-s3g4 ай бұрын
42. There is something to that number. Perhaps the piscine?
@MikeShah4 ай бұрын
From Douglas Adam's book -- Hitchhiker's Guide to the Galaxy :)
@lucasnicosia35363 ай бұрын
Il a pas la ref dans la ref 😅
@MindHaunter3 ай бұрын
Between `std::string s3 = s1+s2;` and `std::string&& s3 = s1+s2;`, the latter is indeed slower (for s2 around 4000 characters), especially with -O3 or -O2 optimization. I am sure there are use cases for rvalue ref (and you will teach us in the next videos), but this simple example is probably not one of them. As always, thank you for detailed explanations. Coming from python and R, I cannot imagine how terribly it'd have been if I just wanted to follow cppref or learncpp.
@MikeShah3 ай бұрын
Cheers! I'll need to think about what exactly is going on when we do std::string&& s3 = s1+s2. To me we're doing all of the construction, and then we move s1 and s2 (or otherwise extend their lifetime). We'll have to be careful otherwise as we can pass s3 into a function only once. I'll talk about this in a future video when I also cover things like perfect forwarding :)
@TheIntervurt2 жыл бұрын
Did you mean to say copy assignment operator at 24:22 ? Thank you for these videos, you take the time to present several examples and explain what is going on behind the scenes which I think is often overlooked in many resources teaching C++
@MikeShah2 жыл бұрын
I meant to say copy constructor. Copy constructor is called when the object is first being initialized from a previously created object. Looks like I mixed my words a bit. :)
@muhammadharris44702 жыл бұрын
Thanks mike for teaching this super important topic for extreme simplicity. really love your teaching style 👍
@MikeShah2 жыл бұрын
Cheers thank you for the kind words!
@IsaacC206 ай бұрын
@28:44 How do you use declspec to check value category of expressions?
@MikeShah6 ай бұрын
There's a trick you can use with templates to get the decltype of a type. See stackoverflow.com/questions/16637945/empirically-determine-value-category-of-c11-expression
@guilherme50943 ай бұрын
👍Thanks again!
@dhanushs18022 жыл бұрын
Very well explained as always. Thank you.
@MikeShah2 жыл бұрын
Cheers thank you for the kind words!
@muhammedhasankayapnar9495 Жыл бұрын
Hi Mike, thank you for this wonderful lecture. As far as I understand, rightvalue references can be used for large data processing for the purpose of preventing stackoverflow. How do we see the s3? since rvalue_references do not have any addresses/memory location ? Is that magic :) ?
@MikeShah Жыл бұрын
Thank you for the kind words. Can you provide a timestamp for the example?
@visitor_t-w3p Жыл бұрын
Thank you so much I enjoyed a lot
@MikeShah Жыл бұрын
Cheers!
@kamilziemian99511 ай бұрын
Very nice video.
@MikeShah11 ай бұрын
Cheers!
@MrTNVolsFan Жыл бұрын
I get the error: error C2440: 'initializing': cannot convert from 'std::basic_string' to 'std::string &&'
@blaisofotso34392 жыл бұрын
I forgot to thank you for your hard work and sharing your knowledge. Do you have a roadmap to advise for one who wnat to be c++ developper in the embedded system and game developpment. i have been scoring the internet looking for books which teach c++ with under the hood concepts and explanations. Please advise for books. Yours sincerely
@MikeShah2 жыл бұрын
You are most welcome! I'd recommend "C++ for game programmers" second edition, "C++ API Design" , then any "Building games in C++" style book. Then follow up with Jason Gregory's "Game Engine Architecture" after you have built a few small games. "Computer Systems a programmers perspective" also is a book of high value. That's a good starting list, perhaps I'll do a video on some book recommendations :)
@blaisofotso34392 жыл бұрын
@@MikeShah Thank you Mike for your advise. I was asking about books which can teach solid background of c++ in general. I loved your tutorials becuase the pictorial explaiations make it relatively easy to follow, so i have been willing to get a book with such details of explanation. Your recommended list mostly focus on game programming which i would like to do as a hobby to apply and learn c++. My study field is mechatronics. Which is why i asked for books in embedded system domain(Robotics, automation). As you said a video would be greatly appreciated.
@MikeShah2 жыл бұрын
@@blaisofotso3439 You are most welcome! I will add the video idea to the wish list, as I have a series of education content I would like to make advising some books I have enjoyed :) Your field of study is a good one!
@blaisofotso34392 жыл бұрын
@@MikeShah Thank you .
@joymakerRC Жыл бұрын
needed this one bro
@joymakerRC Жыл бұрын
i had come across the exact issue earlier this summer when attempting my mode manager class, couldnt figure out why my funtions wouldnt compile to test correctly when i just entered a hard number. I didnt know all this at the time and just assumed i had to create variables all the time for parameters. I had just recent read In "deciphering OOP in C++" when writing a test driver for a class that this can occur.
@MikeShah Жыл бұрын
Cheers
@blaisofotso34392 жыл бұрын
Hallo Mike I have tried adding two integers and assigned the result to an Rvalue reference and it has worked. my question to you is : we never wrote a move assignment operator, is the compiler doing it behind our back?
@MikeShah2 жыл бұрын
For the primitive types, we need not have these implemented for rvalue references (i..e int&& rv_ref = 42;). It' sort of how we never have constructors for 'int' in C++ for example. We'd call 'int' 'long' 'char' etc. trivial types in C++.
@blaisofotso34392 жыл бұрын
@@MikeShah I had that feeling. I was surprised that we perform the move assignement without implementing it. Then i thought that the compiler might have done it as it would when making copy without pointer as data member. In all thank you for your comment about the reason why, it helps with understanding the basics. "There is no rules without exception" . "l exception qui confirme la règle"
@arjunkandaswamy1532 Жыл бұрын
&& was great
@ARANDOMOPENAIUSER Жыл бұрын
24:25
@MrTNVolsFan Жыл бұрын
Concerning the std::string&& s3 = s1+s2, it doesn't work in C++20. Is it deprecated in the modern language?
@MikeShah Жыл бұрын
Not sure--what message are you getting with what compiler?
@VoidloniXaarii Жыл бұрын
Thanks so much
@MikeShah Жыл бұрын
Cheers!
@bobweiram6321 Жыл бұрын
What does the name Shah mean? Does it mean king in Parsi?
@MikeShah Жыл бұрын
Depends on the language, but yes, King is one meaning 🙂
@JamalOmar-p5c20 күн бұрын
Great lessons, shame about all the "go ahead" which is superfluous and irritating. I went ahead and turned it off
@damondouglas2 жыл бұрын
It finally started to click for me at this place kzbin.info/www/bejne/pn6meYqKrK6KpNU
@MikeShah2 жыл бұрын
It's a bit obscure to think of variables as something that stores information and also something with a 'value category' or 'identity' (being lvalue, rvalue, etc.). :)