diff --git a/core/base/intrusive/SmartPointer.hpp b/core/base/intrusive/SmartPointer.hpp index 2900fdb7..e680501f 100644 --- a/core/base/intrusive/SmartPointer.hpp +++ b/core/base/intrusive/SmartPointer.hpp @@ -191,12 +191,6 @@ namespace easy2d } } - template - inline intrusive::SmartPointer MakeSmart(T* ptr) E2D_NOEXCEPT - { - return intrusive::SmartPointer(ptr); - } - // template class cannot specialize std::swap, // so implement a swap function in easy2d namespace template @@ -204,4 +198,27 @@ namespace easy2d { lhs.Swap(rhs); } + + class SmartMaker + { + public: + static inline SmartMaker const& Instance() + { + static SmartMaker maker; + return maker; + } + + template + inline intrusive::SmartPointer operator -(T* ptr) const + { + return intrusive::SmartPointer(ptr); + } + }; + +#ifdef NEW +# undef NEW +#endif + +#define NEW ::easy2d::SmartMaker::Instance() - new (std::nothrow) + }