Enum that can be 0 or null

tsbockman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 20 15:10:51 PDT 2016


On Friday, 20 May 2016 at 13:39:50 UTC, Alex Parrill wrote:
> (How) can I make a constant that is either zero or null 
> depending on how it is used?

In the general case, I don't think this is possible in D 
currently. (It will become possible if the proposed "multiple 
alias this" ever gets implemented, though: 
http://wiki.dlang.org/DIP66 )

However, various workarounds are possible depending on the 
context.

> Anyone have an idea on how to make this work?

Why do you need to?

Just use null for pointer types, and 0 for integers. D is not C; 
you aren't *supposed* to be able to just copy-paste any random C 
snippet into D and expect it to work without modification.

If that's not a satisfactory answer, please show some specific 
examples of code that you don't know how to make work without 
VK_NULL_HANDLE so that I can propose a workaround.


More information about the Digitalmars-d-learn mailing list