"Terje Slettebų" <[EMAIL PROTECTED]> wrote in message 082701c2a12f$15c74170$60fb5dd5@pc">news:082701c2a12f$15c74170$60fb5dd5@pc... > >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.
I just found a thread called "more flexible any" in the ASPN archives, that at a first glance looks like something I could use. However I couldn't compile it under VC.NET. The post was a few months old, don't know what's happened since that. > > As you said it, even COM doesn't use void *, but IUnknown and > QueryInterface. > Well, all COM objects are required to implement IUnknown (which helps :) // Johan _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost