From -6330919865501899056
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,bb2cedb5166b3859
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-11-12 03:21:02 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: "Anthony Williams" <anthwil@nortelnetworks.com>
Newsgroups: comp.std.c++
Subject: Re: Typeof considered harmful (long)
Date: Mon, 12 Nov 2001 11:20:28 GMT
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <9so3n6$14m2on$1@ID-49767.news.dfncis.de>
References: <fTlH7.2855$c87.79835@ozemail.com.au>
X-Trace: mail2news.demon.co.uk 1005564034 mail2news:29692 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Orig-NNTP-Posting-Host: h96s2a160n47.user.nortelnetworks.com (47.160.2.96)
X-Orig-X-Trace: fu-berlin.de 1005556263 38472471 47.160.2.96 (16 [49767])
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700
Lines: 48
Xref: archiver1.google.com comp.std.c++:8131

"Brian Parker" <brianjparker@ozemail.com.au> wrote in message
news:fTlH7.2855$c87.79835@ozemail.com.au...
[snip]
> template<typename R, typename P1, typename P2, typename L>
> R func(P1 p1, P2 p2)
> {
>  L  local  = p1 * p2;
>
>  return local * p2;
> }

[snip]

> Proposed solution by extending C++  type deduction:
> The fundamental problem is that L and R in the above template function are
> essentially non-deduced contexts. A solution, then is to specify that
after
> function argument deduction, if function template parameters remain
> non-deduced and are not used as part of the function signature (excluding
> the return type), then the type is deduced to be that of the initializing
> expression (or more accurately, it is deduced by the same algorithm that a
> function parameter is deduced to match an initialising function argument).
>
> So, for example, L above will be deduced to be the type of the
initializing
> expression "p1 * p2", and R will be deduced as the type of the return
> expression "local * p2".

This would break existing template code, which allows L and R to be
non-deduced, and explicitly specified. This is a feature used in real code.

I agree that typeof() can be clumsy, but this is not a viable alternative.

Anthony
--
Anthony Williams
Software Engineer, Nortel Networks Optical Components Ltd
The opinions expressed in this message are not necessarily those of my
employer



---
[ 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.research.att.com/~austern/csc/faq.html                ]



