// -*- c++ -*- #pragma once #ifndef __XOT_PIMPL_H__ #define __XOT_PIMPL_H__ #include namespace Xot { template class PImpl : public std::unique_ptr { typedef std::unique_ptr Super; typedef PImpl This; public: PImpl () : Super(new T) {} PImpl (T* p) : Super(p) {} PImpl (const This& obj) : Super(obj ? new T(*obj) : NULL) { } This& operator = (const This& obj) { if (&obj == this) return *this; this->reset(obj ? new T(*obj) : NULL); return *this; } };// PImpl template class PSharedImpl : public std::shared_ptr { typedef std::shared_ptr Super; typedef PSharedImpl This; public: PSharedImpl () : Super(new T) {} PSharedImpl (T* p) : Super(p) {} };// PSharedImpl }// Xot #endif//EOH