Article View: comp.std.c++
Article #1925Re: Add dynamic_cast<type_info&>
From: Steve Clamage
Date: Thu, 07 Sep 1995 22:54
Date: Thu, 07 Sep 1995 22:54
28 lines
1719 bytes
1719 bytes
In article AA20283@ird.scitex.com, Etay_Bogner@mail.stil.scitex.com (Etay Bogner) writes: > >Yes, what I ment was 'dynamic_cast<bar>(foo)' where 'bar' is a 'const >type_info&'. > > ... > >My suggestion is that if the compiler encounters an expression like : > >'dynamic_cast<ATypeInfo>(p)' were ATypeInfo is a 'const type_info&' > >the compiler won't try to cast p to ATypeInfo, which will ALWAYS fail, but >it will try to cast p to the type ATypeInfo contains data for. I don't see what problem you are trying to solve. The expression typeid(p) returns a 'const type_info&'. If given a pointer to a polymorphic type, it returns the type of the actual object; otherwise it returns the static type of the expression. What programs are made simpler by giving special- case semantics to dynamic_cast instead of just writing 'typeid', which seems to be what you want anyway? --- Steve Clamage, stephen.clamage@eng.sun.com [ 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:
<42nsuv$bqf@engnews2.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<9509072134.AA20283@ird.scitex.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: clamage@Eng.sun.com (Steve Clamage) Newsgroups: comp.std.c++ Subject: Re: Add dynamic_cast<type_info&> Date: 7 Sep 1995 22:54:34 GMT Organization: Sun Microsystems Inc. Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <42nsuv$bqf@engnews2.Eng.Sun.COM> References: <9509072134.AA20283@ird.scitex.com> Reply-To: clamage@Eng NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: taumet.eng.sun.com Content-Length: 923 X-Lines: 24 Originator: clamage@taumet