safer casts - take II

BCS ao at pathlink.com
Tue May 13 13:26:53 PDT 2008


Reply to terranium,

> BCS Wrote:
> 
>> I'm not seeing it, example please?
>> 
> void foo(T arg)
> {
> auto handle=myhashtable[arg.classinfo];
> //handle can be data or delegate for increased functionality
> }

Where would the table be set up? for delegates to work you would need to 
set up the table every time the function is called (to get the context pointer 
right). The next best thing would be something like this:

switch(myhashtable[arg.classinfo])
{
  case ClassEnum: ...
}


but then we might as well let switch take a classinfo struct and avoid the 
enum. But that looks just plain ugly.





More information about the Digitalmars-d mailing list