开发者

How do I know which STL string implementation I'm using?

Item 15 of Effective STL says that there are at least 6 different implementations of std::string. But if I have to be aware of which implementation I'm using, how do 开发者_StackOverflow中文版I find out which implementation I'm using? std::string of gcc does not show the source code (it's all in the .so file), so how do I find out? Couldn't find anything here, so if in future I need to look up such info, where could I search?


Look at the <string> header and watch the copyright? I'll add that, from what I know, std::string is a typedef of basic_string<>, so of a template class. Now, from what I remember, only Comeau C++ supports "export" templates, so all other compilers need to have template classes defined AND implemented in header files. You are using GCC so probably in the <string> header you'll find a big piece of the string implementation. (I'll add that it's a common trick to make a template "shim"/"proxy" that calls non-templated classes to minimize the compilation size, so not all the implementation truly needs to be in the header file and that, for the specific case of the std::string many methods COULD be defined on top of the C "string" library (but probably won't because std::string considers null as a valid character)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜