/*---------------------------------------------------------------------------* Project: Horizon File: util_ScopedPointer.h Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 12449 $ *---------------------------------------------------------------------------*/ #ifdef __cplusplus #ifndef NN_UTIL_UTIL_SCOPEDPOINTER_H_ #define NN_UTIL_UTIL_SCOPEDPOINTER_H_ #include namespace nn { namespace util { template class ScopedPointer : private nn::util::NonCopyable > { private: T* m_Ptr; public: ScopedPointer(T* ptr) : m_Ptr(ptr){}; ~ScopedPointer() { delete m_Ptr; } T& operator*() const { return *m_Ptr; } T* operator->() const { return m_Ptr; } T* Get() const { return m_Ptr; } }; template class ScopedUntypedPointer : private nn::util::NonCopyable > { private: void* m_Ptr; public: ScopedUntypedPointer(void* ptr) : m_Ptr(ptr){}; ~ScopedUntypedPointer() { Deallocate(m_Ptr); } void* Get() const { return m_Ptr; } }; } } #endif // #ifndef NN_UTIL_UTIL_SCOPEDPOINTER_H_ #endif // __cplusplus