[英]Standard C++ libraries headers on gnu gcc site
I want to browse the source code of gnu implementation of C++ standard libraries -- header files as well as the implementation. 我想浏览C ++标准库的gnu实现的源代码-头文件以及实现。 I have landed myself into: 我已经进入:
http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.4/index.html http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.4/index.html
My first step was to look header file at: 我的第一步是查看头文件:
http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.4/a01376.html http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.4/a01376.html
My question is that as per my understanding the typedeffed string sth like: typedef basic_string string; 我的问题是,根据我的理解,像这样的typedeffed字符串:typedef basic_string string; should have been present in string header, but I don't see one here. 应该已经出现在字符串标题中,但是我在这里没有看到。
Questions: --in which file is the definition of string symbol? 问题:-字符串符号的定义在哪个文件中? --I see that string header file includes lot many headers and if the typedeffed sring symbol is defined in one of these internal headers, is there a search bar something on this site thru which I can reach to the definition of a symbol straightway. -我看到字符串头文件包含很多头文件,并且如果在这些内部头文件之一中定义了typedeffed sring符号,则该站点上是否存在搜索栏,我可以直接找到符号的定义。 (in case someone has already browsed stuff from this site before) (以防以前有人浏览过此网站上的内容)
Thanks, Jagrati 谢谢,Jagrati
A lot of libstdc++ is implemented using only headers, but some parts of the STL, like std::basic_string
, have compiled implementations. 许多libstdc ++仅使用标头实现,但STL的某些部分(如std::basic_string
)已编译实现。
The declaration of template std::basic_string
is located in /usr/include/c++/4.4.4/bits/basic_string.h
(replace '4.4.4' with g++ -dumpversion
) and the implementation is in /usr/include/c++/4.4.4/bits/basic_string.tcc
. 模板的声明std::basic_string
位于/usr/include/c++/4.4.4/bits/basic_string.h
(与替换“4.4.4” g++ -dumpversion
)和实施是在/usr/include/c++/4.4.4/bits/basic_string.tcc
。 The actual typedef
of std::string
, std::wstring
, etc. is in .../bits/stringfwd.h
. std::string
, std::wstring
等的实际typedef
在.../bits/stringfwd.h
。 If you needed to instantiate std::basic_string
with other template parameters, for example, then you do something like: 例如,如果需要使用其他模板参数实例化std::basic_string
,则可以执行以下操作:
#include <bits/basic_string.tcc>
template class std::basic_string<long>;
The way that libstdc++ implements sets and maps (header-only) is kind of interesting, but also very complex because it uses a custom red-black tree implementation ( _Rb_tree
). libstdc ++实现集和映射(仅标头)的方式很有趣,但也非常复杂,因为它使用自定义的红黑树实现( _Rb_tree
)。
The libstdc++ implementation of std::vector
(also header-only) is more self-contained, so it's worth a glance in /usr/include/c++/4.4.4/bits/stl_vector.h
to give you an idea of the internals of libstdc++. std::vector
的libstdc ++实现(也是仅标头)更加独立,因此值得一看/usr/include/c++/4.4.4/bits/stl_vector.h
,以了解内部原理libstdc ++。 Another interesting file is .../bits/stl_algo.h
, which contains the definitions of STL algorithms. 另一个有趣的文件是.../bits/stl_algo.h
,其中包含STL算法的定义。
Note: On Windows with MinGW, you'll find the libstdc++ headers in lib\\gcc\\mingw32\\4.4.0\\include\\c++\\bits
of your MinGW installation, replacing '4.4.0' with g++ -dumpversion
. 注意:在具有MinGW的Windows上,您将在MinGW安装的lib\\gcc\\mingw32\\4.4.0\\include\\c++\\bits
中找到libstdc ++标头,并用g++ -dumpversion
替换'4.4.0'。
You can find what you need directly in /usr/include/c++
: since the standard tag library is composed by templates, most of the code it's placed directly in header files. 您可以直接在/usr/include/c++
找到所需的内容:由于标准标记库是由模板组成的,因此大部分代码都直接放置在头文件中。
Also I tried to read them once, but trust me: you don't want to do it. 我也曾经尝试阅读它们一次,但请相信我:您不想这样做。 :) Seriously, it's a bit messy. :)严重的是,这有点混乱。
A quick grep told me that typedef basic_string<char> string
is in bits/stringfwd.h
. 一个简短的grep告诉我typedef basic_string<char> string
在bits/stringfwd.h
。 I'm using gcc 4.5.0
. 我正在使用gcc 4.5.0
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.