Enum that can be 0 or null

ParticlePeter via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 6 21:31:56 PDT 2016


On Monday, 6 June 2016 at 20:32:23 UTC, Alex Parrill wrote:
> They'd be the same type, since you would define the vulkan 
> functions to take these structures instead of pointer or 
> integer types.
>
> It relies on a lot of assumptions about the ABI that make a raw 
> pointer work the same as a structure containing just one 
> pointer, which is why I did not give it much consideration.

Is there a way to use opCast (just an idea, not working code) ?

private struct VK_HANDLE_HELPER {
	const void * handle = null;
	alias handle this;
	T opCast(T)() if( is( T == uint64_t )) {
		return 0uL;
	}
}
const VK_NULL_HANDLE = VK_HANDLE_HELPER();



More information about the Digitalmars-d-learn mailing list