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


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>'"


  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?


Szymon Gatner
The Lordz Games Studio

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at