Re:Don’t blindly prefer emplace_back to push_back
by brown9-2 on Thursday March 04, 2021 @10:47AM
(#26343847)
I agree you should know what you are calling when writing code, but there is also a need for people to read the code and understand what the behavior will be. My impression is that C++ relies a lot on implicit knowledge.
[ Parent
| on HN ]
Re:Don’t blindly prefer emplace_back to push_back
by vlovich123 on Thursday March 04, 2021 @11:23AM
(#26344364)
All languages do.
Re:Don’t blindly prefer emplace_back to push_back
by Yoric on Thursday March 04, 2021 @02:14PM
(#26346791)
Well, many languages try to keep this minimal.
C++ doesn't.
Re:Don’t blindly prefer emplace_back to push_back
by ziml77 on Thursday March 04, 2021 @04:49PM
(#26348894)
And it's nothing new with move/copy semantics either. Even passing by reference is bad for hiding that. Every time I write C++ I'm tempted to take pointers as parameters in places where you'd normally take a reference just so the call site has an indication of what I'm doing.