From e2b9172f5d1dc6935693b765ed03a3426ab95236 Mon Sep 17 00:00:00 2001 From: Pavol Droba Date: Mon, 6 Feb 2006 18:10:18 +0000 Subject: [PATCH] - tabs removed - find_tail/head_impl functions rearranged to avoid the dependency problem [SVN r32676] --- include/boost/algorithm/string/compare.hpp | 80 ++++---- .../boost/algorithm/string/detail/finder.hpp | 188 +++++++++--------- include/boost/algorithm/string/predicate.hpp | 142 ++++++------- 3 files changed, 206 insertions(+), 204 deletions(-) diff --git a/include/boost/algorithm/string/compare.hpp b/include/boost/algorithm/string/compare.hpp index 6e6e07d..e6610a9 100644 --- a/include/boost/algorithm/string/compare.hpp +++ b/include/boost/algorithm/string/compare.hpp @@ -75,25 +75,25 @@ namespace boost { std::locale m_Loc; }; - // is_less functor -----------------------------------------------// + // is_less functor -----------------------------------------------// - //! is_less functor - /*! - Convenient version of standard std::less. Operation is templated, therefore it is - not required to specify the exact types upon the construction - */ - struct is_less - { - //! Functor operation - /*! - Compare two operands using > operator - */ - template< typename T1, typename T2 > - bool operator()( const T1& Arg1, const T2& Arg2 ) const - { - return Arg1 operator + */ + template< typename T1, typename T2 > + bool operator()( const T1& Arg1, const T2& Arg2 ) const + { + return Arg1 operator - */ - template< typename T1, typename T2 > - bool operator()( const T1& Arg1, const T2& Arg2 ) const - { - return Arg1>=Arg2; - } - }; + //! is_not_greater functor + /*! + Convenient version of standard std::not_greater_to. Operation is templated, therefore it is + not required to specify the exact types upon the construction + */ + struct is_not_greater + { + //! Functor operation + /*! + Compare two operands using > operator + */ + template< typename T1, typename T2 > + bool operator()( const T1& Arg1, const T2& Arg2 ) const + { + return Arg1>=Arg2; + } + }; //! case insensitive version of is_not_greater @@ -187,10 +187,10 @@ namespace boost { // pull names to the boost namespace using algorithm::is_equal; using algorithm::is_iequal; - using algorithm::is_less; - using algorithm::is_iless; - using algorithm::is_not_greater; - using algorithm::is_not_igreater; + using algorithm::is_less; + using algorithm::is_iless; + using algorithm::is_not_greater; + using algorithm::is_not_igreater; } // namespace boost diff --git a/include/boost/algorithm/string/detail/finder.hpp b/include/boost/algorithm/string/detail/finder.hpp index 8d107f1..a990257 100644 --- a/include/boost/algorithm/string/detail/finder.hpp +++ b/include/boost/algorithm/string/detail/finder.hpp @@ -212,9 +212,9 @@ namespace boost { typedef first_finderF< search_iterator_type, PredicateT> first_finder_type; - typedef last_finderF< - search_iterator_type, - PredicateT> last_finder_type; + typedef last_finderF< + search_iterator_type, + PredicateT> last_finder_type; // Construction template< typename SearchT > @@ -241,25 +241,25 @@ namespace boost { ForwardIteratorT Begin, ForwardIteratorT End ) const { - if(m_Nth>=0) - { - return find_forward(Begin, End, m_Nth); - } - else - { - return find_backward(Begin, End, -m_Nth); - } + if(m_Nth>=0) + { + return find_forward(Begin, End, m_Nth); + } + else + { + return find_backward(Begin, End, -m_Nth); + } } - private: - // Implementation helpers + private: + // Implementation helpers template< typename ForwardIteratorT > iterator_range find_forward( ForwardIteratorT Begin, ForwardIteratorT End, - unsigned int N) const + unsigned int N) const { typedef ForwardIteratorT input_iterator_type; typedef iterator_range result_type; @@ -294,7 +294,7 @@ namespace boost { find_backward( ForwardIteratorT Begin, ForwardIteratorT End, - unsigned int N) const + unsigned int N) const { typedef ForwardIteratorT input_iterator_type; typedef iterator_range result_type; @@ -333,55 +333,55 @@ namespace boost { // find head functor -----------------------------------------------// - // Find head implementation - template - iterator_range - find_head_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N ) - { - typedef BOOST_STRING_TYPENAME boost::detail:: - iterator_traits::iterator_category category; + template + iterator_range + find_head_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N, + std::forward_iterator_tag ) + { + typedef ForwardIteratorT input_iterator_type; + typedef iterator_range result_type; - return find_head_impl( Begin, End, N, category() ); - } + input_iterator_type It=Begin; + for( + unsigned int Index=0; + Index - iterator_range - find_head_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N, - std::forward_iterator_tag ) - { - typedef ForwardIteratorT input_iterator_type; - typedef iterator_range result_type; + return result_type( Begin, It ); + } - input_iterator_type It=Begin; - for( - unsigned int Index=0; - Index + iterator_range + find_head_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N, + std::random_access_iterator_tag ) + { + typedef ForwardIteratorT input_iterator_type; + typedef iterator_range result_type; - return result_type( Begin, It ); - } + if ( (End<=Begin) || ( static_cast(End-Begin) < N ) ) + return result_type( Begin, End ); - template< typename ForwardIteratorT > - iterator_range - find_head_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N, - std::random_access_iterator_tag ) - { - typedef ForwardIteratorT input_iterator_type; - typedef iterator_range result_type; + return result_type(Begin,Begin+N); + } - if ( (End<=Begin) || ( static_cast(End-Begin) < N ) ) - return result_type( Begin, End ); + // Find head implementation + template + iterator_range + find_head_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N ) + { + typedef BOOST_STRING_TYPENAME boost::detail:: + iterator_traits::iterator_category category; - return result_type(Begin,Begin+N); - } + return find_head_impl( Begin, End, N, category() ); + } // find a head in the sequence ( functor ) @@ -402,17 +402,17 @@ namespace boost { ForwardIteratorT Begin, ForwardIteratorT End ) const { - if(m_N>=0) - { - return find_head_impl( Begin, End, m_N ); - } - else - { - iterator_range Res= - find_tail_impl( Begin, End, -m_N ); + if(m_N>=0) + { + return find_head_impl( Begin, End, m_N ); + } + else + { + iterator_range Res= + find_tail_impl( Begin, End, -m_N ); - return make_iterator_range(Begin, Res.begin()); - } + return make_iterator_range(Begin, Res.begin()); + } } private: @@ -421,26 +421,13 @@ namespace boost { // find tail functor -----------------------------------------------// - // Operation - template< typename ForwardIteratorT > - iterator_range - find_tail_impl( - ForwardIteratorT Begin, - ForwardIteratorT End, - unsigned int N ) - { - typedef BOOST_STRING_TYPENAME boost::detail:: - iterator_traits::iterator_category category; - - return find_tail_impl( Begin, End, N, category() ); - } template< typename ForwardIteratorT > iterator_range find_tail_impl( ForwardIteratorT Begin, ForwardIteratorT End, - unsigned int N, + unsigned int N, std::forward_iterator_tag ) { typedef ForwardIteratorT input_iterator_type; @@ -464,7 +451,7 @@ namespace boost { find_tail_impl( ForwardIteratorT Begin, ForwardIteratorT End, - unsigned int N, + unsigned int N, std::bidirectional_iterator_tag ) { typedef ForwardIteratorT input_iterator_type; @@ -483,7 +470,7 @@ namespace boost { find_tail_impl( ForwardIteratorT Begin, ForwardIteratorT End, - unsigned int N, + unsigned int N, std::random_access_iterator_tag ) { typedef ForwardIteratorT input_iterator_type; @@ -495,6 +482,21 @@ namespace boost { return result_type( End-N, End ); } + // Operation + template< typename ForwardIteratorT > + iterator_range + find_tail_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N ) + { + typedef BOOST_STRING_TYPENAME boost::detail:: + iterator_traits::iterator_category category; + + return find_tail_impl( Begin, End, N, category() ); + } + + // find a tail in the sequence ( functor ) /* This functor find a tail of the specified range. For @@ -513,17 +515,17 @@ namespace boost { ForwardIteratorT Begin, ForwardIteratorT End ) const { - if(m_N>=0) - { - return find_tail_impl( Begin, End, m_N ); - } - else - { - iterator_range Res= - find_head_impl( Begin, End, -m_N ); + if(m_N>=0) + { + return find_tail_impl( Begin, End, m_N ); + } + else + { + iterator_range Res= + find_head_impl( Begin, End, -m_N ); - return make_iterator_range(Res.end(), End); - } + return make_iterator_range(Res.end(), End); + } } private: diff --git a/include/boost/algorithm/string/predicate.hpp b/include/boost/algorithm/string/predicate.hpp index 2f3b3f8..e6d021c 100644 --- a/include/boost/algorithm/string/predicate.hpp +++ b/include/boost/algorithm/string/predicate.hpp @@ -333,84 +333,84 @@ namespace boost { // lexicographical_compare predicate -----------------------------// - //! Lexicographical compare predicate - /*! - This predicate is an overload of std::lexicographical_compare - for range arguments + //! Lexicographical compare predicate + /*! + This predicate is an overload of std::lexicographical_compare + for range arguments - It check whether the first argument is lexicographically less - then the second one. + It check whether the first argument is lexicographically less + then the second one. - If the optional predicate is specified, it is used for character-wise - comparison + If the optional predicate is specified, it is used for character-wise + comparison - \param Arg1 First argument - \param Arg2 Second argument - \param Pred Comparison predicate - \return The result of the test + \param Arg1 First argument + \param Arg2 Second argument + \param Pred Comparison predicate + \return The result of the test - \note This function provides the strong exception-safety guarantee - */ - template - inline bool lexicographical_compare( - const Range1T& Arg1, - const Range2T& Arg2, - PredicateT Pred) - { - return std::lexicographical_compare( - begin(Arg1), - end(Arg1), - begin(Arg2), - end(Arg2), - Pred); - } + \note This function provides the strong exception-safety guarantee + */ + template + inline bool lexicographical_compare( + const Range1T& Arg1, + const Range2T& Arg2, + PredicateT Pred) + { + return std::lexicographical_compare( + begin(Arg1), + end(Arg1), + begin(Arg2), + end(Arg2), + Pred); + } - //! Lexicographical compare predicate - /*! - \overload - */ - template - inline bool lexicographical_compare( - const Range1T& Arg1, - const Range2T& Arg2) - { - return std::lexicographical_compare( - begin(Arg1), - end(Arg1), - begin(Arg2), - end(Arg2), - is_less()); - } + //! Lexicographical compare predicate + /*! + \overload + */ + template + inline bool lexicographical_compare( + const Range1T& Arg1, + const Range2T& Arg2) + { + return std::lexicographical_compare( + begin(Arg1), + end(Arg1), + begin(Arg2), + end(Arg2), + is_less()); + } - //! Lexicographical compare predicate (case-insensitive) - /*! - This predicate is an overload of std::lexicographical_compare - for range arguments. - It check whether the first argument is lexicographically less - then the second one. - Elements are compared case insensitively + //! Lexicographical compare predicate (case-insensitive) + /*! + This predicate is an overload of std::lexicographical_compare + for range arguments. + It check whether the first argument is lexicographically less + then the second one. + Elements are compared case insensitively - \param Arg1 First argument - \param Arg2 Second argument - \param Pred Comparison predicate - \return The result of the test + \param Arg1 First argument + \param Arg2 Second argument + \param Pred Comparison predicate + \return The result of the test - \note This function provides the strong exception-safety guarantee - */ - template - inline bool ilexicographical_compare( - const Range1T& Arg1, - const Range2T& Arg2) - { - return std::lexicographical_compare( - begin(Arg1), - end(Arg1), - begin(Arg2), - end(Arg2), - is_iless()); - } - + \note This function provides the strong exception-safety guarantee + */ + template + inline bool ilexicographical_compare( + const Range1T& Arg1, + const Range2T& Arg2) + { + return std::lexicographical_compare( + begin(Arg1), + end(Arg1), + begin(Arg2), + end(Arg2), + is_iless()); + } + // all predicate -----------------------------------------------// @@ -455,8 +455,8 @@ namespace boost { using algorithm::equals; using algorithm::iequals; using algorithm::all; - using algorithm::lexicographical_compare; - using algorithm::ilexicographical_compare; + using algorithm::lexicographical_compare; + using algorithm::ilexicographical_compare; } // namespace boost