Memory, Allocator<T> & __USE_MALLOC & alternatives

Phil Edwards phil@jaj.com
Tue Jun 11 17:02:00 GMT 2002


On Wed, Jun 12, 2002 at 11:38:57AM +1200, Tony Bryant wrote:
>
> First, thanks to Phil and everyone else for their suggestions.
> 
> > typedef std::basic_string<char, char_traits<char>, allocator<char> > 
> > MyString;
> >
> > in your code, use MyString everywhere, and then go back and tweak the
> > third parameter as necessary.
> 
> OK, that seems workable, but is this basic_string ISO standard C++? 

Absolutely.  Anything you see in std:: that doesn't start with _ should
be ISO standard, unless we've screwed up or overlooked something.


> There's a distinct lack of ISO standards documentation for the std C++ 
> libraries floating around the net - anybody got a handy URL? - so I can find 
> out what I functionality I can rely on?

The source documentation linked from

    http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html

is quite incomplete but growing.  (string is missing)

The old SGI STL site linked to from the FAQ still has all their docs.


> > std::priority_queue takes a (default) parameter specifying the underlying
> > container; it doesn't handle the memory itself.  The underlying container,
> > say, vector, takes an allocator parameter.
> 
> Sorry my mistake, I'm getting my issues confused here, I tried this a while 
> ago and found that std::priority_queue can be convinced to use a non-standard 
> allocator, but because it lacked a constructor capable of taking a instance 
> of that allocator, it could not be used with non-static (i.e. instanced) 
> allocators. 

Looks like the closest thing to this is passing an instance of the container,
which itself can take an instance of the allocator.  (That's an annoying way
to have to do it, though.)

Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams



More information about the Libstdc++ mailing list