This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Is this a bug or lack of understanding?


martin@loewis.home.cs.tu-berlin.de wrote:
> 
> >     struct s {
> >         bool operator()(string s1, string s2) {
> >             return (s1.size() < s2.size()
> >                     || s1 < s2);
> >         }
> >     };
> 
> Shouldn't that be
> 
>     struct s {
>         bool operator()(string s1, string s2) {
>             return (s1.size() < s2.size()
>                     or (s1.size() == s2.size() and s1 < s2));
>         }
>     };
> 
> instead?

Yes. I use similar code to compare points in row major order (for use in
a std::set).

inline
bool
Point::RowMajorLess::operator ()(const Point& kPoint1,
    const Point& kPoint2) const
{
    return (kPoint1.m_nX < kPoint2.m_nX ||
        kPoint1.m_nX == kPoint2.m_nX && kPoint1.m_nY < kPoint2.m_nY)
}

-- 
Marc A. Lepage
Software Developer
Molecular Mining Corporation
http://www.molecularmining.com/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]