Topic: Constructor call cast syntax
Author: Marc Sherman <msherman@mag1.magmacom.com>
Date: 1996/09/30 Raw View
Looking through the April '95 DWP, I've come accross an interpretation
that I'm unsure of regarding casting using the constructor syntax:
Section 5.2.3.1 [expr.type.conv]
... If the expression list specifies a single value, the expression
is equivalent ... to the corresponding cast expression (expr.cast).
Section 5.4.4 [expr.cast]
... The conversions performed by static_cast, reinterpret_cast, const_cast,
or any sequence thereof, can be performed using the cast notation of
explicit type conversion.
Does this mean that an expression type(val) can result in a
dynamic_cast<type>(val)? I'd thought that static_cast was the only
type of cast allowed by this syntax.
--
Marc Sherman | "What? Rhesus Peasus? | work mailto:marcsh@corel.ca
CorelDRAW! | Latin. Must be Latin." | personal mailto:msherman@magmacom.com
for Macintosh | - Edward Ka-Spel, LPD | http://www2.magmacom.com/~msherman/
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: clamage@taumet.eng.sun.com (Steve Clamage)
Date: 1996/09/30 Raw View
In article MAA12400@mag1.magmacom.com, Marc Sherman <msherman@mag1.magmacom.com> writes:
>Looking through the April '95 DWP, I've come accross an interpretation
>that I'm unsure of regarding casting using the constructor syntax:
>
>Section 5.2.3.1 [expr.type.conv]
>.... If the expression list specifies a single value, the expression
>is equivalent ... to the corresponding cast expression (expr.cast).
>
>Section 5.4.4 [expr.cast]
>.... The conversions performed by static_cast, reinterpret_cast, const_cast,
>or any sequence thereof, can be performed using the cast notation of
>explicit type conversion.
>
>Does this mean that an expression type(val) can result in a
>dynamic_cast<type>(val)?
No. You will notice that dynamic_cast is not listed. Dynamic_cast is
a new kind of cast, not equivalent to anything that existed before.
Old cast notation cannot invoke a dynamic_cast. (Dynamic_cast and
static_cast have some overlap. The dynamic_cast operations that cannot
be done as a static_cast cannot be invoked by an old-style cast.)
> I'd thought that static_cast was the only
>type of cast allowed by this syntax.
No. The static_cast, reinterpret_cast, and const_cast are specializations
of the old-style cast, with a little bit of overlap. The draft explains
in detail what an old-style cast means in terms of the new casts. The
wording in the latest draft has been tightened up from the April 1995
wording, but is not substantially different.
---
Steve Clamage, stephen.clamage@eng.sun.com
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]