Resource Management... Howto?

Deewiant deewiant.doesnotlike.spam at gmail.com
Sat Jul 7 07:48:35 PDT 2007


downs wrote:
> hidden hide(Object ptr) { return cast(hidden)((cast(size_t)cast(void*)ptr)^0); } /// xor with 0 equals negation

Xor with 0? That's a no-op:

version (Tango) import tango.stdc.stdio;

void main() {
	printf("%d\n", 0 ^ 0);
	printf("%d\n", 1 ^ 0);
	printf("%d\n", (-1) ^ 0);
	printf("%d\n", 2 ^ 0);
	printf("%d\n", (-2) ^ 0);
	printf("%d\n", 1000 ^ 0);
	printf("%d\n", (-1000) ^ 0);
}

If you want bitwise negation, use the ~ unary operator.

-- 
Remove ".doesnotlike.spam" from the mail address.


More information about the Digitalmars-d-learn mailing list