Topic: Clearing adaptors
Author: "Neil Butterworth" <neil_butterworth@lineone.net>
Date: Sat, 2 Jun 2001 23:28:36 GMT Raw View
I originally posted this in comp.lang.c++ (and latterly in
comp.lang.c++.moderated) but got almost no response. Now trying here.
<question>
Earlier on today Stuart Golodetz posted here a question regarding clearing
an STL priority queue. My first mental response was "Well, just call
clear!" but a quick flick through Josuttis told me that
std::priority_queue, and the rest of the collection adaptors (stack et al)
don't support this method.
A couple of people then posted as solutions my next idea - assign an empty
adaptor object to the one you are trying to clear. Obviously, this will work
but ... why don't stack, priority_queue et al. support a clear() method? Why
should not _all_ STL collections support the same "remove everything"
method? I can see no obvious reasons - your thoughts?
</question>
NeilB
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]