comparing nullables

Alex sascha.orlov at gmail.com
Fri Jun 15 15:00:38 UTC 2018


Hi all,
do you see any valid reason why the last line yields an error:

import std.typecons;
void main()
{
	void* ptr1;
	void* ptr2;

	assert(ptr1 is null);
	assert(ptr2 is null);
	assert(ptr1 == ptr2);

	Nullable!uint val1;
	Nullable!uint val2;
	assert(val1.isNull);
	assert(val2.isNull);
	assert(val1 == val2);

	Nullable!(uint, uint.max) val3;
	Nullable!(uint, uint.max) val4;
	assert(val3.isNull);
	assert(val4.isNull);
	assert(val3 == val4);
}

The error is
core.exception.AssertError@/usr/local/opt/dmd/include/dlang/dmd/std/typecons.d(3457): Called `get' on null Nullable!(uint,nullValue).

As I can see, this is due the lack of opEquals in the Nullable(T, 
T nullValue), in contrast to Nullable(T).


More information about the Digitalmars-d-learn mailing list