Article View: comp.std.c++
Article #431Re: Casting within MI Graphs
From: Scott Meyers
Date: Mon, 27 Aug 1990 19:23
Date: Mon, 27 Aug 1990 19:23
22 lines
1777 bytes
1777 bytes
In article <CLINE.90Aug27124642@cheetah.ece.clarkson.edu> cline@sun.soe.clarkson.edu (Marshall Cline) writes: | In article <48168@brunix.UUCP> sdm@cs.brown.edu (Scott Meyers) writes: | > Does E&S prohibit explicit casts from pointers to virtual base classes to | > pointers to derived classes? | | Yes, these casts, even though explicit, are illegal. The July issue of | The C++ Report contains a C++ Puzzle solution showing why. Basically | there is no way of knowing at compile time how to perform the cast. The | cover article in the same issue shows a portable method of faking the | cast. The method requires maintaining run-time type information. Do you have a reference for where in E&S they are declared illegal? As I said, I found such a prohibition only in the commentary. Unfortunately, I don't have access to the C++ Report, but the commentary of E&S outlines an implementation for virtual base classes that makes it impossible to do downward casts such as I described, and I suspect this is the implementation discussed in the C++ Report. As the discussion in E&S implies, there are alternative implementations for virtual bases that allow for well-defined downward casts, but they require more memory per object. Scott
Technical Details
Message-ID:
<48362@brunix.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!zaphod.mps.ohio-state.edu!wuarchive!uunet!brunix!sdmReferences:
<48168@brunix.UUCP> <CLINE.90Aug27124642@cheetah.ece.clarkson.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!zaphod.mps.ohio-state.edu!wuarchive!uunet!brunix!sdm From: sdm@cs.brown.edu (Scott Meyers) Newsgroups: comp.std.c++ Subject: Re: Casting within MI Graphs Message-ID: <48362@brunix.UUCP> Date: 27 Aug 90 19:23:50 GMT References: <48168@brunix.UUCP> <CLINE.90Aug27124642@cheetah.ece.clarkson.edu> Sender: news@brunix.UUCP Reply-To: sdm@cs.brown.edu (Scott Meyers) Organization: Brown University Department of Computer Science Lines: 22