title: Iterator for boost::variant
body: <p>Hy there,</p>
  
  <p>I'm trying to adapt an existing code to boost::variant. The idea is to use boost::variant for a heterogeneous vector. The problem is that the rest of the code use iterators to access the elements of the vector. Is there a way to use the boost::variant with iterators?</p>
  
  <p>I've tried</p>
  
  <pre><code> typedef boost::variant&lt;Foo, Bar&gt; Variant;
   std::vector&lt;Variant&gt; bag;
   std::vector&lt;Variant&gt;::iterator it;
   for(it= bag.begin(); it != bag.end(); ++it){
  
   cout&lt;&lt;(*it)&lt;&lt;endl;
   }
  </code></pre>
  
  <p>But it didn't work.</p>
  
  <p>EDIT: Thank you for your help! But in my design, I need to get one element from the list and pass it around other parts of the code (and that can be nasty, as I'm using GSL). The idea of using an iterator is that I can pass the iterator to a function, and the function will operate on the return data from that specific element. I can't see how to do that using for_each. I need to do something similar to that:</p>
  
  <pre><code>for(it=list.begin(); it!=list.end();++it) {
    for(it_2=list.begin(); it_2!=list.end();++it_2) {
  
       if(it-&gt;property() != it_2-&gt;property()) {
  
          result = operate(it,it_2);
  
         }
      }
  
  }
  </code></pre>
  
  <p>Thanks!</p>