Boost logo

Boost :

Subject: Re: [boost] [serialization] rvalues and const-correctness?
From: David Abrahams (dave_at_[hidden])
Date: 2008-11-09 10:57:36


on Thu Nov 06 2008, David Abrahams <dave-AT-boostpro.com> wrote:

> on Thu Nov 06 2008, "Robert Ramey" <ramey-AT-rrsd.com> wrote:
>
>> Thorsten Ottosen wrote:
>>> Robert Ramey skrev:
>>>> David Abrahams wrote:
>>>
>>>> Couldn't we add this overload to the
>>>>> archives, or even simply replace the existing operator with this
>>>>> one? template<class T>
>>>>> Archive & operator<<(T const & t){
>>>>> // ^^^^^------------- Note
>>>>> this->This()->save_override(t, 0);
>>>>> return * this->This();
>>>>> }
>>>>
>>>> Aaaa - I would have to spend some time to look into that.
>>>
>>> Isn't this the debate we have had so many times?
>>
>> well, we havn't had it lately.
>>
>> But this is actually a little different since this is calling a member
>> function inside serialization. Since save(...) is a const member
>> funtion, the f() would have to be const. if you can't make f() const,
>> you've got something to look into.
>
> The member function wasn't my point at all. I just want to be able to
> save rvalues.

Have you had a chance to look into this? I've been using a patched
version of the library that adds the stated overload and it is working
great. Taking out the patch means that where I ought to have been able
to simply write

   ar << f();

I am forced to write code like this:

   typename nasty_trait_to_compute_return_type<foo>::type x = f();
   ar << x;

Nasty.

Please?

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk