>From: "Eric Woodruff" <[EMAIL PROTECTED]> > "Johan Nilsson" <[EMAIL PROTECTED]> wrote in message > at76e1$2ro$[EMAIL PROTECTED]">news:at76e1$2ro$[EMAIL PROTECTED]... > > Anyhow, in my opinion, dynamic_void_cast is completely unnecessary and takes > casts away the intent that it is _supposed_ to be a two step and very ugly > process--the signifier that you have a not-so-good design on your hands. > Stop trying to code a new messenger.
As Bjarne Stroustrup says in D&E, "Don't fight the type system." You can't win. :) Casting does indeed tend to be fighting the type system. Sure, you can do it, but you may end up with switch-on-type code, etc., which, as he said that some had said it, "has the elegance of C, combined with the efficiency of Smalltalk." :) And even that was too nice, he said. I understand you (Johan) want to be able to have generic factories, but then erasing the type is probably not the way to go, and as has been pointed out in this thread, void * is type erasure. More or less the only safe thing you can do with it, is to delete it. You can also cast it back to its original type, but that requires that you know that type to begin with. It doesn't, portably, have the possibility to cast to arbitrary type, as you've seen. As you said it, even COM doesn't use void *, but IUnknown and QueryInterface. Regards, Terje _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost