Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2003-07-23 16:42:55


Daniel Spangenberg wrote:
> template <int Precision, int Range = -1>
> class selected_real;

> template <int Range>
> class selected_int;

> typedef selected_int<9> MyInt;

Those class templates may be of use for some people.
However, until we get typedef templates into the C++
core language, there appears to be no way to defer
the implementation of the type to, say, a plain "int".

This can be fixed by making the selected_XXX classes
template metafunctions that happen to return the correct
type. Usage: typedef selected<int>(9)::type MyInt .

Compare that with boost/integer.hpp where we have
 uint_t<N>::least and uint_t<N>::fast .

Of course, if you compile on a platform that can't
fulfill your precision/range desires, you should get a
compile-time error.

namespace boost::numeric is your friend.

Jens Maurer


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