Add support implicit conversion between types
ilya-stromberg
ilya-stromberg-2009 at yandex.ru
Fri Sep 6 10:25:21 PDT 2013
On Friday, 6 September 2013 at 17:15:03 UTC, H. S. Teoh wrote:
> Hmm, could this be a possible (though somewhat ugly) workaround?
>
> foreach (T; IntegralTypeList)
> {
> assert(factorial(to!T(3) == 6));
> }
>
> AFAIK, if T==int, then std.conv.to should simply alias itself
> away. And
> it *should* be able to handle ctors that take the requisite
> type, I
> think.
I use:
foreach (T; IntegralTypeList)
{
assert(factorial(cast(T)3) == 6));
}
I works, but looks a little strange.
I belive that compiler should optimise this (do nothing), but I
am not sure.
More information about the Digitalmars-d
mailing list