|
Boost : |
From: Ben Artin (macdev_at_[hidden])
Date: 2006-05-28 02:26:47
In article <e5aek0$ikb$1_at_[hidden]>, "Beman Dawes" <bdawes_at_[hidden]> wrote:
> "Ben Artin" <macdev_at_[hidden]> wrote in message
> news:macdev-641F43.15244027052006_at_sea.gmane.org...
> > In article <e56qh0$lu2$1_at_[hidden]>,
> > "Maarten Kronenburg" <M.Kronenburg_at_[hidden]> wrote:
> >
> > If you believe that every unsigned integer is an integer, you should read
> > Effective C++. Item 35, "Make sure public inheritance models 'isa'"
>
> In the 3rd edition, "Make sure public inheritance models 'isa'" is item 32.
Indeed.
> > until you stop believing it.
>
> What specific operations are you saying that the integer class supports but
> C++ unsigned integer class doesn't support? Meyer's Bird/Penguin flying
> argument only applies if there are operations supported by integers but not
> by unsigned integers, AFAIK.
I am actually referring to the square/rectangle example, which is much more
subtle. The point is that if A isa B then every invariant of B also has to hold
for A. So, the question is then: are there any invariants on integers that do
not hold on unsigned integers? It is not at all obvious to me that's true
(especially since integer invariants have not yet, as far as I know, been stated
explicitly), but the obvious place to look is subtraction and negation.
If we are talking about infinite precision integers, then some example of
reasonable invariants on integers that do not apply to unsigned integers might
be:
a + (-a) = 0
a - b + b = a
Ben
-- I changed my name: <http://periodic-kingdom.org/People/NameChange.php>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk