4 ms·
STL uses 'value semantics'. Just use push_back in a loop and observe how often the whole data in std::vector is copied. Not to mention std::sort.
by ExpiredLink 14y ago
STL uses 'value semantics'. Just use push_back in a loop and observe how often the whole data in std::vector is copied. Not to mention std::sort.
- cokernel_hacker 14y agovector::emplace_back ameliorates by allowing new elements to be constructed in-place [1] [1] http://en.cppreference.com/w/cpp/container/vector/emplace_back http://en.cppreference.com/w/cpp/container/vector/emplace_ba...
- Sharlin 14y agoValue semantics are the only sensible default in a language like C++. If you need reference semantics, store (smart) pointers explicitly.
- deleted 14y ago[deleted]