Casting ulong to int with @nogc

Kagamin spam at here.lot
Thu Jul 29 14:22:52 UTC 2021


I use this:

int ToInt(in ulong u) pure
{
	assert(u<=int.max);
	return cast(int)u;
}
int Count(E)(in E[] arr) pure
{
	return ToInt(arr.length);
}

Well, it depends if you're fine with just an assert.


More information about the Digitalmars-d mailing list