On Tue, 24 Aug 2010 17:43:49 -0500, Andrej Mitrovic
<andrej.mitrov...@whatever.com> wrote:
I wasn't refering to the mixin, but the call to CheckedInt(). mixin
compiles "value" ~ op ~ "rhs.value", which in this case evaluates to 5 +
5 and the whole call becomes CheckedInt(10).
Sorry. My mistake, I probably misread.
What I don't understand is how you can construct a new CheckedInt struct
by calling it with CheckedInt(10), when I have to use a call like
CheckedInt!(int)(10) outside the struct (in main or in a unittest block).
This, I don't know. Maybe when you are inside the struct's body the
compiler somehow
can infer the type when CheckedInt is instantiated. Or maybe it does some
kind of
automatic alias (alias CheckedInt!10 CheckedInt).
Outside of the struct's body, as there aren't template default values, is
not possible
to infer the type of CheckedInt. Maybe someone with more experience on
templates can give
you a better (or correct, I'm just guessing this :) ) answer.
--
Yao G.