Martin Vermeer wrote:

> I tried the attached (plus a legion of variants that may remain
> unmentioned)... why doesn't it work?

Because std::find can only compare container elements with the given
element, not the addresses. You need to use something like (untested)

class ParAddressEqual : public std::unary_function<Paragraph, bool> {
public:
        ParAddressEqual(Paragraph const * par) : par_(par) {}
        bool operator()(Paragraph const & par) const {
                return &par == par_;
        }
private:
        Paragraph const * par_;
};

ParagraphList::iterator it = std::find_if(pars_.begin(), pars_.end(),
                                          ParAddressEqual(&par));

IMHO this is overkill if used only once, but is useful if you need it
several times.

> The error output is attached too. I'm probably completely
> misunderstanding this.
> 
> Also, what is the right/best place to put the operator==?

I think we don't want one, see above.


Georg

Reply via email to