This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
swap broken
- To: libstdc++ at gcc dot gnu dot org, libstdc++-prs at gcc dot gnu dot org
- Subject: swap broken
- From: Rob Willis <rob at e-critical dot com>
- Date: Wed, 21 Feb 2001 14:13:08 -0800
- Organization: eCritical
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