Topic: functional cast notation (was Defect: Missing fundamental
Author: AlbertoBarbati@libero.it (Alberto Ganesh Barbati)
Date: Tue, 20 Jun 2006 15:09:47 GMT Raw View
David Abrahams ha scritto:
> AlbertoBarbati@libero.it (Alberto Ganesh Barbati) writes:
>
>> Is there something we could do to fix
>> the situation (in case there someone else that agree with me that
>> the current definition is kind of "wrong")?
>
> You know, bring proposals to the standard committee.
The only thing that comes to my mind is to introduce #pragma notations
as C does, for example:
#pragma STDCPP FUNCTIONAL_CAST_IS_STATIC [on/off]
Such approach might also be considered as a general framework for
enforcing minor (but possibly breaking) behaviour changes, such as
disallowing the deprecated string literal to non-const char* conversion.
>> For example that could
>> be achieved by deprecating (without removing) the
>> reinterpret_cast-ness of the idiom, thus allowing compiler vendors
>> to issue a warning without breaking existing code.
>
> Compiler vendors are allowed to issue any warnings they like without
> deprecations.
>
Yes, but sometimes an official encouragement can be useful ;)
Ganesh
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: tannhauser86549spam@free.fr (=?ISO-8859-1?Q?Falk_Tannh=E4user?=)
Date: Fri, 23 Jun 2006 20:09:27 GMT Raw View
Alberto Ganesh Barbati wrote:
> In fact I always wondered why function style casts are defined that way.
> In practice 5.2.3 says that
>
> int(expr)
>
> is equivalent to
>
> (int)(expr)
>
> According to the least astonishing principle, it should have been
> equivalent to
>
> static_cast<int>(expr)
>
> instead... With this definition, int("hello") would be ill-formed. Do
> you know the rationale why the standard has defined function-style casts
> that way?
Certainly historical reasons - function style casts (as a means of
generalizing conversion constructor calls) appeared in C++ prior
to new-style casts.
Falk
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]