This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Remove invalid test on non-const empty strings

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.
> 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

> 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).


"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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]