220 23693 <569594AD.6000505@wanadoo.fr> article
Path: news.gmane.org!not-for-mail
From: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Default swap/hash_value
Date: Wed, 13 Jan 2016 01:05:01 +0100
Lines: 62
Approved: news@gmane.org
Message-ID: <569594AD.6000505@wanadoo.fr>
References: <569582E5.1040108@wanadoo.fr>
 <4072A7C6-B09D-4847-971B-2914643B91D7@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1452643523 11601 80.91.229.3 (13 Jan 2016 00:05:23 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 13 Jan 2016 00:05:23 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH67CONY4PBBLVJ222AKGQEHUI6L7A@isocpp.org Wed Jan 13 01:05:05 2016
Return-path: <std-proposals+bncBDH67CONY4PBBLVJ222AKGQEHUI6L7A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f70.google.com ([209.85.215.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDH67CONY4PBBLVJ222AKGQEHUI6L7A@isocpp.org>)
	id 1aJ8vv-0003UI-Ug
	for gclcip-std-proposals@m.gmane.org; Wed, 13 Jan 2016 01:05:03 +0100
Original-Received: by mail-lf0-f70.google.com with SMTP id b134sf153933641lfe.2
        for <gclcip-std-proposals@m.gmane.org>; Tue, 12 Jan 2016 16:05:03 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-to:content-type:content-transfer-encoding
         :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=P+hap2VaHHv68JgAJNSUYfGBYyWUSx8ZOHi/mLTi+V4=;
        b=vGuqk9yGcAkDm2+J9dEkp+Yzh/l8MJmF4uYL32WgmYqMo9xSBgaaqPTovlg3qgdL44
         +lYbpR3d1pwle02ckyCkYQFyoIJEySdG9uUWE26BPULtJe3IBsIfCmqUq/XDdGn8swVl
         W9Ix5RwS26hZUisNDyXOCHAwL/jR4c5053JQ6S6wawGHe1ZfqlaATLRVNVzdpb5FUfn9
         kow01VFcEVf6bgPXRKXjsocOzImPOc/Kw0W9JeesGFRRLAF9b6iIEj5x7zjmW645/OwQ
         TMGSFoIwqXl9NC17nEqDKmhIhGwmV/LQc5Ftm8bf4PJKlAj7By/9K5Xr2+o+S 
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-type
         :content-transfer-encoding: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=P+hap2VaHHv68JgAJNSUYfGBYyWUSx8ZOHi/mLTi+V4=;
        b=XN+UPyFPmMFRE3DRyIy0h2c7uEK754D3tfQRImG8zULcXG7NxD5QqYNvb5k70fwJOT
         MbcfL1EXJvmgtYyZtIyULUq+P20Bw5VyThJL7pde7eCM/Zi3wVwzLW+Rb9hS69Pm+t95
         xUG0uzo9J/B8HfVaGNhURepIsd10wIVHSqTJsd5vveXmwGR4NFebXaYyqbX/8Us5ted0
         VJ7XlR67GAQqHheQsBLCt7m2Ks5nzITCLG7Xvjn0m9yUuXti//Y6SBrRl2O8bOfysP9+
         K61pqrfQbAyVeViVFf36RkJv2cxI007FSUCEM1hXNyQ9Wbh 
X-Gm-Message-State: ALoCoQmnshYoO/nsJfswIJsS2t9RCfgPjeQD7S9i6Nj6mAWCJHZWVfNigdbQUUhj/n25Ww1hW6s7btjL2hJA/yvW86gjjHVwcw==
X-Received: by 10.112.16.34 with SMTP id c2mr2634715lbd.19.1452643503262;
        Tue, 12 Jan 2016 16:05:03 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.4.216 with SMTP id 207ls3530wme.35.gmail; Tue, 12 Jan 2016
 16:05:02 -0800 (PST)
X-Received: by 10.194.121.35 with SMTP id lh3mr141946485wjb.164.1452643502088;
        Tue, 12 Jan 2016 16:05:02 -0800 (PST)
Original-Received: from smtp.smtpout.orange.fr (smtp10.smtpout.orange.fr. [80.12.242.132])
        by mx.google.com with ESMTPS id o123si147602wmd.53.2016.01.12.16.05.02
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=AES128-SHA bits=128/128);
        Tue, 12 Jan 2016 16:05:02 -0800 (PST)
Received-SPF: neutral (google.com: 80.12.242.132 is neither permitted nor denied by best guess record for domain of vicente.botet@wanadoo.fr) client-ip=80.12.242.132;
Original-Received: from new-host.home ([86.214.79.135])
	by mwinf5d45 with ME
	id 5C511s00H2v9yza03C51lq; Wed, 13 Jan 2016 01:05:01 +0100
X-ME-Helo: new-host.home
X-ME-Auth: dmljZW50ZS5ib3RldEB3YW5hZG9vLmZy
X-ME-Date: Wed, 13 Jan 2016 01:05:01 +0100
X-ME-IP: 86.214.79.135
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0)
 Gecko/20100101 Thunderbird/38.4.0
In-Reply-To: <4072A7C6-B09D-4847-971B-2914643B91D7@gmail.com>
X-Original-Sender: vicente.botet@wanadoo.fr
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 80.12.242.132 is neither permitted nor denied by best guess
 record for domain of vicente.botet@wanadoo.fr) smtp.mailfrom=vicente.botet@wanadoo.fr
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:23693
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/23693>

Le 13/01/2016 00:54, Howard Hinnant a =C3=A9crit :
> On Jan 12, 2016, at 5:49 PM, Vicente J. Botet Escriba <vicente.botet@wana=
doo.fr> wrote:
>> Hi,
>>
>> I've been working on a proposal (see attached document)
>>
>> Default swap/hash_value
>> Defining swap and hash_value P0029R0 as well as comparison operators, as=
 proposed in N4475, for simple classes is tedious, repetitive, slightly err=
or-prone, and easily automated.
>>
>> I propose to (implicitly) supply default versions of these two operation=
s, if needed. The meaning swap is to swap each member, and the meaning of h=
ash_value is to combine the members using hash_combine.
>>
>> If the simple defaults are unsuitable for a class, a programmer can, as =
ever, define more suitable ones or suppress the defaults. The proposal is t=
o add the operations as an integral part of C++ (like =3D), rather than as =
a library feature.
>>
>> The proposal follows the same approach as Default comparison as in N4475=
, that is, having default generated code for these basic operations only wh=
en needed and possible would makes the language simpler.
>>
>>
>> Any comments are welcome,
>
> For the hash part:  How does one switch to an alternate hash algorithm fo=
r type T without having to revisit the code for every base and member of T?=
  This is the most important part of both http://www.open-std.org/jtc1/sc22=
/wg21/docs/papers/2015/p0029r0.html and http://www.open-std.org/jtc1/sc22/w=
g21/docs/papers/2014/n3980.html.  If the std ropes people/programs into a s=
ingle hash algorithm (as it does today), then all of that code is vulnerabl=
e to attack.
>
> Only by allowing coders to change the hash algorithm for type T with O(1)=
 effort can C++ ever hope to stay ahead of the arms race in software securi=
ty.  The C++ committee itself is too slow and cumbersome (by at least 2 ord=
ers of magnitude) to supply (or even suggest) the best hashing algorithm fo=
r code that must hash values from untrusted input.
>
>
Hi Howard,

I understand your concern, and I'm taking this in account as I'm=20
suggesting the generation of hash_value as defined in P0029R0. What am I=20
missing?

Vicente

--=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/.

.
