title: Template for traversing a tree node using boost::variant
body: <p>Here is my design for traversal of a node tree:</p>
  
  <pre><code>struct Leaf1{};
  struct Leaf2{};
  struct Leaf3{};
  struct Leaf4{};
  struct Leaf5{};
  
  typedef boost::variant&lt; Leaf4, Leaf5 &gt; Node3;
  typedef boost::variant&lt; Leaf2, Leaf3, Node3&gt; Node2;
  typedef boost::variant&lt; Node2, Leaf1 &gt; Node1;
  
  class NodeVisitor: public boost::static_visitor&lt;void&gt;
  {
  public:
      template&lt;class Node&gt;
      void operator()(const Node&amp; e) const
      {
          boost::apply_visitor( *this, e );
      }
  
      void operator()(const Leaf1&amp; e) const{}
      void operator()(const Leaf2&amp; e) const{}
      void operator()(const Leaf3&amp; e) const{}
      void operator()(const Leaf4&amp; e) const{}
      void operator()(const Leaf5&amp; e) const{}
  };
  </code></pre>
  
  <p>So I recursively visit the nodes until I arrive at a leaf. The problem above is that I must add a stub for operater() for each leaf. You can see that I have five such stubs above but have many more in practice. Can you suggest a way of templating this stub?</p>