Why do some libraries need to implement a basic data structure?

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

+4
source share
4 answers

Identifying STL types in headers can in some cases lead to unpleasant, unpleasant link times. In large projects, this may be a good reason to β€œhide” them behind the proprietary API.

+4
source

C ++ as a language exists many years before STL was standardized, and a few years ago STL was consistently implemented in all compilers. Libraries that were originally written during this time might not want to rely on STL to be more portable.

Another reason for portability is inline use. Qt, for example, reimplementes most of the STL, since Qt applications sometimes target embedded platforms (such as Nokia smartphones) that may not have an available STL implementation.

+12
source

STL execution differs on each platform, so publishing an STL to a library will have a risk, for example, if you set std :: map in your library, since you cannot export std :: map from your library, your library will be forced to use the std implementation :: map for users of your library (the one that loads your library), this will lead to some incompatibilities, such as a different version of the STL implementation, a different class of the STL allocator, and some platform-specific problems.

+4
source
0
source

Source: https://habr.com/ru/post/1303632/


All Articles