Simple Tree C++ implementation
Use using keyword to define your type instead of typedef

C++11 introduced type alias which can be used to define your own type and it's compatible with templates, so instead of:

typedef typename std::multiset &lt; Tree * , typename Tree::compare &gt; NodeSet;


you'll get this:

using NodeSet = std::multiset &lt; Tree * , Tree::compare &gt;;


Consider using range-based for loop instead of while loop with iterator

I think that it will result in simplier and more readable code, for example Visit function will look like this:

void Visit(std::deque &lt;T&gt;&amp; exp) const {
  exp.push_back(content);
  for (const auto&amp; child : children)
        child-&gt;Visit(exp);
}


Unnecessary erase call in Clear function

The following call:

children.erase( *it);


is unnecessary - multiset childern will be erased automatically.

Reconsider memory management

Currently it's possible to add new child to existing Tree by calling function

void AttachTree(Tree* t)


which expects pointer to existing Tree object as argument. It means that Tree is not repsonsible for creation of children. By the other hand, in destructor the Clear function is called which deletes all the children, which means that Tree takes responsibility for deletion of children. This might lead to undefined behaviour. Consider the following code:

Tree&lt;int&gt;* t1 = new Tree&lt;int&gt;(1);
{
    Tree&lt;int&gt; t2(2);
    t2.AttachTree(t1);
    {
        Tree&lt;int&gt; t3(3);
        t3.AttachTree(t1);
        std::cout &lt;&lt; "1. t1 content: " &lt;&lt; t1-&gt;GetContent() &lt;&lt; "\n";
    } // t3 desctructor is called, which means that t1 has been deleted
    std::cout &lt;&lt; "2. t1 content: " &lt;&lt; t1-&gt;GetContent() &lt;&lt; "\n"; // t1 doesn't exist anymore - what's the result of t1-&gt;GetContent() ?
} // t2 desctructor is called and t1 will be deleted again
std::cout &lt;&lt; "3. t1 content: " &lt;&lt; t1-&gt;GetContent() &lt;&lt; "\n"; // t1 doesn't exist anymore - what's the result of t1-&gt;GetContent() ?