11// Boost string_algo library compare.hpp header file -------------------------//
22
3- // Copyright Pavol Droba 2002-2003 . Use, modification and
3+ // Copyright Pavol Droba 2002-2006 . Use, modification and
44// distribution is subject to the Boost Software License, Version
55// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
66// http://www.boost.org/LICENSE_1_0.txt)
@@ -37,7 +37,7 @@ namespace boost {
3737 Compare two operands for equality
3838 */
3939 template < typename T1 , typename T2 >
40- bool operator ()( const T1 & Arg1, const T2 & Arg2 ) const
40+ bool operator ()( const T1 & Arg1, const T2 & Arg2 ) const
4141 {
4242 return Arg1==Arg2;
4343 }
@@ -62,7 +62,7 @@ namespace boost {
6262 Compare two operands. Case is ignored.
6363 */
6464 template < typename T1 , typename T2 >
65- bool operator ()( const T1 & Arg1, const T2 & Arg2 ) const
65+ bool operator ()( const T1 & Arg1, const T2 & Arg2 ) const
6666 {
6767 #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
6868 return std::toupper (Arg1)==std::toupper (Arg2);
@@ -75,11 +75,122 @@ namespace boost {
7575 std::locale m_Loc;
7676 };
7777
78+ // is_less functor -----------------------------------------------//
79+
80+ // ! is_less functor
81+ /* !
82+ Convenient version of standard std::less. Operation is templated, therefore it is
83+ not required to specify the exact types upon the construction
84+ */
85+ struct is_less
86+ {
87+ // ! Functor operation
88+ /* !
89+ Compare two operands using > operator
90+ */
91+ template < typename T1 , typename T2 >
92+ bool operator ()( const T1 & Arg1, const T2 & Arg2 ) const
93+ {
94+ return Arg1<Arg2;
95+ }
96+ };
97+
98+
99+ // ! case insensitive version of is_less
100+ /* !
101+ Case insensitive comparison predicate. Comparison is done using
102+ specified locales.
103+ */
104+ struct is_iless
105+ {
106+ // ! Constructor
107+ /* !
108+ \param Loc locales used for comparison
109+ */
110+ is_iless ( const std::locale& Loc=std::locale() ) :
111+ m_Loc ( Loc ) {}
112+
113+ // ! Function operator
114+ /* !
115+ Compare two operands. Case is ignored.
116+ */
117+ template < typename T1 , typename T2 >
118+ bool operator ()( const T1 & Arg1, const T2 & Arg2 ) const
119+ {
120+ #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
121+ return std::toupper (Arg1)<std::toupper (Arg2);
122+ #else
123+ return std::toupper (Arg1,m_Loc)<std::toupper (Arg2,m_Loc);
124+ #endif
125+ }
126+
127+ private:
128+ std::locale m_Loc;
129+ };
130+
131+ // is_not_greater functor -----------------------------------------------//
132+
133+ // ! is_not_greater functor
134+ /* !
135+ Convenient version of standard std::not_greater_to. Operation is templated, therefore it is
136+ not required to specify the exact types upon the construction
137+ */
138+ struct is_not_greater
139+ {
140+ // ! Functor operation
141+ /* !
142+ Compare two operands using > operator
143+ */
144+ template < typename T1 , typename T2 >
145+ bool operator ()( const T1 & Arg1, const T2 & Arg2 ) const
146+ {
147+ return Arg1>=Arg2;
148+ }
149+ };
150+
151+
152+ // ! case insensitive version of is_not_greater
153+ /* !
154+ Case insensitive comparison predicate. Comparison is done using
155+ specified locales.
156+ */
157+ struct is_not_igreater
158+ {
159+ // ! Constructor
160+ /* !
161+ \param Loc locales used for comparison
162+ */
163+ is_not_igreater ( const std::locale& Loc=std::locale() ) :
164+ m_Loc ( Loc ) {}
165+
166+ // ! Function operator
167+ /* !
168+ Compare two operands. Case is ignored.
169+ */
170+ template < typename T1 , typename T2 >
171+ bool operator ()( const T1 & Arg1, const T2 & Arg2 ) const
172+ {
173+ #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
174+ return std::toupper (Arg1)>=std::toupper (Arg2);
175+ #else
176+ return std::toupper (Arg1,m_Loc)>=std::toupper (Arg2,m_Loc);
177+ #endif
178+ }
179+
180+ private:
181+ std::locale m_Loc;
182+ };
183+
184+
78185 } // namespace algorithm
79186
80187 // pull names to the boost namespace
81188 using algorithm::is_equal;
82189 using algorithm::is_iequal;
190+ using algorithm::is_less;
191+ using algorithm::is_iless;
192+ using algorithm::is_not_greater;
193+ using algorithm::is_not_igreater;
83194
84195} // namespace boost
85196
0 commit comments