Re: find() w/ a user defined functor

From: sklett (asasd_at_asdfasdfsd.com)
Date: 01/10/05


Date: Mon, 10 Jan 2005 14:26:48 -0800

ah, of course. Predicates..

I am now trying to use sort with a vector and getting a rather confusing
error. I have added operator < and > to my type, from what I can tell that
is all it needs. I'm getting the error:
error C2784: 'reverse_iterator<_RanIt>::difference_type
std::operator -(const std::reverse_iterator<_RanIt> &,const
std::reverse_iterator<_RanIt> &)' : could not deduce template argument for
'const std::reverse_iterator<_RanIt> &' from 'std::list<_Ty>::iterator'
        with
        [
            _Ty=BeatGroupData
        ]

my comparison operators:
inline bool operator>(const int& right){ return (this->BeatID > right); };

inline bool operator<(const int& right){ return (this->BeatID < right); };

I have read some threads on google, but I don't see any dealing with
vectors, just list which has a member sort....

"Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom> wrote in message
news:u9s6Kk19EHA.2608@TK2MSFTNGP10.phx.gbl...
> > I might want to use find() to match the id property of MyStruct and
later
> I
> > might want to use prefix. Do I need to overload the operator== or is
> there
> > a differe, STL-ish way?
>
> Use find_if() and give different predicates depending on whether you want
to
> match on prefix or id. I tend not to overload == if the object has no
> implicitly natural equality.
>
> Stephen Howe
>
>
>



Relevant Pages

  • Re: Idiomatic ruby
    ... which means all the predicates would have to ... be true on a failure, which might be a bit confusing - I prefer to code ...
    (comp.lang.ruby)
  • Re: Prolog Knights Tour
    ... This is very confusing! ... ?- gtrace, tour. ... to see what's going on using SWI's graphical tracer. ...
    (comp.lang.prolog)