src/stlinst.cc and relationship to the SGI STL

Benjamin Kosnik bkoz@cygnus.com
Thu Dec 30 07:30:00 GMT 1999


> I wonder if any of you can help me. I'm trying to understand the
> relationship between the file src/stlinst.cc and the SGI standard template
> library. As I understand it the SGI STL is intended to only be a set of
> header files... but this file seems to be a dependency on the implementation
> of the SGI STL and if you dont include it as part of the standard library
> then programs using the STL wont link.

It's an explicit instantiation file, and is one way of controlling what
template instantiations are produced.

> In my particular case if you compare the older version of the STL that comes
> with egcs1.1.1 then you find that they've declared (or renamed) a different
> set of static data members in __default_alloc_template. Code built against
> the newer STL doesnt link with older libstdc++.

Binary compatibility should not be assumed amongst different releases
of the STL.

> I cant find a reference to "default_alloc" anywhere in the standard (I only
> have the draft 2 version) nor was I expecting to. This does seem to be some
> form of "collusion" between the SGI STL and libstdc++ which I wasnt
> expecting.

In general, any name with a prepended "__" or a "_" followed by a capital
letter is reserved for implementors. Thus, you can rightly assume that
"__default_alloc_template" is a detail of this specific implemtation.

stl/bits/stl_alloc.h says:

"// Default node allocator.
// With a reasonable compiler, this should be roughly as fast as the
// original STL class-specific allocators, but with less fragmentation.
// Default_alloc_template parameters are experimental and MAY
// DISAPPEAR in the future."


That pretty much sums it up.

-Benjamin



More information about the Libstdc++ mailing list