convert interger to pointer

Moritz Warning moritzwarning at web.de
Sat Jun 28 18:35:03 PDT 2008


Hello,

I wrote a container that relies on treating two different values in a 
special way (they are used as some kind of flag).
For a container of integers, I just use 0 and 1 as special elements.
Those special entries are for internal use only.

The problem comes when I extend the container for reference types.
Instead of 0 I use null, but for 1 the trouble begins.

Is it possible to circumvent the type system and convert an integer to a 
pointer or class type? They won't ever be dereferenced, of course.

Many would probably think that this is the wrong way anyway,
but I try to avoid memory usage that way and to increase speed.

Introducing special workarounds also make the code more complicated.



More information about the Digitalmars-d mailing list