220 15307 <CAFk2RUaekvNJLQrTtba5vHycwgf6w82NzJj76hk4nKt1ZWjpGA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Ville Voutilainen <ville.voutilainen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Isn't it time we had the bool
 std::[container]::contains() family of methods?
Date: Thu, 25 Dec 2014 21:18:09 +0200
Lines: 114
Approved: news@gmane.org
Message-ID: <CAFk2RUaekvNJLQrTtba5vHycwgf6w82NzJj76hk4nKt1ZWjpGA@mail.gmail.com>
References: <0959f2f8-acdd-4786-b6f3-0f05c62dcee6@isocpp.org>
	<1fbcb132-f6ca-4dbf-b5ef-f114447faf8c@isocpp.org>
	<b64f874c-473a-4b58-9553-609c95c601c2@isocpp.org>
	<CAFk2RUb=AB7-NUfyKhFQm43adqcGZW7xp+1wutpEY5t4H5uDPw@mail.gmail.com>
	<a8d7672f-27e5-49ea-83e2-f52c6963ff31@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1419535096 13095 80.91.229.3 (25 Dec 2014 19:18:16 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 25 Dec 2014 19:18:16 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5JHI7A7ALRB4WF6GSAKGQEDKHQOAQ@isocpp.org Thu Dec 25 20:18:11 2014
Return-path: <std-proposals+bncBC5JHI7A7ALRB4WF6GSAKGQEDKHQOAQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qa0-f72.google.com ([209.85.216.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRB4WF6GSAKGQEDKHQOAQ@isocpp.org>)
	id 1Y4DvH-00085F-FZ
	for gclcip-std-proposals@m.gmane.org; Thu, 25 Dec 2014 20:18:11 +0100
Original-Received: by mail-qa0-f72.google.com with SMTP id n8sf17277682qaq.7
        for <gclcip-std-proposals@m.gmane.org>; Thu, 25 Dec 2014 11:18:10 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=HwImEofRD3apk3zKosjggLg7qxvg8Pq4cq19wDipUqc=;
        b=beDVY8ilJkJYrkTBmDFbZwlVmaaMKBtigcIM4vBcUWjXw7ZnN7/fFYzOqyX4BC2Uop
         to4D1uL2QSFRmbY319u1ritk9Li01yRlaFFIAvlgZ8siTr36LPrbMtLH83EkEM2Eqqpc
         c0l72U9HiYQfKUYwqkWlqoXKuRG/Yr0yesYiPNfLEMc9bzVBrUWjQaV5xLJ/2Qf9JLGH
         eyUimBzdfRx6oaLy8b4GzFRKQEIz0GY+uPq0f7xYAC23CsLUDzM0bLALXImYBjnBAhcT
         +WZfKzxUsn3PlU5plVhGPnjT8evjgvHUUKpkvAk6Dhg33AqR9L3DkOg0KEzqYe5mgYih
         bYhQ==
X-Gm-Message-State: ALoCoQnfu/mrmgcelLU44djjxc1DVEiMo4Zp+cNZcWdxrGQftnOiEOZdxoPFER/9nOfLw+Hnb1zx
X-Received: by 10.236.98.71 with SMTP id u47mr30459844yhf.30.1419535090673;
        Thu, 25 Dec 2014 11:18:10 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.131.234 with SMTP id op10ls2537844obb.36.gmail; Thu, 25
 Dec 2014 11:18:09 -0800 (PST)
X-Received: by 10.202.134.78 with SMTP id i75mr16503210oid.23.1419535089935;
        Thu, 25 Dec 2014 11:18:09 -0800 (PST)
Original-Received: from mail-oi0-x234.google.com (mail-oi0-x234.google.com. [2607:f8b0:4003:c06::234])
        by mx.google.com with ESMTPS id b187si3987421oia.12.2014.12.25.11.18.09
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 25 Dec 2014 11:18:09 -0800 (PST)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:4003:c06::234 as permitted sender) client-ip=2607:f8b0:4003:c06::234;
Original-Received: by mail-oi0-f52.google.com with SMTP id h136so20703873oig.11
        for <std-proposals@isocpp.org>; Thu, 25 Dec 2014 11:18:09 -0800 (PST)
X-Received: by 10.60.119.98 with SMTP id kt2mr7676639oeb.55.1419535089809;
 Thu, 25 Dec 2014 11:18:09 -0800 (PST)
Original-Received: by 10.76.154.2 with HTTP; Thu, 25 Dec 2014 11:18:09 -0800 (PST)
In-Reply-To: <a8d7672f-27e5-49ea-83e2-f52c6963ff31@isocpp.org>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of ville.voutilainen@gmail.com designates 2607:f8b0:4003:c06::234 as
 permitted sender) smtp.mail=ville.voutilainen@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:15307
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/15307>

On 25 December 2014 at 21:13, Leo Heinsaar <leoheinsaar@gmail.com> wrote:
> That's why I'm writing about it now Ville - hoping that by now everybody
> will have written the boilerplate you mentioned so often that it would make
> it easier to sell :-)

For what it's worth, somewhat philosophically: it took a while for people to
admit that "YES, it's FUNDAMENTAL to traverse a range from begin to
end, we should have a shortcut (range-for) for that". We are going towards
a direction where applying an algorithm for such a full range is considered
equally fundamental. One would hope that 'basic' operations like
"does this range contain element with value equivalent to 'foo'" would
be treated equally fundamental.

So, now that the *real* Ranges-work is ongoing, we need to remember
that the usual "let's do it with Ranges" is no longer just a "punt to unknown
time in the future with hand-waving", now we have a real proposal that
attempts to solve these issues in a comprehensive way instead of patching
algorithms individually.

>
> On Thursday, December 25, 2014 11:08:19 PM UTC+4, Ville Voutilainen wrote:
>>
>> On 25 December 2014 at 21:02, Leo Heinsaar <leohe...@gmail.com> wrote:
>> > Hi Olaf - same argument from me as just wrote to Andy.
>>
>> See
>> http://open-std.org/JTC1/SC22/WG21/docs/papers/2014/n4273.htm
>> and
>> http://open-std.org/JTC1/SC22/WG21/docs/papers/2014/n4280.pdf
>>
>> Having generic operations in the library is good, but it's rather likely
>> that having them as non-member algorithms is somewhat
>> preferred to adding a member to every container. Do remember that
>> legacy arrays do not have member functions (although personally
>> I don't really care). I'm not saying it wouldn't be good to add members
>> that do the same thing for every container and would standardize
>> existing-practice-boilerplate (if (foo.find(whatever)!=foo.end()) gets old
>> after you've written it twice). I'm just saying that it may be a hard
>> sell. ;)
>>
>> >
>> > Thanks,
>> > Leo
>> >
>> >
>> > On Thursday, December 25, 2014 8:44:12 PM UTC+4, Olaf van der Spek
>> > wrote:
>> >>
>> >> On Thursday, December 25, 2014 7:40:40 AM UTC+1, Leo Heinsaar wrote:
>> >>>
>> >>> Hi guys,
>> >>>
>> >>> Range-for and auto greatly simplify code dealing with iterators -
>> >>> thanks
>> >>> to all who contributed to that - but don't you think it's an omission
>> >>> we
>> >>> still don't have the very simple bool contains(const T&) family in STL
>> >>> containers?
>> >>>
>> >>> There's hardly a single production codebase in the world that doesn't
>> >>> have the contains() boilerplate (I mean, of course, comparing the
>> >>> result of
>> >>> find() to an end() to see if the value is there), often in multiple
>> >>> places.
>> >>> And I guess range-for and auto were also at least partly born out of
>> >>> realization that our code often deserves a higher abstraction level
>> >>> than
>> >>> iterators.
>> >>>
>> >>> Correct me if I'm wrong, but I see contains() as a not-so-big of an
>> >>> addition to the standard library that would be of quite significant
>> >>> value.
>> >>
>> >>
>> >> Hi Leo,
>> >>
>> >> If it's about maps etc you could use count() or a find wrapper that
>> >> returns a pointer (to second) for simpler syntax.
>> >> contains() might still be useful.
>> >>
>> >> Olaf
>> >
>> > --
>> >
>> > ---
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "ISO C++ Standard - Future Proposals" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to std-proposal...@isocpp.org.
>> > To post to this group, send email to std-pr...@isocpp.org.
>> > Visit this group at
>> > http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
