Thread-safe Phoenix Singleton class template with Boost I've implemented the phoenix-singleton as a class template with boost inspired by Modern C++ Design. The code compiles fine with MSVC 2013 - and it seems to work, but I'm new
to multi-threaded programming and Boost. Are there any pitfalls in the code? Improvements?

TSingleton.h

#ifndef TSINGLETON_H
#define TSINGLETON_H

#include &lt;cstdlib&gt;
#include &lt;boost/atomic.hpp&gt;
#include &lt;boost/thread/mutex.hpp&gt;

template&lt;typename T&gt;
class TSingleton{
public:
    static T&amp; getInstance();

protected:
    inline explicit TSingleton();
    TSingleton(const TSingleton&amp;);
    TSingleton&amp; operator=(const TSingleton&amp;);
    virtual ~TSingleton();
    static void _CreateInstance();
    static void _Phoenix();
    static void _KillPhoenix();

    static boost::atomic&lt;T*&gt; _instance;
    static boost::atomic&lt;bool&gt; _destroyed;
    static boost::mutex _instantiation_mutex;
};



template&lt;typename T&gt;
boost::atomic&lt;bool&gt; TSingleton&lt;T&gt;::_destroyed = (boost::atomic&lt;bool&gt;) false;

template&lt;typename T&gt;
boost::atomic&lt;T*&gt; TSingleton&lt;T&gt;::_instance = (boost::atomic&lt;T*&gt;) nullptr;

template&lt;typename T&gt;
boost::mutex TSingleton&lt;T&gt;::_instantiation_mutex;

template&lt;typename T&gt;
TSingleton&lt;T&gt;::~TSingleton(){
    TSingleton::_destroyed = true;
    TSingleton::_instance = nullptr;
}

template&lt;typename T&gt;
T&amp; TSingleton&lt;T&gt;::getInstance(){
    T* tmp = TSingleton::_instance.load(boost::memory_order_consume);
    if (!tmp){
        boost::mutex::scoped_lock guard(TSingleton::_instantiation_mutex);
        tmp = TSingleton::_instance.load(boost::memory_order_consume);
        if (!tmp){
            if (TSingleton::_destroyed){
                TSingleton::_Phoenix();
            }else{
                TSingleton::_CreateInstance();
            }
            tmp = TSingleton::_instance.load(boost::memory_order_consume);
        }
    }
    return *tmp;
}

template&lt;typename T&gt;
void TSingleton&lt;T&gt;::_CreateInstance(){
    static T instance;
    TSingleton::_instance.store(&amp;instance, boost::memory_order_release);
}

template&lt;typename T&gt;
void TSingleton&lt;T&gt;::_Phoenix(){
    TSingleton::_CreateInstance();
    new(TSingleton::_instance) T;
    std::atexit(TSingleton::_KillPhoenix);
    TSingleton::_destroyed = false;
}

template&lt;typename T&gt;
void TSingleton&lt;T&gt;::_KillPhoenix(){
    T* tmp = TSingleton::_instance.load(boost::memory_order_consume);
    tmp-&gt;~T();
    TSingleton::_destroyed = true;
    TSingleton::_instance = nullptr;
}

#endif // TSINGLETON_H


Simple usage example:

#include &lt;iostream&gt;
#include "TSingleton.h"

class Foo{
public:
    void bar(){ std::cout &lt;&lt; "bar" &lt;&lt; std::endl; }
};

int main(int argc, char **argv){
    Foo&amp; myfoo = TSingleton&lt;Foo&gt;::getInstance();
    myfoo.bar();
    return 0;
}
I'm not a threading specialist, so won't be able to tell you for sure if your code is 100% race condition free. However, there are a few other code smells that I would like to warn you about:


Reserved names: A name starting with an underscore and an uppercase letter is reserved in any scope. _CreateInstance, _Phoenix and _KillPhoenix are not safe to be used, even inside a class.
inline is redundant for a template class or function. The class is always inline, so you don't have to add the keyword.
explicit makes no sense for a constructor that takes 0 arguments. You usually apply explicit if you have a constructor taking 1 argument and you wish to avoid an implicit conversion.
Do you really plan on allowing classes to inherit from TSingleton? It doesn't seem like there is a need for that, since the singleton type is a template parameter. Maybe I'm missing something, but if it is not to be inherited, make all currently protected members private and remove virtual from the destructor.
This initialization style is mighty strange: _destroyed = (boost::atomic&lt;bool&gt;) false; A plain assignment _destroyed = false; or using the constructor syntax: _destroyed(false); would be much better. 
When calling a static method or accessing a static variable of a class, inside the given class, prefixing the call with ClassName is optional. So you could, for example, simply use _instance instead of TSingleton::_instance.
VS 2013 should have most if not all C++11 features and libraries working. So you could replace Boost with the new threading and atomics libraries to reduce dependencies.
If you switch to C++11, you can delete the copy constructor and assignment operator.