Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to download C++ STLsource code both .h and .cpp files?

Tags:

c++

stl

I downloaded the STL source code from http://www.sgi.com/tech/stl/download.html , but it only has the .h for the function declaration. Where can I download the .cpp files to read the actual implementation?

For example, in the stl_multimap.h or in stl_map.h, it has:

template <class _Key, class _Tp, class _Compare, class _Alloc>
inline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x, 
                 multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
  __x.swap(__y);
}

I want to know the actual implementation of the swap as in

__x.swap(__y);

I don't see where the actual code for swap is. In here, it just calls itself.

like image 847
Amumu Avatar asked May 11 '11 05:05

Amumu


1 Answers

The .h files contains the implementations. Many of the headers on that page are just wrappers around other headers or provide typedefs, but if you look at a file like stl_set.h, you will see that it has all the definitions of functions for the set class.

Even the page itself states that it is a header-only library, which means that the implementations are included in the headers.

like image 188
逆さま Avatar answered Sep 21 '22 12:09

逆さま