开发者

Where can I find the implementation for std::string

I am looking for the code for the c++开发者_Python百科 string class. What header is it implemented in?


There is no single implementation for std::string. But you can find your particular implementation in the <string> header.

On my system it can be found here:

/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/g++-v4/bits/basic_string.h and /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/g++-v4/bits/basic_string.tcc

On a Debian-based system:

~$ locate basic_string.tcc
/usr/include/c++/4.5/bits/basic_string.tcc
/usr/include/c++/4.6/bits/basic_string.tcc
~$ locate basic_string.h
/usr/include/c++/4.5/bits/basic_string.h
/usr/include/c++/4.6/bits/basic_string.h
~$ 

Generally, you are going to be looking for the basic_string template, since std::string is just a specialization of that.


As you might expect,

<string>

which will most likely be located in whatever include directory your compiler has as its base.


It's in <string>. It's a header file distributed with your compiler. It may include other (private) header files - a lot of the implementation for Visual Studio is in a file named "xstring".


A similar question with the answer for Visual Studio: https://stackoverflow.com/a/17205896/5520058

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\crt\src\

The version and location of Visual Studio can be changed. This is the default installation path where the sources can be found.

Visual studio versions:

  • 2005 -> 8
  • 2008 -> 9
  • 2010 -> 10
  • 2012 -> 11
  • 2013 -> 12
  • 2015 -> 14
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜