On Mon, 06 Jul 2009 14:28:38 +0400, Walter Bright
<[email protected]> wrote:

Denis Koroskin wrote:
auto x = p1 - p2;

What's the type of x?
 ptrdiff_t, signed counterpart of size_t

Do you really want an error if you go:

size_t y = p1 - p2;

?


Of course, what sense does it make when p2 > p1?

I'd put an assert and made a cast explicit, if a size_t is so badly needed for ptr difference:

assert(p1 >= p2);
size_t y = cast(size_t)p1 - p2;

Reply via email to