struct opEquals

SiegeLord none at none.com
Wed Mar 9 08:40:25 PST 2011


1) Why does this code not work (dmd 2.051) and how do I fix it:

struct S
{
	static S New()
	{
		S s;
		return s;
	}
	
	const bool opEquals(ref const(S) s)
	{
		return true;
	}
}

void main()
{
	S s;
	assert(s == S.New);
}

2) Why is the type of struct opEquals have to be const bool opEquals(ref const(T) s)? Why is it even enforced to be anything in particular (it's not like there's an Object or something to inherit from)?

-SiegeLord


More information about the Digitalmars-d-learn mailing list