Article View: comp.std.c++
Article #1943Re: Extended typeinfo (was- dyn
From: mfinney
Date: Sun, 10 Sep 1995 02:28
Date: Sun, 10 Sep 1995 02:28
31 lines
1931 bytes
1931 bytes
In <MATT.95Sep9122342@physics10.Berkeley.EDU>, jason@cygnus.com (Jason Merrill) writes: >Hmm? What about > >if (Derived *p = dynamic_cast<Derived*>(possible_derived)) That is the approach I would take if the full capability is not available. This does not handle all of the cases of interest, however. It only handles the case of an object relative to a known class. It does not handle the case of two objects, nor the case of two class names. It also does not handle the case where you have references to two type_info instances. The problem is that the above approach uses the side effect of dynamic_cast<> returning a null pointer if the case fails. This only works where you have an object to be casted, and further the cast itself requires a know type. It will, however, handle many cases of interest and is an excellent approach. The only difference is that I would encasulate the test inside of an inline operator defintion, because I don't really WANT the case, I want the information about the inheritance dag. Michael Lee Finney [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<42sr3k$dg3@mujibur.inmind.com>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<n1401567773.54923@taligent.com> <42rf97$p8h@mujibur.inmind.com> <MATT.95Sep9122342@physics10.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: mfinney@inmind.com Newsgroups: comp.std.c++ Subject: Re: Extended typeinfo (was- dyn Date: 10 Sep 1995 02:28:28 GMT Organization: In Mind, Inc. Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <42sr3k$dg3@mujibur.inmind.com> References: <n1401567773.54923@taligent.com> <42rf97$p8h@mujibur.inmind.com> <MATT.95Sep9122342@physics10.Berkeley.EDU> Reply-To: mfinney@inmind.com NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: finneyman.inmind.com X-Newsreader: IBM NewsReader/2 v1.2 Content-Length: 1051 Originator: clamage@taumet