Boost logo

Boost Users :

From: Peng Yu (pengyu.ut_at_[hidden])
Date: 2007-10-13 15:42:06


On 10/13/07, John Maddock <john_at_[hidden]> wrote:
> Peng Yu wrote:
> > Hi,
> >
> > Suppose I define a class fixed_point as
> >
> > class fixed_point{
> > ....some operations are defined here
> >
> > private:
> > int _integer_part;
> > unsigned _fractional_part
> > }
> >
> > I want is_arithmetic<fixed_point>::type to be true_
>
> The aim of is_arithmetic is that it returns true only for built-in
> arithmetic types: in other words it's a type introspection tool. If you
> specialise it for UDT's you will very likely break other code (for example
> has_trivial_XXX assumes that all arithmetic types have trivial
> construct/asign/copy/destroy operations). Probably the correct traits to be
> specialising (and using to detect "numbers") is std::numeric_limits.

Unfortunately, there are not types that contain constants in
std::numeric_limits as in the boost type_traits library. If I want do
metaprogramming based the types, I can not used numeric_limits. You
have a point that specialize is_arithmetic might break other code. But
are there any other walk around for this problem of adding user
defined types?

Thanks,
Peng


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net