220 3683 <c17c2225-7bb7-4e04-93f2-bd83636c4f33@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: jgottman6@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: N3573: Why heterogenous extensions to unordered
 containers will not work
Date: Tue, 9 Apr 2013 19:22:47 -0700 (PDT)
Lines: 112
Approved: news@gmane.org
Message-ID: <c17c2225-7bb7-4e04-93f2-bd83636c4f33@isocpp.org>
References: <ed957851-6769-4e9e-9244-36b31112799c@isocpp.org>
 <d32b2253-b4c4-43ea-8cb6-b635a5af3342@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_6377_22165865.1365560567186"
X-Trace: ger.gmane.org 1365560567 20609 80.91.229.3 (10 Apr 2013 02:22:47 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 10 Apr 2013 02:22:47 +0000 (UTC)
Cc: jgottman6@gmail.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD7LHGWIQEPRB6EZSOFQKGQE2XPXH7I@isocpp.org Wed Apr 10 04:22:50 2013
Return-path: <std-proposals+bncBD7LHGWIQEPRB6EZSOFQKGQE2XPXH7I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vb0-f69.google.com ([209.85.212.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD7LHGWIQEPRB6EZSOFQKGQE2XPXH7I@isocpp.org>)
	id 1UPkgU-0006z4-3v
	for gclcip-std-proposals@m.gmane.org; Wed, 10 Apr 2013 04:22:50 +0200
Original-Received: by mail-vb0-f69.google.com with SMTP id p12sf10231054vbe.0
        for <gclcip-std-proposals@m.gmane.org>; Tue, 09 Apr 2013 19:22:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-received:x-beenthere:x-received:date:from:to:cc:message-id
         :in-reply-to:references:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-google-group-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=X2r+5Ndti2iYio1ULdE20WmVEggAP8PqVrKxQvDdoEw=;
        b=BpusDLJdUGJdFzqGr5YLYwc6R/IDr8ggEwmf5iNpfzGZahCyKYMB/Qb7qSslyjkEDz
         6RSl/FMkh1rM/5kiMXLj44iSW0sjc7AisThExvusJ1jMcg44bvC5NnwD6qPcdp9CGCEF
         7X9ytdFfLiIzDrYMcofpGJnKLt7GvGFKyPMtPIfQirB/wl0wSqxcRW5aV+dE6MI/do3/
         eaE91gb0P7ymw7yJ1cZNcqbSaFHVAIm4250eMclQo6WEvibuJbsvZKiluDV7WyBubSBG
         JpJpwxXOiV2oLXcHpkowhs6xcP2kG9uz+JkkKsFWal0vWzoxARedAWx0jRqNLaO8GR3b
         ZZ/Q==
X-Received: by 10.224.65.6 with SMTP id g6mr384206qai.4.1365560569161;
        Tue, 09 Apr 2013 19:22:49 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.24.230 with SMTP id x6ls87671qef.31.gmail; Tue, 09 Apr 2013
 19:22:47 -0700 (PDT)
X-Received: by 10.49.37.39 with SMTP id v7mr5274qej.27.1365560567911;
        Tue, 09 Apr 2013 19:22:47 -0700 (PDT)
In-Reply-To: <d32b2253-b4c4-43ea-8cb6-b635a5af3342@isocpp.org>
X-Original-Sender: jgottman6@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?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:3683
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/3683>

------=_Part_6377_22165865.1365560567186
Content-Type: text/plain; charset=ISO-8859-1


On Tuesday, April 9, 2013 6:58:15 AM UTC-4, DeadMG wrote:
>
> Actually, I don't believe that exact use case *is* in the paper. And, 
> whilst it's nice, it would depend on std::hash<const char*> treating it's 
> argument like a C string rather than a generic pointer, and I don't know if 
> it does. If so, then that would certainly be a nice use case- and you could 
> certainly provide a custom hasher for one lookup that could perform this 
> using another of the features in N3573.
>
> Whilst I admit that I overlooked implicit conversions in this case, it's 
> not a breaking problem, I'll just have to provide a new name, like, find_by 
> or some such (and the same for erasure). That also means I'd have to use 
> SFINAE to limit operator[] too, since that cannot be given another name, or 
> perhaps some kind of trait. It would have been nice to have something like
>
> template<typename T, typename U> void find(std::unordered_set<T> t, U&& u) 
> {
>     t.find(u);
> }
>
> function for any U, I doubt any such code exists, so I'm not that bothered 
> by losing it.
>

 
Actually, this is possible.  You just need to overload operator() in your 
hash object.  Thus, for hash<unique_ptr<X>>, as well as defining 
operator()(const unique_ptr<X> &), you would also define operator()(X *).  
Then, your templated find method would always call 
hash<unique_ptr<X>>()(u), but which overload it chooses would depend on the 
type of u.

Joe Gottman

-- 

--- 
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/?hl=en.



------=_Part_6377_22165865.1365560567186
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>On Tuesday, April 9, 2013 6:58:15 AM UTC-4, DeadMG wrote:<blockquote cl=
ass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px =
#ccc solid;padding-left: 1ex;">Actually, I don't believe that exact use cas=
e *is* in the paper. And, whilst it's nice, it would depend on std::hash&lt=
;const char*&gt; treating it's argument like a C string rather than a gener=
ic pointer, and I don't know if it does. If so, then that would certainly b=
e a nice use case- and you could certainly provide a custom hasher for one =
lookup that could perform this using another of the features in N3573.<div>=
<br></div><div>Whilst I admit that I overlooked implicit conversions in thi=
s case, it's not a breaking problem, I'll just have to provide a new name, =
like, find_by or some such (and the same for erasure). That also means I'd =
have to use SFINAE to limit operator[] too, since that cannot be given anot=
her name, or perhaps some kind of trait. It would have been nice to have so=
mething like</div><div><br></div><div style=3D"background-color:rgb(250,250=
,250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><div><s=
pan style=3D"color:#008">template</span><span style=3D"color:#660">&lt;</sp=
an><span style=3D"color:#008">typename</span><span style=3D"color:#000"> T<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span=
><span style=3D"color:#008">typename</span><span style=3D"color:#000"> U</s=
pan><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#008">void</span><span style=3D"color:#000"> find</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#000">std</span=
><span style=3D"color:#660">::</span><span style=3D"color:#000">unordered_s=
et</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">T=
</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"> t<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> U</spa=
n><span style=3D"color:#660">&amp;&amp;</span><span style=3D"color:#000"> u=
</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; =
&nbsp; t</span><span style=3D"color:#660">.</span><span style=3D"color:#000=
">find</span><span style=3D"color:#660">(</span><span style=3D"color:#000">=
u</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=
</span><span style=3D"color:#660">}</span></div></code></div><div><br></div=
><div>function for any U, I doubt any such code exists, so I'm not that bot=
hered by losing it.<br></div></blockquote><div><br>&nbsp;<br>Actually, this=
 is possible.&nbsp; You just need to overload operator() in your hash objec=
t.&nbsp; Thus, for hash&lt;unique_ptr&lt;X&gt;&gt;, as well as defining ope=
rator()(const unique_ptr&lt;X&gt; &amp;), you would also define operator()(=
X *).&nbsp; Then, your templated find method would always call hash&lt;uniq=
ue_ptr&lt;X&gt;&gt;()(u), but which overload it chooses would depend on the=
 type of u.<br><br>Joe Gottman<br></div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_6377_22165865.1365560567186--

.
