Boost logo

Boost :

Subject: Re: [boost] [move] Library uploaded to sandbox
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-02-21 06:07:54


----- Original Message -----
From: "Ion Gaztañaga" <igaztanaga_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, February 17, 2009 11:00 PM
Subject: [boost] [move] Library uploaded to sandbox

>
> Hi to all,
>
> I've uploaded a new version of the move emulation library to sandbox.
> I've put it temporarily in "move_semantics" folder to avoid overwriting
> current move code.
<snip>
> I've personally added to the library all that I've seen useful for
> move-aware containers, so it might lack some features (move aware
> algorithms, for example).

Hi,

I was wondering if we can define a implicit conversion from rv<Derived>& to rv<Base>& if is_convertible<Derived,Base>

   template <typename U>
   typename enable_if<move_detail::is_convertible<T,U>, rv<U>&>::type
   convert_to() {
       return (static_cast<rv<U>& >(static_cast<U&>(*this)));
   }
   template <typename U>
   operator rv<U>&() {
       convert_to<U>();
   }

With this implicit conversion the

   Derived(BOOST_RV_REF(Derived) x) // Move ctor
      : Base(boost::move(static_cast<Base&>(x))),
        mem_(boost::move(x.mem_)) { }

could be

   Derived(BOOST_RV_REF(Derived) x) // Move ctor
      : Base(x),
        mem_(boost::move(x.mem_)) { }

What do you think?
Vicente


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