On Tue, 12 Oct 2010 05:30:27 +0400, Philippe Sigaud <philippe.sig...@gmail.com> wrote:

2010/10/11 Adam D. Ruppe <destructiona...@gmail.com>:

For future direction, I don't think the Type argument is actually needed to the
Bounded struct. It could determine it from the bounds.

So Bounded!(0, 255) it knows could be a ubyte, but Bounded!('A', 'Z') is a char.

Maybe the type param can be moved to the end, as an optional parameter. In most
cases, it should be able to figure it out on its own.


Good point. That'd make for cleaner code, but there are cases where
you want to specify the underlying/implicit cast type, such as
int/uint or int/short/byte.

That could be as simple as:

struct Bounded(A min, A max, T = A) { ... }

Bounded!(0, 1) zeroOrOne;               // 4 bytes because of default int
Bounded!(0, 1, ubyte) zeroOrOne;  // 1 byte, specified explicitly

Reply via email to