220 21330 <CAFmGaCr2yF0h965+pESC-846M0+_zRtLbNnODDq79zziSOCnvw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Shahms King <shahms.king@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: missing hash_code result in P0029
Date: Mon, 05 Oct 2015 22:33:50 +0000
Lines: 176
Approved: news@gmane.org
Message-ID: <CAFmGaCr2yF0h965+pESC-846M0+_zRtLbNnODDq79zziSOCnvw@mail.gmail.com>
References: <d714437b-638b-4a72-9e0a-35c4f6e9e484@isocpp.org>
 <1572715.jJmjmrJA0J@tjmaciei-mobl4> <CAFmGaCoRKXE9pVUpW=qD8or8Z-pXa3Ve8DMUjDJg-=+w66awsA@mail.gmail.com>
 <1894409.GHBCqMxsGN@tjmaciei-mobl4>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a113d9f7a0f81e50521631c8d
X-Trace: ger.gmane.org 1444084450 4612 80.91.229.3 (5 Oct 2015 22:34:10 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 5 Oct 2015 22:34:10 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC7ML3M6QIDBBWHVZOYAKGQET3VETEI@isocpp.org Tue Oct 06 00:34:04 2015
Return-path: <std-proposals+bncBC7ML3M6QIDBBWHVZOYAKGQET3VETEI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f70.google.com ([209.85.213.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC7ML3M6QIDBBWHVZOYAKGQET3VETEI@isocpp.org>)
	id 1ZjEKY-00024p-Pd
	for gclcip-std-proposals@m.gmane.org; Tue, 06 Oct 2015 00:34:02 +0200
Original-Received: by vkao3 with SMTP id o3sf261402831vka.1
        for <gclcip-std-proposals@m.gmane.org>; Mon, 05 Oct 2015 15:34:01 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:content-type:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=TsKB7p/o5DiwW0DBJyG8gVjuFEWiIyoNHuIpWqPEALg=;
        b=feSjDZQ+ZkCjxKoAWRb/7lRIgApmpYWKJDteyayto8q7PDZP1zm34LHoy+SkYpJl6o
         xI/FUD50QZPguT+KSENj9VszWWhAk35lemyXePIBKSGe54B56TJ6mGx4PqMGuer+TJWZ
         WEOBBjqU9NLHayGyCGJBhxEGVxxtxJpMMdYTswXXQoDlxVc5x9Lfqf/419lrwIdFehN1
         g9u1mhnErRf7TKo2IHIsi/AR4Es5K7fIoYw9RwXSHlrbvTgZOC2Wd1P8dBHRCQWGQzMq
         zzA0VUuPi3iWh7XI663zUysLadTeCkdtfG0EU5er/XfYgxIADedOYIkOazVx51x7eLgz
         35Ug==
X-Gm-Message-State: ALoCoQnzOZV9rCe4fzClnwwp7xwp5mMXdTU/Cbv0m8cRfoLx42+9XKkPeogpF1dnwENKb5g/ZN0r
X-Received: by 10.31.178.196 with SMTP id b187mr28130381vkf.3.1444084441694;
        Mon, 05 Oct 2015 15:34:01 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.97.245 with SMTP id m108ls3201312qge.16.gmail; Mon, 05 Oct
 2015 15:34:00 -0700 (PDT)
X-Received: by 10.31.13.11 with SMTP id 11mr22527709vkn.59.1444084440100;
        Mon, 05 Oct 2015 15:34:00 -0700 (PDT)
Original-Received: from mail-vk0-x232.google.com (mail-vk0-x232.google.com. [2607:f8b0:400c:c05::232])
        by mx.google.com with ESMTPS id z22si15462746vkd.175.2015.10.05.15.34.00
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 05 Oct 2015 15:34:00 -0700 (PDT)
Received-SPF: pass (google.com: domain of shahms.king@gmail.com designates 2607:f8b0:400c:c05::232 as permitted sender) client-ip=2607:f8b0:400c:c05::232;
Original-Received: by vkat63 with SMTP id t63so105956650vka.1
        for <std-proposals@isocpp.org>; Mon, 05 Oct 2015 15:34:00 -0700 (PDT)
X-Received: by 10.31.32.137 with SMTP id g131mr21270056vkg.2.1444084439808;
 Mon, 05 Oct 2015 15:33:59 -0700 (PDT)
In-Reply-To: <1894409.GHBCqMxsGN@tjmaciei-mobl4>
X-Original-Sender: shahms.king@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of shahms.king@gmail.com designates 2607:f8b0:400c:c05::232 as
 permitted sender) smtp.mailfrom=shahms.king@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-Spam-Checked-In-Group: 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:21330
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/21330>

--001a113d9f7a0f81e50521631c8d
Content-Type: text/plain; charset=UTF-8

As far as I understand it, you don't.  std::hash_code is the internal state
of whatever hash algorithm is being used by std::hash.  Either you're using
std::hash, in which case it initializes the std::hash_code through
mechanisms unknown and similarly extracts the value or you're using a
different algorithm which uses a different type to represent its internal
state which conforms to the HashCode concept and you don't traffic in
std::hash_code at all.  At least, that's my reading of the proposal.

Either your hash_value() function accepts std::hash_code and only works
with std::hash, or it's a template and supports any conforming hashing
algorithm.

--Shahms

On Mon, Oct 5, 2015 at 1:58 PM Thiago Macieira <thiago@macieira.org> wrote:

> On Monday 05 October 2015 17:34:04 Shahms King wrote:
> > You can trivially use them in your own hashing container, as you would
> > now.  The primary thing that is being changed is the mechanism by which
> > user-defined types can supply their data to the hash function, not the
> > interface for retrieving final values from that hash function.  The
> > high-level API for retrieving a hash value from an object is unchanged,
> e.g.
> >
> > template <typename T>
> > struct hash {
> >   size_t operator() (const T& value) const {
> >     std::hash_code state = __implementation_defined_init();
> >     state = hash_value(state, value);
> >     return __implementation_defined_extract_value(state);
> >   }
> > };
>
> If by __implementation_defined_init(), you mean the way I will initialise
> the
> hash from my hash seed, I understand. But what constructors and assignment
> operators will std::hash_code have so I can create it from my hash seed?
>
> As for the extract value, I don't get it.
>
> Can you give as example the two most trivial implementations? That is, the
> one
> where there's no extra state before or after the hashing of the value type
> (no
> seed) and the one where the seed is just a global integer value initialised
> from a random source.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>    Software Architect - Intel Open Source Technology Center
>       PGP/GPG: 0x6EF45358; fingerprint:
>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
>
> --
>
> ---
> 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/.

--001a113d9f7a0f81e50521631c8d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">As far as I understand it, you don&#39;t. =C2=A0std::hash_=
code is the internal state of whatever hash algorithm is being used by std:=
:hash.=C2=A0 Either you&#39;re using std::hash, in which case it initialize=
s the std::hash_code through mechanisms unknown and similarly extracts the =
value or you&#39;re using a different algorithm which uses a different type=
 to represent its internal state which conforms to the HashCode concept and=
 you don&#39;t traffic in std::hash_code at all.=C2=A0 At least, that&#39;s=
 my reading of the proposal.<div><br></div><div>Either your hash_value() fu=
nction accepts std::hash_code and only works with std::hash, or it&#39;s a =
template and supports any conforming hashing algorithm.<div><br></div><div>=
--Shahms</div></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">O=
n Mon, Oct 5, 2015 at 1:58 PM Thiago Macieira &lt;<a href=3D"mailto:thiago@=
macieira.org">thiago@macieira.org</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">On Monday 05 October 2015 17:34:04 Shahms King wrote:<br>
&gt; You can trivially use them in your own hashing container, as you would=
<br>
&gt; now.=C2=A0 The primary thing that is being changed is the mechanism by=
 which<br>
&gt; user-defined types can supply their data to the hash function, not the=
<br>
&gt; interface for retrieving final values from that hash function.=C2=A0 T=
he<br>
&gt; high-level API for retrieving a hash value from an object is unchanged=
, e.g.<br>
&gt;<br>
&gt; template &lt;typename T&gt;<br>
&gt; struct hash {<br>
&gt;=C2=A0 =C2=A0size_t operator() (const T&amp; value) const {<br>
&gt;=C2=A0 =C2=A0 =C2=A0std::hash_code state =3D __implementation_defined_i=
nit();<br>
&gt;=C2=A0 =C2=A0 =C2=A0state =3D hash_value(state, value);<br>
&gt;=C2=A0 =C2=A0 =C2=A0return __implementation_defined_extract_value(state=
);<br>
&gt;=C2=A0 =C2=A0}<br>
&gt; };<br>
<br>
If by __implementation_defined_init(), you mean the way I will initialise t=
he<br>
hash from my hash seed, I understand. But what constructors and assignment<=
br>
operators will std::hash_code have so I can create it from my hash seed?<br=
>
<br>
As for the extract value, I don&#39;t get it.<br>
<br>
Can you give as example the two most trivial implementations? That is, the =
one<br>
where there&#39;s no extra state before or after the hashing of the value t=
ype (no<br>
seed) and the one where the seed is just a global integer value initialised=
<br>
from a random source.<br>
<br>
--<br>
Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"noref=
errer" target=3D"_blank">macieira.info</a> - thiago (AT) <a href=3D"http://=
kde.org" rel=3D"noreferrer" target=3D"_blank">kde.org</a><br>
=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center<br>
=C2=A0 =C2=A0 =C2=A0 PGP/GPG: 0x6EF45358; fingerprint:<br>
=C2=A0 =C2=A0 =C2=A0 E067 918B B660 DBD1 105C=C2=A0 966C 33F5 F005 6EF4 535=
8<br>
<br>
--<br>
<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 <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" rel=3D"noreferrer" target=3D"_blank">http://groups.google.c=
om/a/isocpp.org/group/std-proposals/</a>.<br>
</blockquote></div>

<p></p>

-- <br />
<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 <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a113d9f7a0f81e50521631c8d--

.
