Boost logo

Boost :

From: Robert Kawulak (kawulak_at_[hidden])
Date: 2005-09-25 15:08:32

Hi group,
> Some time ago I've written a set of class templates for
> bounded types (types
> whose variables may hold a value only from within a specified
> range).

Just today I've discovered, that basic_bounded class template is even more
flexible than I thought! :-) It may be used for types holding their values
not only within a specified range, but virtually any set (or, in other
words, values conforming to any criterion). For instance a policy template
may be written very easily for even numbers only. When it's used as
basic_bounded's policy parameter, the new type will only accept even values:


template<typename T>
struct even_policy; // implementation not included for conciseness

typedef basic_bounded< even_policy<int> > even_int;
even_int i;

i = 2; // OK
i = 3; // illegal
i += 2; // OK
i += 3; // illegal
i++; // illegal, might even generate a compiler error


Therefore I think that this flexibility should be reflected in the name of
the basic_bounded template as well as the library in general. Maybe it
should be something like 'restricted' meaning that the types may hold only
values restricted by some constraint? Or maybe 'constrained'? Could some
native english speaker write which he thinks is the most appropriate name?

The rest of the library doesn't need any significant changes, only more
policies which seem to be useful may be added (like odd, even, etc.).

Best regards,

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