Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-09-02 06:50:43


"Eric Friedman" <ebf_at_[hidden]> writes:

> Peter Dimov wrote:
> [snip]
>> Provide operator<. Wait six months. Collect feedback. If there is evidence
>> that operator< is evil, remove it and document why it is not supplied.
>
> OK, I'm willing to go along with this. I'll probably also include
> operator==, with a similar plan for future evaluation.
>
> Early evidence that operator< is evil though may be demonstrated in the
> following:
>
> boost::variant<int, double> var(3.0);
> ...
> if (var <= 3) // false
> ...
>
> While the obvious objection is "but operator< isn't meant for
> variant-nonvariant comparison," I don't see how to prevent it since variant
> has implicit constructors.
>
> Ideas?

Arrange for a compile-error if x <= 3 is legal for more than one of
the types in the variant?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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