Boost logo

Boost Users :

From: Olaf van der Spek (OvdSpek_at_[hidden])
Date: 2006-03-03 08:42:14


Pavol Droba wrote:
> The functionality is in cvs. I have added lexicographical_compare (also in i variant)
> and comparison predicates is_(i)less, is_not_(i)greater.
>
> Check it out.

struct is_not_greater
{
     template< typename T1, typename T2 >
         bool operator()( const T1& Arg1, const T2& Arg2 ) const
     {
         return Arg1>=Arg2;
     }
};

>=, isn't that is_not_less?

struct is_iless
{
     is_iless( const std::locale& Loc=std::locale() ) :
         m_Loc( Loc ) {}

     template< typename T1, typename T2 >
         bool operator()( const T1& Arg1, const T2& Arg2 ) const
     {
         #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) &&
(__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
             return std::toupper(Arg1)<std::toupper(Arg2);
         #else
             return std::toupper(Arg1,m_Loc)<std::toupper(Arg2,m_Loc);
         #endif
     }
}

What about 'A' vs 'a'? Shouldn't 'A' < 'a'?

I'm also wondering how expensive std::toupper is. Would it make sense to
do a == first to avoid the std::toupper calls in certain cases?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net