#include <boost/noncopyable.hpp>
#include <memory>


class U {};

U* create_T() { return new U; }

class T : boost::noncopyable {
public:
    explicit T(U *p) : p_(p) {
    }

    ~T() {
        delete p_;
    }

    operator bool() const { return p_ != 0; }


private:
    mutable U *p_;
    U* release() const { U* r = p_; p_ = 0; return r; }
    friend class InitT;
};

class InitT {
public:
  T t;
  InitT(const InitT& o) : t(o.t.release()) {}
  InitT(U* u) : t(u) {}
  operator bool() const { return t; }
};

int main() {
    T x = new U; // allowed
    T y(new U);  // allowed
    std::auto_ptr<U> a = new U;
    std::auto_ptr<U> b(new U);

   if (T i = create_T()) {}
   if (T i(create_T())) {}
   if (U* u = create_T()) { T i(u); }
   if (InitT i = create_T()) {  i.t;  }

    //T z = x;     // not allowed
    //T x2(x)      // not allowed
}