Boost logo

Boost Users :

Subject: [Boost-users] [move] Move c-tor template
From: Szymon Gatner (szymon.gatner_at_[hidden])
Date: 2012-03-30 11:11:57


Hi,

I am implementing custom smart pointer with move semantics and I am
having problems with implementing move constructor with template
param. In fact clone_ptr presented in docs suffers from that issue
also. This code:

class B {}
class D: public B {}

clone_ptr<D> makeD();

void main()
{
clone_ptr<B> b = makeD() // gives "error C2440: 'initializing' :
cannot convert from 'clone_ptr<T>' to 'clone_ptr<T>'"
}

adding

  template <class U>
  clone_ptr(BOOST_RV_REF(clone_ptr<U>) p) //Move constructor
    : ptr(p.ptr) { p.ptr = 0; }

to clone_ptr class does not help. Additional c-tor seems to be
ignored. How to fix that?

Cheers,
Simon

-- 
Szymon Gatner
The Lordz Games Studio
www.thelordzgamesstudio.com

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