Boost logo

Boost :

Subject: Re: [boost] Boost.Variant is not EqualityComparable
From: Matthew L. Creech (mlcreech_at_[hidden])
Date: 2009-05-28 13:59:36


On Wed, May 27, 2009 at 1:50 PM, Eric Friedman
<ebf_at_[hidden]> wrote:
> I think operator!= (and operator<=, operator>, operator>=) were left out for
> simplicity, but no good reason other than that.
>
> The main issue I considered at the time was that I felt variant should
> forward to the underlying operator. That is, it should call operator!=,
> rather than assume operator!= is equivalent to the negation of operator==.
>
> Maybe there's no need to be this pedantic though. Do others have an opinion?
>

Could this be useful in the case of something like boost::tribool as a
variant type? For example:

tribool a(true);
tribool b(indeterminate);

if ((a==b) || (a!=b))
        assert(false);

It would be nice if boost::variant<> with a tribool bounded type could
maintain this behavior, which it seems like it would as long as
operator!=() is separately forwarded.

-- 
Matthew L. Creech

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