🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2285

Re: dynamic_cast<T> implementation...

#2285
From: Alex Martelli
Date: Mon, 23 Oct 1995 17:41
37 lines
1695 bytes
Michael Cook <mcook@cognex.com> writes:
	...
>What if I use `dynamic_cast' where `static_cast' would be sufficient?  Is the

Yes, I think this holds in general.

>type /still/ required to be polymorphic?  For example, given this:

> struct B {};
> struct D : B {};
> D* d;

>is this expression valid?

> dynamic_cast<B*>(d)

This surely is.  Draft standard 5.2.6 explains the semantic of
dynamic_cast<T>(v), and sub 5 it gives the possibility...:

5. If T is "pointer to cv1 B" and v has type "pointer to cv2 D" such that
   B is a base class of D, the result is a pointer to the unique  B  sub-
   object of the D object pointed to by v. 



Alex
--
DISCLAIMER: these are TOTALLY personal opinions and viewpoints, NOT connected
in any way with my employer, nor any other organization or individual!
Email: martelli@cadlab.it                            Phone: +39 (51) 597313
CAD.LAB s.p.a., v. Ronzani 7/29, Casalecchio, Italia   Fax: +39 (51) 597120

---
[ 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: <martelli.814443165@cadlab>
Path: arc1-ca.pugleaf.net!128.32.155.1!matt
References: <9510191610.ZM21213@yosemite.eai.com> <u9hh141x8p.fsf@yorick.cygnus.com> <r4rb05s7jj.fsf@pluto.cognex.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt
From: martelli@cadlab.cadlab.it (Alex Martelli)
Newsgroups: comp.std.c++
Subject: Re: dynamic_cast<T> implementation...
Date: 23 Oct 1995 17:41:34 GMT
Organization: Cad.Lab Spa, Bologna, Italia
Approved: matt@physics2.Berkeley.EDU (Matt Austern)
Message-ID: <martelli.814443165@cadlab>
References: <9510191610.ZM21213@yosemite.eai.com>  <u9hh141x8p.fsf@yorick.cygnus.com> <r4rb05s7jj.fsf@pluto.cognex.com>
NNTP-Posting-Host: physics2.berkeley.edu