Boost logo

Boost :

From: Robert Kawulak (kawulak_at_[hidden])
Date: 2006-01-17 07:34:29


Hi,

> From: Vladislav Lazarenko
>
> Is there any library to do thing like this more easily?
>
> [code]
>
> int x = -10;
> int rating = std::max(std::min(x, 5), 0);
>
> [/code]
>

Not yet, but I'm working (slowly, I admit :P) on a constrained
types library. With this library it would be as easy as:

saturating_int<int, 0, 5>::type rating;
rating = -10; // clips the value to 0
rating = 10; // clips the value to 5

Recently I've found some time to continue working on the library
and am writing the documentation, but I can't tell whether and
when the library will be accepted as a Boost library. This can
take some time since there's still some work to do. Therefore if
you need the feature urgently you shouldn't count on soon
availability of the library.

Best regards,
Robert


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