C++ Optional Implementation
Rule of Three.

int main()
{
    extra::Optional&lt;int&gt; x = Optional&lt;int&gt;of(new int(5));
    extra::Optional&lt;int&gt; y(x);   // This still compilers.

    // But your problems don't appear until here
    // at the end of scope.
}


Design

Why do you force the construction of optional objects via the static methods?

    static Optional&lt;T&gt; of(const T &amp;v);
    static Optional&lt;T&gt; of(T *v);


Why not allow people to just construct the objects in the normal way. It would seem more  natural to create objects of this type just like any other object!

Move semantics

You may not want copy semantics (since you are basically implementing a smart pointer. But you could do with implementing move semantics on your object.

Overall

I don't see the need.

If you want to return a pointer (but make sure it is managed). Then pass back a std::unique_ptr&lt;T&gt;.

If you are doing this as a learning exercise that's different. I'll give it a good going over once you have fixed the problems around the rule of three. But that is such a fundamental problem there is no point in reviewing this code further (Though in future version I would like a justification for the static of() methods and examples of why they are needed).