From -570981591479844712
X-Google-Thread: f78e5,8b7617618a67f610
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.stueberl.de!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: AlbertoBarbati@libero.it (Alberto Ganesh Barbati)
Newsgroups: comp.std.c++
Subject: functional cast notation (was Re: Defect: Missing fundamental feature!)
Date: Sun, 18 Jun 2006 17:32:08 GMT
Organization: [Infostrada]
Lines: 37
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <TAdlg.6091$zy5.145144@twister1.libero.it>
References: <Xns97E4A9B1CFB86fgothamNOSPAM@194.125.133.14>	<1150485390.906845.45740@y41g2000cwy.googlegroups.com> <u1wto5ala.fsf@boost-consulting.com>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: news.demon.co.uk 1150651934 9286 158.152.254.254 (18 Jun 2006 17:32:14 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sun, 18 Jun 2006 17:32:14 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Mozilla Thunderbird 1.5.0.4 (Windows/20060516)
X-Scanned: with antispam and antivirus automated system at libero.it
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
X-Path: comp-std-cpp-robomod!not-for-mail
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id k5IHW8g4025088;
	Mon, 19 Jun 2006 03:32:08 +1000 (EST)
X-NNTP-Posting-Date: Sun, 18 Jun 2006 16:39:47 MET DST
X-Delivered-To: std-c++@mailman.ucar.edu
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
Xref: g2news2.google.com comp.std.c++:2408

David Abrahams ha scritto:
>     class Foo {};
> 
>     Foo x = Foo("hello"); // error, as desired
>     int x = int("hello"); // no error
> 

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? 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")? 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.

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                      ]



