Ticket #4189: transform_iterator.patch

File transform_iterator.patch, 1009 bytes (added by Daniel Walker, 12 years ago)

use boost::optional to store function objects

  • boost/iterator/transform_iterator.hpp

     
    1414#include <boost/iterator/iterator_categories.hpp>
    1515#include <boost/mpl/not.hpp>
    1616#include <boost/mpl/bool.hpp>
     17#include <boost/optional.hpp>
    1718#include <boost/type_traits/function_traits.hpp>
    1819#include <boost/type_traits/is_const.hpp>
    1920#include <boost/type_traits/is_class.hpp>
     
    130131   {}
    131132
    132133    UnaryFunc functor() const
    133       { return m_f; }
     134      { return *m_f; }
    134135
    135136  private:
    136137    typename super_t::reference dereference() const
    137     { return m_f(*this->base()); }
     138    { return (*m_f)(*this->base()); }
    138139
    139140    // Probably should be the initial base class so it can be
    140141    // optimized away via EBO if it is an empty class.
    141     UnaryFunc m_f;
     142    boost::optional<UnaryFunc> m_f;
    142143  };
    143144
    144145  template <class UnaryFunc, class Iterator>