[Development] Question about QCoreApplicationData::*_libpaths
Mathias Hasselmann
mathias at taschenorakel.de
Sun Jan 17 11:31:30 CET 2016
Am 16.01.2016 um 01:29 schrieb Kevin Kofler:
> Now, what *I* find "simply *not acceptable*" is that "a seemingly innocuous
> piece of code like":
> std::vector<Foo> foo1 = …;
> std::vector<Foo> foo2 = foo1; // <- here
> "leads to a memory allocation, nay, a complete deep copy of the container".
> This is particularly problematic when you want to have methods that return
> an STL container, because returning a reference is a bad idea. (Of course
> you can return a pointer, but that opens its own can of worms, plenty of
> ways to shoot yourself in the foot there: the same issues with explicit
> sharing semantics as in Java, plus memory leaks and more.)
Almost was going to confirm this example as most relevant use case for
implicit sharing. Sadly, no luckily actually, modern C++ compilers just
optimize this case. The calling method just keeps the callee's instance
alive and reuses it. No constructors involved. Compilers have been smart
enough to do that for a long time. C++11 sanctified that litle trick.
http://stackoverflow.com/questions/4986673/c11-rvalues-and-move-semantics-confusion-return-statement/4986802#4986802
Still in general I agree that time-to-market usually is much more
important like code purity: We are doing products, not religion.
Ciao,
Mathias
More information about the Development
mailing list