Boost logo

Boost :

From: Moore, Paul (paul.moore_at_[hidden])
Date: 2001-01-12 11:43:39

From: Jeremy Siek [mailto:jsiek_at_[hidden]]
> On Fri, 12 Jan 2001, Moore, Paul wrote:
> paul.m> Thanks for pointing this out. I won't use !! though (as
> paul.m> someone pointed out in a later post, the integer type may
> paul.m> not have operator! either). My initial preference is for
> paul.m> "while (m != 0)" - would that cause a problem (I think it
> paul.m> requires that the integer type be comparable with built-in
> paul.m> integers, hardly an unreasonable requirement)?
> Sorry, I think it is an unreasonable requirement. In my
> experience with MTL, I've run into lots of number types that
> are not comparable with built-in integers. Using
> "while (m != IntType())" is much better. Even better
> would be for boost to have some sort of number_traits
> class that defines one() and zero() functions.

OK, I take your point. Looking at the code, zero is used in a few places. I
can change that to IntType(). [Side note - I have to assume that a
default-constructed IntType is zero. This isn't necessarily true for
arbitrary types, so it becomes a requirement].

However, I also need access to 1. Specifically, "rational<T> r(t)" defaults
the denominator to 1. Also, operator>> uses 1, again as a default
denominator. Without a number_traits class such as you describe, I have to
assume that IntType(1) is a "one". Is this reasonable? Is it reasonable for
this to be reasonable, but for m != 0 to be unreasonable? The only thing I
can see is if conversion from int is explicit - is that what you have?

I think I'll assume that IntType(0) and IntType(1) are the zero and one for
IntType. The only reason for using IntType(0) rather than IntType() is a
sense that "explicit is better than implicit", and as I need IntType(1),
there's no point in *not* using IntType(0).

Does anyone have any alternative views on all this?


Boost list run by bdawes at, gregod at, cpdaniel at, john at