C++ source code

where we can see the source code of c++ basic functions like sort, set, multiset?
(already googled, couldn’t find)

1 Like

Go through this link.

2 Likes

If you’re using mingw, this might be useful. You’ll find the directory structure in the links. All you have to do is fish out the function definitions in the appropriate header files. :slightly_smiling_face:

3 Likes

Here is the git repo for libc++ - a modern-ish implementation of the C++ Standard Library.

Many of the things are very heavily optimised and correspondingly hard to read - for example, here is the guts of std::sort:

This seems to the be the corresponding libstdc++ (gcc’s implementation of the C++ Standard Library) version:

2 Likes

Install VSCode and you can view the source code of any function by using ctrl + click on the function name.

1 Like