swap broken

Rob Willis rob@e-critical.com
Wed Feb 21 14:19:00 GMT 2001


I just updated to the gcc-20010205 snapshot (from a very old snapshot). 
The line in swap:

_STL_REQUIRES( _Tp, _Assignable );

breaks alot of old code.  Basically, in most of my operator= statements,
i have the following code:

SomeClass
{
public:
  ...
private:
  struct State;
  std::auto_ptr<State> _state;
};


SomeClass& SomeClass::operator=(const SomeClass& object )
{
  SomeClass temp)( object );
  std::swap( _state, temp._state ); // _state is auto_ptr
  return *this;
}

Which is recommended in a dozen books to be exception safe assignment
semantics.  When i compile, i'm getting the following type of message on
the swap line:

_STL_ERROR::__const_parameter_required_for_assignment_operator(...)  and
so on.

And of course, the auto_ptr assignment operator DOES NOT take a const
parameter, which is why this error is being generated.

So....  is my code now incorrect?  Is there a way to work around this??  

Is it a bug?
-Rob

PS  Please copy me on responses and not just mail the newsgroup.  
Thanks.

-- 
Rob Willis
rob@e-critical.com



More information about the Libstdc++ mailing list