Boost logo

Boost :

From: Sylvain Pion (pion_at_[hidden])
Date: 2002-09-08 19:40:03


On Fri, Sep 06, 2002 at 05:34:06PM -0400, Douglas Gregor wrote:
> I propose that we:
> 1) Remove comparison policies _in their current form_
> 2) Create a default comparison semantics that makes interval<T> a numeric
> type that will work well in generic functions (it should throw if rounding
> errors cause a comparison to be indeterminate)
> 3) Allow other comparison semantics to override the default semantics within
> a particular scope

I like your proposal.

I am also now convinced that the (lexicographic) std::less specialization is
probably a good thing to have.

> [Implementation Details]
> Here's a short sample program that describes the implementation scheme that
> can be used. The crucial point is that the definition of operator< inside the
> interval class is the default operator<. However, the second argument (not
> 'this') requires a (no-op) implicit conversion via the interval_holder class
> template. Thus, if any operator<(const interval<T>&, const interval<T>&) is
> available (e.g., introduced via a 'using namespace ...'), that operator< will
> be a better choice than the operator< inside the interval class, because the
> second argument will only require cv-qualifier adjustments instead of a
> user-defined conversion by constructor. The result is that 'using namespace
> my_interval_semantics' brings in a set of operators whose semantics are
> always better than the default semantics.

Nice trick !

-- 
Sylvain

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