MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
Cuz it won't cause undefined behavior
olli
Cuz it won't cause undefined behavior
provide a full example please
MᏫᎻᎯᎷᎷᎬᎠ
I think it must return a const lvalue in case of returning lvalue reference
olli
I think it must return a const lvalue in case of returning lvalue reference
please provide a full comileable example. A const value will change nothing here.
MᏫᎻᎯᎷᎷᎬᎠ
But the rvalue will be destroyed anyway
MᏫᎻᎯᎷᎷᎬᎠ
Silvestr
none
std::string func() { std::string name{"qwerty"}; return name; } std::string result = func() - here copy constructor std::string&& result = func() - here nothing?
olli
std::string func() { std::string name{"qwerty"}; return name; } std::string result = func() - here copy constructor std::string&& result = func() - here nothing?
the second one will not trigger an constructor or assignment operator call. This is basically like std::string * ptr = &otherString;. Which operator/constructor should be called?
olli
std::string func() { std::string name{"qwerty"}; return name; } std::string result = func() - here copy constructor std::string&& result = func() - here nothing?
For the first thing there are basically multiple options and multiple things to consider. Compiler nowadays are likely to neither copy assign nor copy construct. Changes to C++17 regarding RVO also make it likely the compiler is trying to avoid any "unecessary" object instantiation.
Silvestr
None
olli
But if I disable all optimization? It will call copy constructor?
Even without I am unaware of any compiler that calls the copy ctor here
olli
Thank you for explaining)
sure. You can read more about RVO/NRVO/Copy Ellision here https://en.cppreference.com/w/cpp/language/copy_elision
Sai
Hey which app is best for learning html
Sai
I didn't understand
Anonymous
Hi
Anonymous
Hi Sahil
S.
yo
Ariana
XD
Ritwik
Can anyone help me
Ritwik
Actually I am a beginner in C
Anonymous
/notes
14•08
Actually I am a beginner in C
Give us you're quiz if you fail to compile
Liam
#callingfunction
Liam
lol, that's funny.
Elnee
Really cool gif
Liam
#noendl
14•08
😂😂 its just like array
S.
Hmmm when you’ve already understood the concept, you understand the gif … but when you have not, you’d still have the wtf face
MᏫᎻᎯᎷᎷᎬᎠ
Ritwik
Why this?
14•08
Elnee
¯\_(ツ)_/¯
Mat
Why this?
Are you asking us?
Liam
Why this?
#howtoask
Mat
Yes
Conio.h :/
S.
And you showed us no code
Liam
Sorry, but I see no connection from your code to what the gif conveyed.
Elnee
How is it related to passing values by reference?
S.
😑 totally confused
S.
But the fact is, it doesn’t
Elnee
K
S.
😅
Liam
interesting...
Mat
Why this?
Did you die?
S.
too many topics mixed here (
Ritwik
Did you die?
Actually I can't understand yet that why it can't run
Ritwik
Means
Liam
Well, you need to learn how to ask good questions before learning C/C++.
S.
Means
If you don’t show any code, how can we help?
14•08
too many topics mixed here (
😂😂 lol you just act like bot you will recognize everything...
14•08
Yo eat ,drink ,sleep and code nightmare 😂😂 Mr bot
Mat
Avoid the possibility of including multiple time the same header
Anonymous
Thanks
Liam
Suppose that there is a herder named foo.h, and you include it in bar.cc. bar.cc also include baz.h which in turn is return ed by foo.h. So, bar.cc includes baz.h for twice (1 explicit and 1 implicit).
Liam
If you define something in baz.h, it'll be defined twice in bar.cc's point of view. And without guards, compiler will report errors.
Anonymous
Am a beginner in c++ and am confused about "using namespace std;" how do I differentiate when to use it
Dima
lol
Hakker
i need to submit before 1 pm plz anyone send