diff --git a/include/boost/algorithm/string/detail/find_iterator.hpp b/include/boost/algorithm/string/detail/find_iterator.hpp index 1a02bc4..dfa90e3 100644 --- a/include/boost/algorithm/string/detail/find_iterator.hpp +++ b/include/boost/algorithm/string/detail/find_iterator.hpp @@ -10,70 +10,16 @@ #ifndef BOOST_STRING_FIND_ITERATOR_DETAIL_HPP #define BOOST_STRING_FIND_ITERATOR_DETAIL_HPP - #include #include #include #include +#include namespace boost { namespace algorithm { namespace detail { -// finder virtualizer -----------------------------------------------// - - template - struct virtual_finder - { - // typedefs - typedef IteratorT input_iterator_type; - typedef iterator_range match_type; - - // virtual destructor - virtual ~virtual_finder() {} - - // clone - virtual virtual_finder* clone() const=0; - - // operation - virtual match_type do_find( - input_iterator_type Begin, - input_iterator_type End ) const=0; - }; - - template - struct virtual_finder_typed : public virtual_finder - { - // typedefs - typedef virtual_finder base_type; - typedef BOOST_STRING_TYPENAME - base_type::input_iterator_type input_iterator_type; - typedef BOOST_STRING_TYPENAME - base_type::match_type match_type; - - // constuction - virtual_finder_typed( FinderT Finder ) : m_Finder(Finder) {} - - // clone - virtual_finder_typed* clone() const - { - return new virtual_finder_typed(m_Finder); - } - - // operation - virtual match_type do_find( - input_iterator_type Begin, - input_iterator_type End ) const - { - return m_Finder(Begin,End); - } - - private: - // Finder - FinderT m_Finder; - }; - - // find_iterator base -----------------------------------------------// // Find iterator base @@ -84,40 +30,36 @@ namespace boost { // typedefs typedef IteratorT input_iterator_type; typedef iterator_range match_type; - + typedef function2< + match_type, + input_iterator_type, + input_iterator_type> finder_type; + protected: // Protected construction/destruction // Default constructor - find_iterator_base() : m_pFinder(0) {}; + find_iterator_base() {}; // Copy construction find_iterator_base( const find_iterator_base& Other ) : - m_pFinder(0) - { - if ( Other.m_pFinder ) - { - m_pFinder=Other.m_pFinder->clone(); - } - } + m_Finder(Other.m_Finder) {} + // Constructor template find_iterator_base( FinderT Finder, int ) : - m_pFinder( new virtual_finder_typed(Finder) ) {} + m_Finder(Finder) {} // Destructor - ~find_iterator_base() - { - if (m_pFinder) delete m_pFinder; - } + ~find_iterator_base() {} // Find operation match_type do_find( input_iterator_type Begin, input_iterator_type End ) const { - if (m_pFinder) + if (!m_Finder.empty()) { - return m_pFinder->do_find(Begin,End); + return m_Finder(Begin,End); } else { @@ -128,12 +70,12 @@ namespace boost { // Check bool is_null() const { - return !m_pFinder; + return m_Finder.empty(); } private: // Finder - virtual_finder* m_pFinder; + finder_type m_Finder; }; } // namespace detail diff --git a/include/boost/algorithm/string/find_iterator.hpp b/include/boost/algorithm/string/find_iterator.hpp index 21bf748..6c23131 100644 --- a/include/boost/algorithm/string/find_iterator.hpp +++ b/include/boost/algorithm/string/find_iterator.hpp @@ -154,7 +154,7 @@ namespace boost { /*! * Construct a find iterator to iterate through the specified collection */ - template + template inline find_iterator< BOOST_STRING_TYPENAME result_iterator_of::type> make_find_iterator( @@ -304,7 +304,7 @@ namespace boost { /*! * Construct a split iterator to iterate through the specified collection */ - template + template inline split_iterator< BOOST_STRING_TYPENAME result_iterator_of::type> make_split_iterator(