title: Speeding up boost::iterator_facade dereference
body: <p>I am using iterator_facade to provide iterator support for a class. However, because the iterator_facade::dereference returns by reference, and it is an object with a non-trivial copy-const that is being returned, my performance is suffering upon every dereference (as profiled with VTune) as a result of constantly performing these copies. Is there a way around this? </p>
  
  <pre><code>class time_series::iterator : public boost::iterator_facade&lt;
                           time_series::iterator,
                           time_series::variable_vec,
                           boost::bidirectional_traversal_tag,
                           timestep&gt; //&lt;--- dereference type
  {
  public:
      iterator();
      iterator(const iterator&amp; src);
      ~iterator();
      iterator&amp; operator=(const iterator&amp; rhs);
  private:
       //the following satisfies the reqs for a boost::facade bidirectional iterator
       friend class boost::iterator_core_access;
       friend class time_series;
  
       const timestep&amp; dereference() const;
       bool equal(iterator const&amp; other) const;
       void increment();
       void decrement();
       std::ptrdiff_t distance_to(iterator const&amp; other) const;
  
       //iterators for the current step
       timestep _currentStep;// &lt;--returned on dereference, is non-trivial to copy.
  };
  </code></pre>
  
  <p>edit:
  as per comment</p>
  
  <pre><code>const timestep&amp; time_series::iterator::dereference() const
  {
      return _currentStep;
  }
  </code></pre>