220 15305 <CAFk2RUb=AB7-NUfyKhFQm43adqcGZW7xp+1wutpEY5t4H5uDPw@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:08:17 +0200
Lines: 71
Approved: news@gmane.org
Message-ID: <CAFk2RUb=AB7-NUfyKhFQm43adqcGZW7xp+1wutpEY5t4H5uDPw@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>
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 1419534505 5101 80.91.229.3 (25 Dec 2014 19:08:25 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 25 Dec 2014 19:08:25 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5JHI7A7ALRBIWB6GSAKGQEWOFEGTA@isocpp.org Thu Dec 25 20:08:20 2014
Return-path: <std-proposals+bncBC5JHI7A7ALRBIWB6GSAKGQEWOFEGTA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f199.google.com ([209.85.220.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRBIWB6GSAKGQEWOFEGTA@isocpp.org>)
	id 1Y4Dlj-0005wa-PZ
	for gclcip-std-proposals@m.gmane.org; Thu, 25 Dec 2014 20:08:19 +0100
Original-Received: by mail-vc0-f199.google.com with SMTP id le20sf28013874vcb.2
        for <gclcip-std-proposals@m.gmane.org>; Thu, 25 Dec 2014 11:08:18 -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=u4HIkp4KTjN2vdJw9iwGVrPo8xkHHap50du9NUfoSIE=;
        b=lDdZXG8vxK7iEv57xDMAbF40EkxfbIYuQPKtaxhZGuKCNbfC3UZpzReKXWbcpGrZgl
         d2aWdXiEqfjWPZpCO3lE3DWirT4DRUWeVDky2eU1BvN+pwFL1v3dQClOqlhYhINmYEPa
         1S7V6IRJDvK1+73phxWeLBCG/SXvpSLUFg8ylGnLYm0kVQE5qGsYtEmv7SxlGRbFd0S0
         GUjQp9yNFPEzPRfgnjVadvXyxvzGq/W59MqJdz5uXTxA1tyYCQluRk/QQCsuG/7bveNt
         NUWH/32ltp6pFvXjCUM33UvfNoie+wTQHxdGnOP7+/Ri1l3BxEFBVZxQkPGIpcFUbDzA
         dnHQ==
X-Gm-Message-State: ALoCoQnBMo3neBO1RyV4mI1CQCYu6UtwcfS5Pgwxmz0hJRGsTSkML9VZMiVsES24LBkO45FVPGIz
X-Received: by 10.224.114.144 with SMTP id e16mr14218430qaq.3.1419534498777;
        Thu, 25 Dec 2014 11:08:18 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.128.227 with SMTP id nr3ls2614548obb.18.gmail; Thu, 25 Dec
 2014 11:08:18 -0800 (PST)
X-Received: by 10.182.42.168 with SMTP id p8mr2187866obl.81.1419534498020;
        Thu, 25 Dec 2014 11:08:18 -0800 (PST)
Original-Received: from mail-oi0-x22f.google.com (mail-oi0-x22f.google.com. [2607:f8b0:4003:c06::22f])
        by mx.google.com with ESMTPS id o8si16265967obl.80.2014.12.25.11.08.18
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 25 Dec 2014 11:08:18 -0800 (PST)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:4003:c06::22f as permitted sender) client-ip=2607:f8b0:4003:c06::22f;
Original-Received: by mail-oi0-f47.google.com with SMTP id v63so20695891oia.6
        for <std-proposals@isocpp.org>; Thu, 25 Dec 2014 11:08:17 -0800 (PST)
X-Received: by 10.202.73.6 with SMTP id w6mr22241848oia.37.1419534497900; Thu,
 25 Dec 2014 11:08:17 -0800 (PST)
Original-Received: by 10.76.154.2 with HTTP; Thu, 25 Dec 2014 11:08:17 -0800 (PST)
In-Reply-To: <b64f874c-473a-4b58-9553-609c95c601c2@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::22f 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:15305
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/15305>

On 25 December 2014 at 21:02, Leo Heinsaar <leoheinsaar@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-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/.

.
