开发者

Why some libraries must implement basic data structure? [closed]

开发者 https://www.devze.com 2022-12-22 16:41 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing
Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 7 years ago.

开发者_JS百科 Improve this question

Some open source libraries have tendency to re implement basic structures like string, list, stack, queue... Why don't they use stl library? Is stl not good enough?


C++ as a language existed for many years before the STL was standardized and for several more years before the STL was implemented consistently across all compilers. Libraries that were originally written during that time may not have wanted to rely on the STL in order to be more portable.

Another reason related to portability is embedded use. Qt, for example, re-implements most of the STL because Qt applications are sometimes targeted at embedded platforms (e.g. Nokia smartphones) which may not have an STL implementation available.


Exposing STL types in headers can, in some cases, lead to nasty, nasty link times. On large projects, that can be sufficient reason to "hide" them behind a proprietary-looking API.


STL implementation differ on every platform, so exposing STL in library will have risk, for example if you expose std::map on your library, since you can not export std::map from your library, your library will be forced to use std::map implementation from your library users (the one that load your lib), this will cause some incompatibility such as different version of STL implementation, different STL allocator class, and some platform specific issues.


  1. One of the reasons may be that STL containers are not intended to be used as base classes - STL design issues Wikipedia

  2. To STL or NOT STL that is the question - SO

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号