[patch] Remove invalid test on non-const empty strings
Jonathan Wakely
cow@compsoc.man.ac.uk
Fri Jan 21 10:41:00 GMT 2005
On Thu, Jan 20, 2005 at 08:15:32PM +0000, Chris Jefferson wrote:
> Out of curiosity I tried running the libstdc++ debug library against the
> libstdc++ test suite. A few tests failed, and I intend to look through
> and try to fix them up, once I decide the nicest way to do it.
[snip]
> On a related note, there are a bunch of tests to check that the
> specialisations of swap work. These don't appear to work on the
I reported these as http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16021
> debugging library, and also make me nervous as they are adding overloads
> of member functions of elements of std. It seems their purpose is to
> check that the O(1) swap is being called. Wouldn't therefore something like:
>
> #include<vector>
> #include<algorithm>
>
> int swaps;
> struct T
> {
> T() {}
> T(T& t) { ++swaps;}
> };
>
> int main(void)
> {
> swaps=0;
> vector<T> a(10);
> vector<T> b(10);
> std::swap(a,b);
> VERIFY(swaps==0);
> }
>
> Test the same thing, and not require adding overloads?
They're specialisations, not overloads, so are absolutely fine. It's
legal to add specialisation to namespace std for stdlib components
with user-defined types as template arguments. The point is to test
that std::swap<std::deque<T> >() calls std::deque<T>::swap(), which I
don't think your code above does - it assumes that the default
specialisation of std::swap() will cause copies of the elements, but
it's possible it could be implemented purely in terms of assigments
(however unlikely that may be).
jon
--
"More computing sins are committed in the name of efficiency
(without necessarily achieving it) than for any other single reason
- including blind stupidity."
- W.A. Wulf
More information about the Libstdc++
mailing list