Where can I find the implementation for std::string

一个人想着一个人 提交于 2019-12-01 03:47:46

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".

mtb

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!