Boost logo

Boost :

Subject: Re: [boost] Boost.Convert. Take 2.
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2014-02-20 21:11:02


On February 20, 2014 5:48:18 PM EST, Vladimir Batov <Vladimir.Batov_at_[hidden]> wrote:
>
>On 02/21/2014 02:47 AM, Andrzej Krzemienski wrote:
>>
>> Regarding "Type Requirements" section in documentation:
>> TypeOut needs to be
>>
>> *Copy Constructible.*
>> Is it not enough to require that TypeOut be *MoveConstructible*?
>>
>
>I readily admit I am shaky about new C++11 stuff... even though it's
>2014 outside... I've not had (cannot afford) any exposure to C++11 as I
>
>am still stuck with C++03... well, at least for 2 more months... which
>in the airline industry is more likely 6-12 months. :-(
>
>Still I suspect some interfaces require to be Copy Constrictible. For
>example,
>
>template<typename TypeOut>
>struct boost::convert<TypeOut>::result
>{
> ...
> template<typename FallbackType>
> out_type value_or(FallbackType const& fallback) const
> {
> return good_ ? value_ : fallback;
> }
>};

This would address your concern:

if (good_)
{
   return std::move(value_);
}
else
{
   return fallback;
}

However, for non-movable types, the fallback is to copy anyway, so both should be moved.

___
Rob

(Sent from my portable computation engine)


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