6 ms·
That's interesting, I always thought of STL as a well-designed piece of library. Or is it just not specialised enough to fit your case?
by pestaa 14y ago
That's interesting, I always thought of STL as a well-designed piece of library. Or is it just not specialised enough to fit your case?
- bronxbomber92 14y agoI cannot speak to jandrewrogers specific reason, but the two major sticking points I've seen developers hit is the STL's bad allocator design and the lack of intrusive data structures. Check out EASTL for more information [1][2]. [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n227... [2] https://github.com/paulhodge/EASTL https://github.com/paulhodge/EASTL
- jandrewrogers 14y agoSTL is good for what it is. The limitation is that there is little ability to specify behaviors, use cases, data distributions, workload profiles, etc because that would effectively break the abstraction and expose the internals. However, STL still requires an implementation and so the implementors select algorithms that will give adequate performance across a wide range of scenarios but which are usually significantly suboptimal for any specific scenario. Consequently, a custom implementation tuned for a specific scenario will often handily out-perform the STL implementation. For the kinds of applications I work on, poor-fitting STL implementations are frequently major bottlenecks in the profiler. It is plausible to add an enormous number of implementations and data structures to STL that would allow someone to select/construct the perfect data structure for a particular use case. However, that would also add a level of complexity to the STL that probably is not worth the benefit for many users.
- ExpiredLink 14y ago> The limitation is that there is little ability to specify behaviors, use cases, data distributions, workload profiles, etc because that would effectively break the abstraction and expose the internals. STL's limitation is its design. That's the real reason why STL acceptance is low (for a Standard library), not the often cited compatibility issues.
- zvrba 14y ago> STL's limitation is its design. Care to elaborate more on this?
- br1 14y agoCan you give a concrete example of a refactoring you had to do?
- ExpiredLink 14y agoSTL 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]