220 37072 <f18af735-cbd2-48ce-b4c4-42a3d320cdeb@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: olafvdspek@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: const std::map operator []
Date: Mon, 26 Feb 2018 03:04:11 -0800 (PST)
Lines: 112
Approved: news@gmane.org
Message-ID: <f18af735-cbd2-48ce-b4c4-42a3d320cdeb@isocpp.org>
References: <c510e551-256b-4127-8606-2011ab998e3d@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2406_2026382015.1519643052056"
X-Trace: blaine.gmane.org 1519642933 27982 195.159.176.226 (26 Feb 2018 11:02:13 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 26 Feb 2018 11:02:13 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC5NB45SSABBBLGTZ7KAKGQEBRRRSLQ@isocpp.org Mon Feb 26 12:02:09 2018
Return-path: <std-proposals+bncBC5NB45SSABBBLGTZ7KAKGQEBRRRSLQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f71.google.com ([209.85.213.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC5NB45SSABBBLGTZ7KAKGQEBRRRSLQ@isocpp.org>)
	id 1eqGXn-0006ov-Fa
	for gclcip-std-proposals@m.gmane.org; Mon, 26 Feb 2018 12:02:07 +0100
Original-Received: by mail-vk0-f71.google.com with SMTP id n23sf4316496vke.14
        for <gclcip-std-proposals@m.gmane.org>; Mon, 26 Feb 2018 03:04:14 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=RmAfrKlh5+6eJOQXAtk/4nYvD+KP9dgR0up1Jo/lTGE=;
        b=rxkt7N28mdAHSIPZuc8y5FcoKhYUxDUhdYTw8YTUpLAtOPoE7sz3TRyydMRQ2cjj7r
         tdasTHzZzrWM8Pj+xL368pRw5oS4ROJRtWxXYAmQZlyp9j8QeK6LKlwpIKVpyjdgIHFD
         AfM+N3YHgTh/+t7voV/nxiMYVsLiXJdp4HgeT5ksWRENLvsd2Kwgvfu7R2z5z7B6xQlt
         b2Uyy5BkB7uWdzP2vA+wO7EAN+CRJ5cIKpU3+BF6pVMBwniHYuu0ZgZh0QRSlbzPhsbu
         pQgBBdMAH4zvNGLUA5Whg9AlyE3DFnyHIVWOp/u8+njGOQ/Vly7CfCeMF9PYvFuvGpm7
         Swdw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=RmAfrKlh5+6eJOQXAtk/4nYvD+KP9dgR0up1Jo/lTGE=;
        b=ayPpRICODwXWIAxsKfcRAdfW0+Kl2us7B82ENTX0K6oIiYHIDs2xqUz1bb+1t42Sq2
         if3mYARJBuptRm55G95vzXgW3Vv+B/9d6gfUk7g9JFp6z57qhENd/MUjGSLZhg0THUzY
         ZrlBUGDHScTRaNjoqBhzjYOwcqhSSB6TPOX/CMeC8WmdCsJoayNLKtwpsHLxpHCBuB4L
         alEy0+gg9q/YY5g+gqlNecdfk1RGsNTBPi7zFnQUXXCEv1iVbmjPpBjTjwtTkBdfPsPV
         oezF9EyjnAE3uwJSgVpsbauc1b/4gixny9rVm9o3ninLUzfoaaNoIxIixJBULu7pFvye
         pJbw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=RmAfrKlh5+6eJOQXAtk/4nYvD+KP9dgR0up1Jo/lTGE=;
        b=fnqr/dHktZek+BXHPlr+93i4+qealNcReP6Rz/+/HBK290LdEWZ/hKR4f24rUfTbMl
         aoHS47YXhmkHtKj3JTpqlf/ExfV+C7fKBMqHxcIM8We+YODoroS54msgg02zx+O9yhXw
         CNFxeh011XOSvW7WGVdv2AXRCjvIDxLqg1ar1eAgnjnyfI8Ey5MUBPT3O7L/Tc0I8PJM
         pcn9RaR7YrcelTTxNkOxb1lCSATBIQBHw0dzK4TKtsvJ6E8vWEr3RF3ZSCHn0IzhrVdp
         2NOC0IKc/H1IFqw0+J/sTXNmPPOiUSAmND4G7TmbfowgBAv8bWDdP/IBtoyltrTHPYVR
         ZThw==
X-Gm-Message-State: APf1xPD0qMeGvDs6v7ygzhi7FkZuwfvrLE3T96KJVIV+BxIyruDz3xKY
	VqK8l+kwXHUPBd6KLlnyhBucRA==
X-Google-Smtp-Source: AG47ELs+psOT79CnFnl2kUqxQHGm+ehlfD7Ez/v4np6zhcizfIq5cSsTbDArnUWO1sanBPXtYprMHw==
X-Received: by 10.31.131.20 with SMTP id f20mr4800255vkd.87.1519643053824;
        Mon, 26 Feb 2018 03:04:13 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.158.3 with SMTP id h3ls4698074vke.11.gmail; Mon, 26 Feb
 2018 03:04:12 -0800 (PST)
X-Received: by 10.31.67.71 with SMTP id q68mr1075304vka.9.1519643052546;
        Mon, 26 Feb 2018 03:04:12 -0800 (PST)
In-Reply-To: <c510e551-256b-4127-8606-2011ab998e3d@isocpp.org>
X-Original-Sender: olafvdspek@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:37072
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37072>

------=_Part_2406_2026382015.1519643052056
Content-Type: multipart/alternative; 
	boundary="----=_Part_2407_1973863748.1519643052057"

------=_Part_2407_1973863748.1519643052057
Content-Type: text/plain; charset="UTF-8"

Op zondag 5 november 2017 00:18:59 UTC+1 schreef Cleiton Santoia:
>
> What about include a 'const operator []' in std::map that returns a 
> std::optional instead a reference to T ?
>
> std::optional< std::reference_wrapper< T > > operator[] (const Key& key) 
> const { ... }
>
> Maybe this is a case for committee consider std::optional for references
>
> std::optional< T& > operator[] (const Key& key) const { ... } 
>
>
A wrapper returning second_type* is so much easier. See my find_ptr and 
friends.

const typename T::value_type::second_type* find_ptr(const T& c, const U& v)

https://github.com/OlafvdSpek/xbt/blob/master/misc/xbt/find_ptr.h 

-- 
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f18af735-cbd2-48ce-b4c4-42a3d320cdeb%40isocpp.org.

------=_Part_2407_1973863748.1519643052057
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Op zondag 5 november 2017 00:18:59 UTC+1 schreef Cleiton S=
antoia:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">What a=
bout include a &#39;const operator []&#39; in std::map that returns a std::=
optional instead a reference to T ?<div><br></div><div><span style=3D"color=
:rgb(36,39,41);font-family:Consolas,Menlo,Monaco,&quot;Lucida Console&quot;=
,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono&quot;,&quot;Bitstream V=
era Sans Mono&quot;,&quot;Courier New&quot;,monospace,sans-serif;background=
-color:rgb(239,240,241)">std::optional&lt; std::reference_wrapper&lt; T &gt=
; &gt; operator[] (const Key&amp; key) const { ... }</span></div><div><span=
 style=3D"color:rgb(36,39,41);font-family:Consolas,Menlo,Monaco,&quot;Lucid=
a Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono&quot;,&q=
uot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospace,sans-s=
erif;background-color:rgb(239,240,241)"><br></span></div><div>Maybe this is=
 a case for committee consider std::optional for references<br></div><div><=
br></div><div><span style=3D"color:rgb(36,39,41);font-family:Consolas,Menlo=
,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu=
 Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quo=
t;,monospace,sans-serif;background-color:rgb(239,240,241)">std::optional&lt=
; T&amp; &gt; operator[] (const Key&amp; key) const { ... }=C2=A0</span><br=
></div><div><br></div></div></blockquote><div><br></div><div>A wrapper retu=
rning=C2=A0<span style=3D"color: rgb(36, 41, 46); font-family: SFMono-Regul=
ar, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-=
size: 12px; white-space: pre;">second_type* is so much easier. See my find_=
ptr and friends.</span></div><div><br></div><div><span class=3D"pl-k" style=
=3D"box-sizing: border-box; color: rgb(215, 58, 73); font-family: SFMono-Re=
gular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; fo=
nt-size: 12px; white-space: pre;">const</span><span style=3D"color: rgb(36,=
 41, 46); font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot=
;, Menlo, Courier, monospace; font-size: 12px; white-space: pre;"> </span><=
span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(215, 58, 73=
); font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menl=
o, Courier, monospace; font-size: 12px; white-space: pre;">typename</span><=
span style=3D"color: rgb(36, 41, 46); font-family: SFMono-Regular, Consolas=
, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 12px; =
white-space: pre;"> T::value_type::second_type* </span><span class=3D"pl-en=
" style=3D"box-sizing: border-box; color: rgb(111, 66, 193); font-family: S=
FMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monos=
pace; font-size: 12px; white-space: pre;">find_ptr</span><span style=3D"col=
or: rgb(36, 41, 46); font-family: SFMono-Regular, Consolas, &quot;Liberatio=
n Mono&quot;, Menlo, Courier, monospace; font-size: 12px; white-space: pre;=
">(</span><span class=3D"pl-k" style=3D"box-sizing: border-box; color: rgb(=
215, 58, 73); font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&=
quot;, Menlo, Courier, monospace; font-size: 12px; white-space: pre;">const=
</span><span style=3D"color: rgb(36, 41, 46); font-family: SFMono-Regular, =
Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size=
: 12px; white-space: pre;"> T&amp; c, </span><span class=3D"pl-k" style=3D"=
box-sizing: border-box; color: rgb(215, 58, 73); font-family: SFMono-Regula=
r, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-s=
ize: 12px; white-space: pre;">const</span><span style=3D"color: rgb(36, 41,=
 46); font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, M=
enlo, Courier, monospace; font-size: 12px; white-space: pre;"> U&amp; v)</s=
pan><br></div><div><br></div><div>https://github.com/OlafvdSpek/xbt/blob/ma=
ster/misc/xbt/find_ptr.h=C2=A0</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f18af735-cbd2-48ce-b4c4-42a3d320cdeb%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f18af735-cbd2-48ce-b4c4-42a3d320cdeb=
%40isocpp.org</a>.<br />

------=_Part_2407_1973863748.1519643052057--

------=_Part_2406_2026382015.1519643052056--

.
