Consider the following program:
class A(uint N) {}
void foo(uint N)(A!N) {}
void main()
{
auto a = new A!1; // compiles
foo(new A!1); // error
foo(new A!1u); // compiles
foo(cast(A!1u)
That's because implicit casts in D are much more strict, then those in C/C++.
Such seemingly intuitive cats, e.g. from long to int are not performed
due to potential loss of data.
Casting from int to uint has the same effect of potential loss of data.
Probably, the compile-time versions of those
On Friday, October 21, 2011 11:57:50 Gor Gyolchanyan wrote:
That's because implicit casts in D are much more strict, then those in
C/C++. Such seemingly intuitive cats, e.g. from long to int are not
performed due to potential loss of data.
Casting from int to uint has the same effect of
Unlike long - int conversions, signed - unsigned conversions are
narrowing in both ways.
If anything, those conversions should be even more strict.
On another note, i had this thought about fundamental types.
What i thought about is, making fundamental types a library solution.
What? Are you out
On 21.10.2011 02:31, Tobias Brandt wrote:
Consider the following program:
class A(uint N) {}
void foo(uint N)(A!N) {}
void main()
{
auto a = new A!1; // compiles
foo(new A!1); // error
foo(new A!1u);
On 21 October 2011 10:01, Jonathan M Davis jmdavisp...@gmx.com wrote:
On Friday, October 21, 2011 11:57:50 Gor Gyolchanyan wrote:
That's because implicit casts in D are much more strict, then those in
C/C++. Such seemingly intuitive cats, e.g. from long to int are not
performed due to
On Friday, October 21, 2011 12:20:02 Tobias Brandt wrote:
On 21 October 2011 10:01, Jonathan M Davis jmdavisp...@gmx.com wrote:
On Friday, October 21, 2011 11:57:50 Gor Gyolchanyan wrote:
That's because implicit casts in D are much more strict, then those in
C/C++. Such seemingly intuitive
On 10/21/11 12:20 PM, Tobias Brandt wrote:
Obviously, the conversion does happen implicitly, otherwise
'new A!1' wouldn't compile (A expects a uint as parameter).
But then, why are A!1 and A!1u different types?
Because of a compiler bug, and contrary to the other answers, implicit
conversion
2011/10/21 Don nos...@nospam.com:
On 21.10.2011 02:31, Tobias Brandt wrote:
Consider the following program:
class A(uint N) {}
void foo(uint N)(A!N) {}
void main()
{
auto a = new A!1; // compiles
foo(new A!1); //