|
Boost : |
From: Maarten Kronenburg (M.Kronenburg_at_[hidden])
Date: 2006-05-27 08:49:26
Douglas,
This is the same discussion I had with
Gehard about the negate().
Negating an unsigned with value zero
is perfectly legal.
When it is not zero, it can throw an exception,
as a good numeric class is supposed to do.
By the way for the modular integer we don't
have this discussion, as the base type
unsigned int is actually a modular integer
with modulus 2^32, with negation.
Regards, Maarten.
"Douglas Gregor" <doug.gregor_at_[hidden]> wrote in message
news:325920BA-D24C-475E-AB8C-85D9429C224B_at_cs.indiana.edu...
>
> On May 26, 2006, at 7:26 AM, Maarten Kronenburg wrote:
> > Every unsigned integer is an integer,
>
> No.
>
> A (signed) integer will have a negation operator, such that 0 - x = -
> x, x + -x = 0, etc. An unsigned integer will not have this operator.
>
> > and every modular integer is an integer.
> > So therefore in my opinion public inheritance
> > can be used.
> > Also I think there is no other way of defining
> > an unsigned_integer.
>
> Sure there is. What we want is to share nearly all of the
> implementation details without providing exactly the same interface.
> You can do that with a common base class (that is neither integer
> nor unsigned_integer).
>
> Doug
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk