libstdc++ of g++ 3.4.x: std::swap and std::auto_ptr causes compilation errors

Paolo Carlini
Tue Nov 16 09:46:00 GMT 2004

Vinzenz Feenstra wrote:

> std::swap of 3.4
>  template<typename _Tp>
>    inline void
>    swap(_Tp& __a, _Tp& __b)
>    {
>      // concept requirements
>      __glibcpp_function_requires(_SGIAssignableConcept<_Tp>)
>          const _Tp __tmp = __a; // <-- this is the problem in my opinion
>      __a = __b;
>      __b = __tmp;
>    }

Yes, you are right that this is the ""problem"", in the sense that, being
auto_ptr not Assignable, later, in __b = __tmp, its assignment operator
wants a *non* constant reference. We (I) could revert the change which
const-ified, correctly, the temporary, but the fundamental problem of
your testcase would remain the same: try compiling it passing,


on 3.4 or


on 3.3 (this actually enables the concept check encoded in the
__glibcpp_function_requires line)


More information about the Libstdc++ mailing list