3 ms·
> I would bet most people are unaware of how emplace actually works and for a reviewer it's more cognitive overhead too. If you are doing professional developm
by sumeno 2y ago
> I would bet most people are unaware of how emplace actually works and for a reviewer it's more cognitive overhead too.
If you are doing professional development in C++ you should learn the difference and how to recognize incorrect usages
- the_mitsuhiko 2y agoI'm unconvinced. emplace is inherently more complex and requires a complete understanding of the relevant constructors of the value type in the collection. push_back is much less surprising. I'm not a professional C++ developer, but I'm obviously required to use the language every once in a while and I vastly prefer code that requires me to have to look at fewer implementations of potentially implicit and hidden things.
- TillE 2y agostd::make_unique does the exact same kind of forwarding arguments to a constructor. Yeah it's important to know which constructor you're calling, but that's just a general fact, emplace_back isn't exceptional.