I am looking for the code for the c++ string class. What header is it implemented in?
+5
A:
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
Generally, you are going to be looking for the basic_string
template, since std::string
is just a specialization of that.
Evan Teran
2010-07-03 04:16:31
Thank you. It appears only the prototype of the method I was looking for: find() is in there "size_type find(const _CharT* __s, size_type __pos, size_type __n) const;"
Alan
2010-07-03 14:26:25
ahhh sorry. I've found it in basic_string.tcc. Thanks!
Alan
2010-07-03 14:28:36
A:
As you might expect,
<string>
which will most likely be located in whatever include
directory your compiler has as its base.
Amber
2010-07-03 04:16:38
you are of course right, but keep in mind that (IIRC) `<string>` doesn't actually have to be an actual file. I never seen an implementation where it wasn't though...
Evan Teran
2010-07-03 04:19:54
It isn't a file on VMS; header files are contained in 'text libraries', whatever they are. Why, I've no idea.
Brian Hooper
2010-07-03 08:58:40
A:
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".
Terry Mahaffey
2010-07-03 04:17:23