views:

160

answers:

4

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?

+4  A: 

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.

kyoryu
It's even worse for boost... heck, I just had to add a hack to our build system at work to skip the boost headers when compiling `ctags` information, because it flat out ran out of memory.
Tom
@Tom +1 - boost is heavy and unbearable. I sometimes prefer STLPort instead: http://www.stlport.org/
vprajan
+10  A: 

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.

Tyler McHenry
Yup. He who does not know his history will always be baffled by the present. Always.
dmckee
Isn't the STL portable? Couldn't you just download the STL headers to an embedded system and compile as easily as installing Qt sources?
Inverse
A big no.. some STL features like IO, Allocators requires porting or retargeting and moreover QT cannot depend on compilers or external libs for STL's. Having own STL rewrite also helps optimization and easy movement of code. NOTE: STL changes when C++ standard changes.
vprajan
+4  A: 

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.

uray
A: 
  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

TheMachineCharmer