struct opCast to void* and back

Nrgyzer nrgyzer at gmail.com
Sun Apr 11 02:46:14 PDT 2010


Hello everyone,

how can I cast a struct to void* and back to my struct? I have the following struct:

struct myStruct {

	char[] structName;

	public char[] toString() {
		return structName;
	}

	void* opCast() {
		return &this;
	}
	
}

myStruct test = myStruct(); // ok
test.structName = "Example struct"; // ok
void* temp = cast(void*) test; // ok
writefln(cast(myStruct) temp); // failed


Thanks for solutions & help :).



More information about the Digitalmars-d mailing list