Library source code

May 28, 2012 at 2:18am
Is there a resource that shows the source code for the basic c++ libraries included with most compilers? I know what they do and how to implement them successfully, but I have no clue how they do it. I have searched with google and all I could find is links to DLL crackers. I just want to understand the basic libraries a little better, find out how they do what they do.
May 28, 2012 at 2:26am
The source is already on your machine. when you #include <iostream>, it's actually including a file named iostream. Just search your HD for that file and look at it.

But be warned. The STL source is extremely obfuscated and confusing.
May 28, 2012 at 2:53am
Thanks. You are right. It IS icredibly confusing.
May 28, 2012 at 3:57am
To understand how standard algorithms could be implemented, look at the reference documentation of this site.

For example, std::find() http://www.cplusplus.com/reference/algorithm/find/ has:
The behavior of this function template is equivalent to:
1
2
3
4
5
6
template<class InputIterator, class T>
  InputIterator find ( InputIterator first, InputIterator last, const T& value )
  {
    for ( ;first!=last; first++) if ( *first==value ) break;
    return first;
  }


Take it as indicative and nothing more; no self-respecting C++ programmer would write first++ on a polymorphic first where ++first would have been adequate.
Topic archived. No new replies allowed.