MᏫᎻᎯᎷᎷᎬᎠ
2nd edition
Harsh
MᏫᎻᎯᎷᎷᎬᎠ
It's from the inventor of the language
MᏫᎻᎯᎷᎷᎬᎠ
Ludovic 'Archivist'
You require to have quite a few mental issues to write C++
Dima
Would early return/guard prevent rvo? I am curious about this one
Anonymous
Dima
Yes
Anonymous
I didn’t get you
olli
Ludovic 'Archivist'
Anonymous
Ludovic 'Archivist'
Which is why [[no_discard]] is your friend
Ludovic 'Archivist'
Ludovic 'Archivist'
Ludovic 'Archivist'
Specifically thread local ones, static ones, and those initialized by _start
Anonymous
where to read?
Ludovic 'Archivist'
Anonymous
?
Ludovic 'Archivist'
Ajay here
I could add to that that it means they are not freed at the end of the function
Nick
😅😅 Of course not. It shouldn't be allowed. But a clean, croped screenshots should allowed i think.
Anonymous
If we create a copy constructor in a class, does the compiler creates a default constructor for the class?
Anonymous
I read this:
When not to use return by address:
1. When returning variables that were declared inside the function or parameters that were passed by value (use return by value)
2. When returning a large struct or class that was passed by reference (use return by reference)
Kindly explain the reason for the second point.
Anonymous
so you don't have to use the address-of (&) operator on the reference you were passed.
Anonymous
It's much safer to just return the reference you were passed.
Dima
and it will not be copied
Anonymous
I don't think there are many reasons at all to return by address in C++.
Dima
there are
Dima
fuck pure functions and functional stuff
Dima
Anonymous
well, one that comes to my mind would be low-level memory management
Anonymous
^lol
Dima
I think it’s okay to return by address if there can be none lol
Dima
returning by a reference fields that are not on a heap
Pavel
What "return by address" means?
Return by raw pointer?
Dima
I think so
Dima
I didn’t get it too
Anonymous
yeah, I think so too.
Anonymous
Since a pointer really is just an address
Anonymous
(A C-Pointer that is)
Anonymous
iirc unique_ptr is just an address too.
Anonymous
Not sure now.
Anonymous
*stored as just an address
Anonymous
@unterumarmung you mean something like "void foo(char** out);" ?
Anonymous
so you return a raw pointer via the parameters?
Anonymous
That seems strange.
Anonymous
I mean:
Convert
int func();
To
void func(int* param);
Anonymous
Or
void func(int& param);
Anonymous
ah, I'm not sure he meant that.
Anonymous
I can't guess what he meant
Anonymous
Ah, interesting, TIL.
Anonymous
Thanks!
Anonymous
So 2 pointers in total then?
Anonymous
Why pointers?
Tushar
/get
Dima
you can return a value with rvo supported
Tushar
/rules
Dima
instead of passing as a reference and getting a result
Anonymous
One pointer and one function
Dima
check out the rvo stuff
Anonymous
I'd assume they'd use a pointer to a fucntion.
Anonymous
No
Anonymous
Callable object is not only a pointer to function
Anonymous
Also lambdas and functors — class objects with overloaded operator()
Anonymous
You can provide your custom types for a deleter function
Tushar
/get notes
Tushar
/list
Tushar
/get names
Anonymous
@Dragon_Trainer786, stop spamming
Anonymous
Tushar
I want to study complete c++ so I am trying to get notes through rose
Tushar
Can you help me?
Anonymous