Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2001-08-24 15:02:22


> > > Would there be some need for seminumerical functions?
> > > Would this solution be better than
> > > an implicit conversion to bool for unlimited integer?
> >
> > I think it's a better solution. I also think there's a place for
> > numeric/integer traits which would support generic numeric/integer
> > algorithms.
> >
>
> Can yo be a bit more specific what kind of traits you
> are thinking of?

I don't mean just type properties (e.g., is_bounded/is_signed), but also
type methods (int_traits is a namespace):
  int_traits::is_zero(x) -- returns true if x == 0
  int_traits::is_positive(x) -- returns true if x >= 0
  int_traits::is_odd(x) -- returns true if (x % 2) == 1

These 'traits' will just allow generic numeric algorithms to be more
efficient -- you can write one 'gcd' algorithm that works for all integral
types that support int_traits. 'gcd' would use is_zero; 'pow' would use
is_odd; etc.

I've thought briefly about this before, but never really developed the idea.
It would be interesting to see where it goes!

        -Steve


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