|
Boost Users : |
Subject: Re: [Boost-users] Serializing containers of movable but noncopyabletypes
From: Daniel Mitchell (dlm.bulk.messages_at_[hidden])
Date: 2013-07-02 12:13:37
On Jul 1, 2013, at 11:21 AM, "Robert Ramey" <ramey_at_[hidden]> wrote:
> Daniel Mitchell wrote:
>> While attempting to serialize a std::vector<T>, where T is a movable
>> but noncopyable type, I was getting blown up by the call to
>> s.push_back() on line 65 of collections_load_imp.hpp (Boost 1.53.0).
>>
>> In my local copy of that header I changed s.push_back(t.reference())
>> to s.push_back(std::move(t.reference())). Is this a safe change? Is
>> there a better way to handle this case?
>
> Hmmm -
>
> When I look at the type requirements for the vector class:
>
> http://www.sgi.com/tech/stl/Vector.html
> http://www.sgi.com/tech/stl/Sequence.html
> http://www.sgi.com/tech/stl/Container.html
> http://www.sgi.com/tech/stl/Assignable.html
>
> I see that items in vectors must be assignable and that assignable means
> "copyable".
>
> I realize that this information might now be out of date, but since I use
> the
> weakest common denominator of type requirements to diminish portability
> problems, that's what I use.
>
> I'm sure someone might have something more useful to add here.
>
> Robert Ramey
I've found that I can work around this by using array optimization on my vectors.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net