安装 std 命名空间的源代码以了解实现(Linux GCC)

Install source code of std namespace to understand the implementation (Linux GCC)

我想了解std::runtime_errorclass的内部实现。

c++ vector source code的回答说明我平时只能浏览"interface spec"(h文件),但为什么没有一个实现。

我在 Ubuntu 18.04 上使用 Qt Creator,gcc/g++ 作为编译器

如何安装std的源代码(最好是Qt Creator在我"follow the symbol under the cursor"时可以直接导航到源代码的方式?

libstdc++ (GNU) 的源代码,请看这里:https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3.

std::runtime_error的源代码:class and member functions.

libc++的源代码(通常与 Clang 一起使用):https://github.com/llvm-mirror/libcxx.

据我所知,Microsoft 实现 无法在线获得,但如果您安装 MSVC (Visual C++),则可以找到这些文件。


更新

对于 Microsoft 实现,您可以使用在线编译器来探索源代码(尽管这对用户来说有点不友好)。看,例如https://rextester.com/NRP17506.