Why is std::type_info noncopyable? Am I allowed to store it somewhere?
<p>The <code>std::type_info</code> class is non-copyable. This makes it hard to store it in an object for later use. I spent some time trying to make an object wrapper that allows me to do this. I'm not sure if it is because I had too much coffee; but the result is much more complicated than expected:</p>

<pre><code>// Helper for TypeInfo class below.
template&lt;typename T&gt;
struct Identity
{
    typedef T type;
};

// Allows you to store std::type_info in a copyable object.
class TypeInfo
{
public:
    // Template constructor of non-template class is only possible
    // if you pass an argument of the template type.
    // We have to use a dummy here to make the compiler happy.
    template&lt;class T&gt;
    TypeInfo(Identity&lt;T&gt; id) :
        mTypeInfoImpl(new TypeInfoImpl(id))
    {
    }

private:
    friend bool operator&lt;(const TypeInfo &amp; lhs, const TypeInfo &amp; rhs);

    struct TypeInfoImpl
    {
        template&lt;class T&gt;
        TypeInfoImpl(Identity&lt;T&gt; id) :
            mTypeInfo(typeid(id)) // Copy constructor is avoided here by storing
                                  // a const reference instead of an object.
        {
        }

        // typeid(T) returns a const reference to a static object.
        // therefore we can safely store the reference here.
        // Edit: prev comment here was wrong.
        const std::type_info &amp; mTypeInfo;
    };

    // Make our class copyable by storing our non-copyable
    // TypeInfoImpl wrapper as a pointer.
    boost::shared_ptr&lt;TypeInfoImpl&gt; mTypeInfoImpl;
};

// We want to be able to compare TypeInfo objects.
bool operator&lt;(const TypeInfo &amp; lhs, const TypeInfo &amp; rhs)
{
    return lhs.mTypeInfoImpl-&gt;mTypeInfo.before(rhs.mTypeInfoImpl.get()-&gt;mTypeInfo);
}

// Factory function for creating a TypeInfo object.
// So you don't need to specify the Identity object.
template&lt;class T&gt;
static TypeInfo TypeId()
{
    return TypeInfo(Identity&lt;T&gt;());
}

// A few tests.
bool TestTypeInfo()
{
    TypeInfo t1 = TypeId&lt;int&gt;();
    TypeInfo t2 = TypeId&lt;bool&gt;();
    t2 = t1;
    return t1 &lt; t2;
}
</code></pre>

<p>Where did I go wrong?</p>
