220 23702 <9160999F-C7E2-4D3F-B343-96CF587BEF61@gmail.com> article
Path: news.gmane.org!not-for-mail
From: Howard Hinnant <howard.hinnant@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Default swap/hash_value
Date: Wed, 13 Jan 2016 11:09:41 -0500
Lines: 47
Approved: news@gmane.org
Message-ID: <9160999F-C7E2-4D3F-B343-96CF587BEF61@gmail.com>
References: <569582E5.1040108@wanadoo.fr> <4072A7C6-B09D-4847-971B-2914643B91D7@gmail.com> <569594AD.6000505@wanadoo.fr> <2170C30C-830F-47C2-8397-29DD4ED35E97@gmail.com> <56960730.9000403@wanadoo.fr>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\))
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1452701398 30408 80.91.229.3 (13 Jan 2016 16:09:58 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 13 Jan 2016 16:09:58 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCK2HM4L6YERBR7N3G2AKGQEFF7BB7Q@isocpp.org Wed Jan 13 17:09:49 2016
Return-path: <std-proposals+bncBCK2HM4L6YERBR7N3G2AKGQEFF7BB7Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f200.google.com ([209.85.192.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCK2HM4L6YERBR7N3G2AKGQEFF7BB7Q@isocpp.org>)
	id 1aJNzV-00089O-KZ
	for gclcip-std-proposals@m.gmane.org; Wed, 13 Jan 2016 17:09:45 +0100
Original-Received: by mail-pf0-f200.google.com with SMTP id 78sf361176087pfw.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 13 Jan 2016 08:09:45 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=content-type:mime-version:subject:from:in-reply-to:date
         :content-transfer-encoding:message-id:references:to
         :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=vj/Lf4nVpEapQk/FL/tStM6DScjSyDYPLOBUxxzInvY=;
        b=OkpLHFpSRtS+Xj4hRrwUpCfEZUfhMbTu7jXcx0yNssTQXwqMqyloJr0zTuV2ZLS6AO
         cX/sSXywL4PUHbklRv5ABtfLlqntmxpB8TrME3iPEOaqyh8cbSG5Wi1pcXuZuAWXrQwb
         yYTt79DEIhuGYC0hEG5a42PBNo17QiH39QZMFF4EvoiGiZuUZgjPwdHeste+pAkaGZxi
         +qOKPqJXr40GowRrJZsoFeondRxUdIigOfrznypDu4rrbK6+cD1p1GBTtcTLsfzr5fC/
         UtJT0xkUb0z5sm+GPEpNjSR5Q6kJpDTReesA/StogtP7rUIa0QEZFSaG2BpsSBtBnw+A
    
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:content-type:mime-version:subject:from
         :in-reply-to:date:content-transfer-encoding:message-id:references:to
         :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=vj/Lf4nVpEapQk/FL/tStM6DScjSyDYPLOBUxxzInvY=;
        b=l9nszpZLKI4KJANrnJtKSxf8cnzI2/49fjwweLoYIT5WuozOv+XGEQNVpOnnd/d5iq
         ZaA4gDkD4SAFKpQlGQx3imE6cPJvF3J4ua6P3fvA2PybhsjXh8lx/c92vysXS57Ef/1n
         ZOjIWU1OT7F9Ayqiz5vRNPlTLDcy2HrWkbZpM6i8NdG7K3jtxSUJ4BA0vcPwrpuu8UPx
         czRLtVDnjL8XU5/oGYbpE8zFPG5WMzSvz0CmDK5bnAAWeDNwQNejtqJmLAbJMRexYgIG
         IvYsMOT1eJCmIpglNfyjhj4dMGMA0FQ4JFyWW6YrE1QMwp2GCHRLVzf0VkLnLWJRCCLK 
X-Gm-Message-State: ALoCoQmUV6e4d3tpRWrXtk24cqOzZfyb1qhurj5tAbTNNMCfrFxgLWXNM/FfISJ/950ADJbc2Dtg2eicAuyVstaey3bn8gLqUQ==
X-Received: by 10.66.186.201 with SMTP id fm9mr22022016pac.41.1452701384459;
        Wed, 13 Jan 2016 08:09:44 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.93.245 with SMTP id d108ls4694667qge.89.gmail; Wed, 13 Jan
 2016 08:09:42 -0800 (PST)
X-Received: by 10.140.25.169 with SMTP id 38mr173112697qgt.73.1452701382932;
        Wed, 13 Jan 2016 08:09:42 -0800 (PST)
Original-Received: from mail-qg0-x234.google.com (mail-qg0-x234.google.com. [2607:f8b0:400d:c04::234])
        by mx.google.com with ESMTPS id a52si1961741qga.61.2016.01.13.08.09.42
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 13 Jan 2016 08:09:42 -0800 (PST)
Received-SPF: pass (google.com: domain of howard.hinnant@gmail.com designates 2607:f8b0:400d:c04::234 as permitted sender) client-ip=2607:f8b0:400d:c04::234;
Original-Received: by mail-qg0-x234.google.com with SMTP id 6so379165173qgy.1
        for <std-proposals@isocpp.org>; Wed, 13 Jan 2016 08:09:42 -0800 (PST)
X-Received: by 10.140.99.53 with SMTP id p50mr102535536qge.97.1452701382705;
        Wed, 13 Jan 2016 08:09:42 -0800 (PST)
Original-Received: from [10.0.1.2] (cpe-104-229-168-124.twcny.res.rr.com. [104.229.168.124])
        by smtp.gmail.com with ESMTPSA id p19sm740333qgp.9.2016.01.13.08.09.41
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
        Wed, 13 Jan 2016 08:09:41 -0800 (PST)
In-Reply-To: <56960730.9000403@wanadoo.fr>
X-Mailer: Apple Mail (2.3112)
X-Original-Sender: howard.hinnant@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of howard.hinnant@gmail.com designates 2607:f8b0:400d:c04::234 as
 permitted sender) smtp.mailfrom=howard.hinnant@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: <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:23702
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/23702>

On Jan 13, 2016, at 3:13 AM, Vicente J. Botet Escriba <vicente.botet@wanado=
o.fr> wrote:
>=20
> I've some additional concerns about the possible generation of specializa=
tion of is_uniquely_represented<T>. I would like it to be generated the spe=
cialization when possible but while multiple definition of hash_value could=
 be check at link time, I believe that multiple specializations of is_uniqu=
ely_represented<T> would result in ODR, which would be a showstopper. So at=
 the end, it would be the responsibility of the developer of class C to add=
 a specialization of is_uniquely_represented<T>. What do you think about th=
is point?

I believe you are correct that it will be necessary for the author of C to =
specialize is_uniquely_represented<C>.  There are semantics to this propert=
y that do not show up in the C++ type system.  For example the hashing of a=
 std::vector should never include the vector=E2=80=99s capacity().  And the=
 hashing of an IEEE floating point should hash -0. and 0. to the same value=
 (despite the different bit layouts).  C may have similar rules on how it m=
ust be hashed and only the author of C can know this.

In the case that is_uniquely_represented<C> answers true, I believe it is a=
 simple library function to automate hash_append/hash_value.  Here is an up=
dated N3980 implementation of such a function:

https://github.com/HowardHinnant/hash_append/blob/master/hash_append.h#L203=
-L212

If something is uniquely represented, you can ship its bytes off to the has=
h algorithm without concern about how its bases and members are laid out.  =
Not only is this easier than dealing with the bases and members individuall=
y, it is also more efficient for most modern hash algorithms.  Hash algorit=
hms like to see as many bytes as possible at once for best performance.  Th=
is leads to less buffering and more bit crunching within the algorithm.

Howard

--=20

---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.

.
