From 4473133512762236065
X-Google-Thread: f78e5,2a0144bbf1d6a893
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!nntp.abs.net!news-FFM2.ecrc.net!newsfeed.vmunix.org!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: ben-public-nospam@decadentplace.org.uk (Ben Hutchings)
Newsgroups: comp.std.c++
Subject: Re: Proposal: Allow member typedefs to be used in return types without qualification
Date: Mon, 25 Apr 2005 01:21:27 GMT
Lines: 59
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <slrnd6fodt.15i.ben-public-nospam@decadentplace.org.uk>
References: <d43gf6$avo$1@newsreader.wustl.edu>
NNTP-Posting-Host: news.news.demon.net
X-Trace: news.demon.co.uk 1114392108 1055 158.152.254.254 (25 Apr 2005 01:21:48 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Mon, 25 Apr 2005 01:21:48 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: slrn/0.9.7.4 (Linux)
X-Orig-X-Trace: individual.net 4CiCr1VzDZPyHApzNSb8/gflaNBV4SJaTTwbUkbqWTpB6BTZ8=
X-Virus-Scanned: by amavisd-new at cs.mu.OZ.AU
X-Reply-To: Ben Hutchings <ben@decadentplace.org.uk>
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id j3P1LRUM018118;
	Mon, 25 Apr 2005 11:21:27 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Orig-Path: decadentplace.org.uk!nobody
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:4579

"James Aguilar" wrote:
> Currently, when writing a member function in a class definition,
> typedefs that the programmer makes in the class allow member
> typedefs to be used as a return type, thus:
> 
> class Example
> {
> public:
>   typedef bool result_type;
>   typedef int input_type;
> 
>   result_type operator ()(input_type in1, input_type in2)
>   {
>     return in1 < in2;
>   }
> };

Yes, because the member type is in scope at the beginning of the
member function declaration.

> However, when defining a member function outside of the class in which it is 
> declared, it looks more like this:
> 
> Example::result_type Example::operator ()(input_type in1, input_type in2)
> {
>   return in1 < in2;
> }
>
> and
> 
> result_type Example::operator ()(input_type in1, input_type in2)
> {
>   return in1 < in2;
> }
> 
> is illegal.  This should not be.  If the parameter types can be
> assumed to be members of the containing class, so should return
> types.
<snip>

Perhaps they should, but the return type has to be parsed before the
member function name can be parsed and its scope determined.  In your
example this doesn't require the name to be looked-up immediately, but
general it is impossible to parse the return type without knowing what
scope names should be looked-up in.  In some circumstances it would be
necessary to resort to disambiguating keywords, as in template
definitions.  Why add further complexity to the declaration rules for
so little gain?

-- 
Ben Hutchings
Larkinson's Law: All laws are basically false.

---
[ 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.jamesd.demon.co.uk/csc/faq.html                       ]



