From -121498105126756411
X-Google-Thread: f78e5,1130da7a3640a78c
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 09 May 2006 11:30:40 -0500
Return-Path: <devnull@stump.algebra.com>
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-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@ucar.edu
From: kuyper@wizard.net
Newsgroups: comp.std.c++
Subject: Re: Deprecate the use of plain pointers as standard container iterators
Organization: http://groups.google.com
Message-ID: <1147191075.332852.261800@g10g2000cwb.googlegroups.com>
References: <1146830242.416436.272780@g10g2000cwb.googlegroups.com>
   <1146842605.957240.37860@i39g2000cwa.googlegroups.com>
   <1147087120.946744.158720@v46g2000cwv.googlegroups.com>
   <1147122934.938877.153140@g10g2000cwb.googlegroups.com>
   <1147172370.383985.216490@y43g2000cwc.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Complaints-To: groups-abuse@google.com
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 Firefox/1.0.7,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: g10g2000cwb.googlegroups.com; posting-host=65.242.71.114;
   posting-account=bPBxkgwAAABzUwlEAMy-xGlLqZFJ5Jz_
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Date: Tue,  9 May 2006 11:27:17 CST
Lines: 55
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-ibDPKprP72xghrQ3odY7w1ZxJIhtQaDCA3cr7dKb+1ts4YuetLf40IaEUl0ntUL1qMBLjWqFJqd2My0!TgQs0j8nY3f0Lxp1Y/Oh5B1Gf+CcQBsl3m3hA35oqByJjt7l269Hkrkrqkj/K8GK2Lb4IaGUYyvy!AUY13jTQDRAXKlMizgURehwbd1H1OZklO97NvjNPO0k=
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32
Xref: g2news2.google.com comp.std.c++:1856

Nicola Musatti wrote:
> kuyper@wizard.net wrote:
.
> > 3. The semantics that actually will be executed when your code calls
> > find(). If these are the semantics that are insufficiently specified,
> > it implies that you don't know enough about which overload of find()
> > will be called, to be sure that the semantics of that overload are
> > acceptable. If that's the case, you need to change the syntax of your
> > function call to ensure that only overloads that are actually
> > acceptable will be chosen. For instance, if std::find() provides the
> > semantics you're looking for, then call it by using std::find() rather
> > than find().
>
> This is the problem. I claim that knowing about argument dependent
> lookup, overload resolution in the presence of function template *and*
> the definition of the standard library interface should be enough for
> me to know exactly which overload of find() will be called in my code.
> The fact that it isn't is a most unfortunate circumstance that should
> be removed if at all possible.

Any function with the same name as a standard library template, whose
parameter types can make it compete with that template in overload
resolution for particular values of the template parameters, can cause
exactly the same problem, even in contexts that have nothing to do with
the iterator type of standard containers. Pointers to built-in types
are generic, the name "find" is generic - you're virtually guaranteed
to have overload resolution problems when you define such a function,
and that's the problem you're really demonstrating.

The only thing that the standard guarantees about standard container
iterator types are what operations they support. If you write code
whose correct behavior depends upon anything other than the fact that
those operations are supported, and do behave as specified by the
standard, then it's bad code. Writing code that depends upon the
iterator types not being pointers is just a special case of this
general rule. If plain pointers were prohibited as standard container
iterators, it would just change which special cases cause problems, it
wouldn't avoid them.

For example, prohibiting the use of plain pointers as standard
container iterators won't prevent find(v.begin(), v.end(), 2) from
picking up an alternative definition of find(); it would require a
different alternative definition of find() than the one you gave as an
example, but whatever iterator type an implementation choses for a
given container, a find() can be written which will be selected, over
std::find(), by overload resolution. If you don't want that overload
selected, either don't provide that alternative definition of find(),
or don't leave out the std:: qualifier that forces it to be ignored.

---
[ 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                      ]



