Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2004-03-11 20:14:24


On Thursday 11 March 2004 06:09 pm, Peter Dimov wrote:
> Douglas Gregor wrote:
>
> [...]
>
> > The "contains" member is there precisely because I knew about the
> > cases where we want to check containment but don't want to use
> > operator==.
>
> I must be missing something. The "contains" member is there? Where? I don't
> see "contains" in the source, in the docs, and my compiler doesn't see it,
> either (it has much better vision).

Sorry, it's called "target", and it's not the same as contains. The contains
we're talking about would be implemented as:

// inside class template function/functionN
template<typename F>
  bool contains(const F& f) const
  {
    if (const F* fp = this->template target<F>()) {
      return function_equal(*fp, f);
    } else {
      return false;
    }
  }

I should (will) add it, regardless of the fate of operator==, because it's
obviously needed.

> > I guess the above will either convince you that:
> >
> > 1) operator== is sufficiently limited so that it is safe to use,
> > because bad uses end up with compiler errors.
> > 2) operator== is still a terrible way to represent check the
> > containment relationship, and turns into a bloody mess of
> > requirements.
>
> I don't view these two options as mutually exclusive. ;-)

Heh heh.

Well, I'm all out of arguments for operator==.

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk