why ushort alias casted to int?

crimaniak crimaniak at gmail.com
Fri Dec 22 10:14:48 UTC 2017


My code:

alias MemSize = ushort;

struct MemRegion
{
	MemSize start;
	MemSize length;
	@property MemSize end() const { return start+length; }
}

Error: cannot implicitly convert expression `cast(int)this.start 
+ cast(int)this.length` of type `int` to `ushort`

Both operands are the same type, so as I understand casting to 
longest type is not needed at all, and longest type here is 
ushort in any case. What am I doing wrong?


More information about the Digitalmars-d-learn mailing list