Subject: Re: [boost] Boost.Algorithm design question
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2011-10-31 13:08:40
Peter Dimov wrote:
> Andrew Sutton wrote:
>> > None of this has anything to do with the fact that you want to require
>> > operator== to be an equivalence relation, and it doesn't have to be.
>> Realistically though, when is == not (at least) an equivalence
> Realistically, and in this context, when the two sides are not of the same
In most of the cases that I care about, there is some underlying type
like "string" or "integer", on which an equivalence relation exists in
some formal sense. Then there are some concrete C++ types like
std::basic_string<char,allocator_2> or int32_t or int64_t. operator==
is defined on pairs of these concrete types in some way that
approximates to the equivalence relation on the underlying formal type,
but with some inevitable flakiness at the edges, such as comparison
between two char*s or comparison between integers with different
numbers of bits.
The difficulty, which is perhaps what Dave is grappling with, is how to
specify an algorithm that does the "right thing" if-and-only-if the
types do the "right thing", while remaining vague about what the "right
thing" means to allow the implementation flexibility.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk