[Bug libstdc++/52442] temporary_buffer does not swap
giecrilj at stegny dot 2a.pl
gcc-bugzilla@gcc.gnu.org
Wed Feb 29 23:25:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52442
--- Comment #3 from Christopher Yeleighton <giecrilj at stegny dot 2a.pl> 2012-02-29 23:25:19 UTC ---
(In reply to comment #1)
> You're right, it can't be used like that, but it's not meant to be.
>
> By design temporary_buffer is not copyable, so it's not swappable either.
Here is my shoot, feel free to criticise. Not copyable but swappable.
template < class P_T >
class temporary_buffer: protected ::std ::pair < P_T *, ::std ::ptrdiff_t >
{
public: typedef P_T item_type;
public: typedef class temporary_buffer < item_type > itself, &ref; typedef
itself const &cref;
public: typedef class ::std ::pair < item_type *, ::std ::ptrdiff_t >
inherited;
public: typedef typename inherited ::second_type size_type;
public:
temporary_buffer (::std ::ptrdiff_t const &p_s = 01)
: inherited (::std ::get_temporary_buffer < item_type >(p_s)) {}
private: temporary_buffer (cref); ref operator = (cref);
public: ~temporary_buffer () { ::std ::return_temporary_buffer (inherited
::first); }
public: size_type const &size () const { return inherited ::second; }
public: item_type *const &buffer () const { return inherited ::first; }
public: ref clear () { inherited ::second = size_type (); return *this; }
protected: inherited &base () { return *this; }
protected: inherited const &base () const { return *this; }
public: void swap (ref that) { ::std ::swap (base (), that .base ()); }};
More information about the Gcc-bugs
mailing list