title: Implementing an iterator over binary (or arbitrary) tree using C++ 11
body: <p>I would like to create an iterator over the binary tree so as to be able to use range-based for loop. I understand I ought to implement the begin() and end() function first. </p>
  
  <p>Begin should probably point to the root.  According to the specification, however, the end() functions returns "the element following the last valid element". Which element (node) is that? Would it not be illegal to point to some "invalid" place? </p>
  
  <p>The other thing is the operator++. What is the best way to return "next" element in tree? I just need some advice to begin with this programming.</p>
  
  <hr>
  
  <p>I would like to expand/augment my question*. What if I wanted to iterate over a tree with an arbitrary arity? Let each node have a vector of children and let begin() point to the "real" root. I would probably have to implement a queue (for breadth-first) inside the iterator class to store the unique_ptr's to nodes, right? Then, when the queue is empty I would know that I have passed all nodes and thus should return TreeIterator(nullptr) when oprator++() is called. Does it make sense? I want it as simple as possible and only forward iteration. </p>
  
  <p>*Or should I create a new thread?</p>