#ifndef CSINGLETON_H
#define CSINGLETON_H


template <typename T>
class SingleTon
{
public:
    // 创建单例实例
    template<typename... Args>
    static T* instance(Args&&... args)
    {
        if (m_pInstance == nullptr)
        {
            m_pInstance = new T(std::forward<Args>(args)...);
        }

        return m_pInstance;
    }

    // 获取单例
    static T* getInstance()
    {
        return m_pInstance;
    }

    // 删除单例
    static void destroyInstance()
    {
        delete m_pInstance;
        m_pInstance = nullptr;
    }

private:
    SingleTon();
    virtual ~SingleTon();

private:
    static T* m_pInstance;
};

template <class T>
T* SingleTon<T>::m_pInstance = nullptr;


#endif
