//懒汉式 1 
template<typename Singleton>
class CSingleton    
{    
private:    
//构造 拷贝 赋值均是私有或关闭 
    CSingleton();    
    static pthread_t mutex_;     
public:    
    CSingleton(const Singleton&)=delete;  
    CSingleton& operator=(const Singleton&)=delete;  
    static Singleton *Getinstance()  
    {    
        if(m_Instance == NULL)    
        {   //double check 
            pthread_mutex_lock(mutex_);           //用lock实现线程安全 
            if(m_Instance == NULL)    
            {    
                m_Instance = new Singleton();    
            }   
            pthread_mutex_unlock(mutex_)   
        }    
        return m_Instance;    
    }  
    static Singleton *m_Instance;    
    
};    
Singleton* CSingleton::m_Instance = 0;    
  
  
//懒汉式 2 
template<typename Singleton>
class CSingleton  
{  
private:  
    CSingleton();  
public:  
    CSingleton(const Singleton&)=delete;  
    CSingleton& operator=(const Singleton&)=delete;  
      
    static Singleton* get_instance(){  
        static Singleton* m_instance = new Singleton();  
        return instance;  
    }  
  
};  
  
//饿汉式 
template<typename Singleton>
class CSingleton {  
private:  
    CSingleton();  
    static Singleton* m_instance = new Singleton();  
 
public:  
    CSingleton(const Singleton&)=delete;  
    CSingleton& operator=(const Singleton&)=delete;  
     
    Singleton* getInstance()   
    {  
        return m_instance;  
    }  
}