220 33272 <CAFk2RUa+-_mw2QNh_pYR-QakwEh60OgoeCMaGsWW1yansRrV+w@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Ville Voutilainen <ville.voutilainen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Adding operator overloading case to structure binding
Date: Fri, 21 Jul 2017 17:15:24 +0300
Lines: 98
Approved: news@gmane.org
Message-ID: <CAFk2RUa+-_mw2QNh_pYR-QakwEh60OgoeCMaGsWW1yansRrV+w@mail.gmail.com>
References: <d992c1f5-72f1-4127-9b53-3a4d360a58d6@isocpp.org> <CAPCFJdSxx8TBEC+bdPr+MnZPBYvZKrFK350zOnwE7U7Ug0BmmQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1500646529 12352 195.159.176.226 (21 Jul 2017 14:15:29 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 21 Jul 2017 14:15:29 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC5JHI7A7ALRB7UYZDFQKGQEEQ5EOHY@isocpp.org Fri Jul 21 16:15:23 2017
Return-path: <std-proposals+bncBC5JHI7A7ALRB7UYZDFQKGQEEQ5EOHY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt0-f199.google.com ([209.85.216.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRB7UYZDFQKGQEEQ5EOHY@isocpp.org>)
	id 1dYYi9-0002mH-Pq
	for gclcip-std-proposals@m.gmane.org; Fri, 21 Jul 2017 16:15:21 +0200
Original-Received: by mail-qt0-f199.google.com with SMTP id n42sf32144698qtn.10
        for <gclcip-std-proposals@m.gmane.org>; Fri, 21 Jul 2017 07:15:27 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1500646527; cv=pass;
        d=google.com; s=arc-20160816;
        b=xN0ubU316ZZcxfNUC+/nPS9IN3s426jzr2N4r74rU/GLlE6sD6mo6R573r5MxLNkwY
         qxkGi+j11r/5ImJ8UxHRjBZ/0Hvm/0ge5kzWBvb8CH3g2w48nJH5VNNTR5o+qkud9W0E
         y97ss36jYpQBT5+/nQ62SM+rY8hTaDjwEeXxn+6tSTglFX8fk2MhrOEFWp+atCv6BZ9N
         JBsXLKPAUFBBXgPipEITPbQ4sL6OqC+kE+fyu/leL/rB0GZghP9j2M2nMQUpaDtID5iB
         e1L/9NLiCUwGWn2RnVQb40dLVNWTouxreAtIZLAOxK0HS5Mp+Vd57HBTY8msId0uiR0c
         y4gw==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:content-transfer-encoding
         :to:subject:message-id:date:from:references:in-reply-to:mime-version
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=bDrNzyVN/prnvMLaI4BN6Qb4LrgsIKJBNmu04fdi6Fs=;
        b=DJTlLH9eHRC57IkEcEHdG714PmP09xh8pI9T7wi5DbQrjYYDnTj566bOg0Y/XpJ2jN
         lVweUC4SBpmg77vFof2k6fkQ7Rw6mXUyBzHUUWGFe8Bbo9T2HFSlMDbAmAld3mb0qBxw
         TluwUAVlteOoA+Vpp+BJ5lP1WcBUwIy9ZHLhuOWGgF3Fl9JXvcRntroQ/k05LfS7j9FT
         AF69oSRxp29gGYgB1DBVsuABQSTEvEqvSSWAn1xBwcFjM1HJ6D1GgeZyLH89iJBzBMGP
         mJ+B3yTij/PCUw2F6LF/RJt8AXPzcBl0SfrhlmlJuQ3ClnpdMzYYHPVpQIHc8PKA9jMB
         UKew==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=VO1SGFLw;
       spf=pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400c:c08::22e as permitted sender) smtp.mailfrom=ville.voutilainen@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :content-transfer-encoding:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=bDrNzyVN/prnvMLaI4BN6Qb4LrgsIKJBNmu04fdi6Fs=;
        b=SWWdGfuPoTmeWBnoFQLw6S+SPVVBuOYuGpnkQ5LUbl3d0Ma8sN5bzgLRKimZCXKdmH
         ExRrZk8FxbmBcRqdkG6nKHLu6QWKr64ozHVGfF4l1Tz1i/JaeZuZd3DgXgeSskVkD4bi
         begcv1QhU/tbOZToD+4cZNUm0xq1IzDMUyZdtJqlAuC7ux3VMIDlRz7yGUQs1X5a3RqQ
         YGzQbn+4fKVongehS93XbLVBJbbZyLAMv4gOIUZxrwmDjsXfyiL832Mhupil/q1t2Q2J
         SrVjJYV1iJ55f7pCLkoBG1Ehih4MYSfpbOqQTytR7B24ICPaa45tjarz0Vhenqfe0f0u
         YQyA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to: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=bDrNzyVN/prnvMLaI4BN6Qb4LrgsIKJBNmu04fdi6Fs=;
        b=X/Wa3e1j8Sxud/EBgwqvAevdhcOOR/BF9f6uzws2IMgzPB7gI29bJywKIXxnfFieYk
         NlzH2GY9eulKnH9c2KziQ+8PBOQ2EgMhG33x9a2kI3hbk0QAn4FhxCf7tnfaX/wB7vhx
         SMeShdlDPWcRg4EYL+R178qTzWScrMDjveJyr+Js9faMrDpw6RXEul6zgmYL6HFZr4Bh
         ctktbFYXCPulj5UNFEH2LH3QrEO0D/kcevV8xTRp1PkwDN7C9uC8zdznMxj20J/XqgeA
         cWPeW0MhBJXZziUNMAiz1nPjSXXaXcCnW5L3E1ZRkJUNpjudCZBqTjHAXRwKFrIhhSJz
         K3J 
X-Gm-Message-State: AIVw112Uux1Mt15YrgTu/uXzs3Pda6w49z3YNXfQJZv5oQkk3Qlc7R92
	jJO9vz6A5EpmEjwI
X-Received: by 10.200.42.240 with SMTP id c45mr4558439qta.60.1500646527171;
        Fri, 21 Jul 2017 07:15:27 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.160.210 with SMTP id j201ls8154939ioe.38.gmail; Fri, 21
 Jul 2017 07:15:25 -0700 (PDT)
X-Received: by 10.159.35.117 with SMTP id 108mr4894373uae.8.1500646525844;
        Fri, 21 Jul 2017 07:15:25 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1500646525; cv=none;
        d=google.com; s=arc-20160816;
        b=QWmvnTNXQkvG9JErxCgJN1eb4J7TVWNNO5EBpndMIlyOyz2iRaptCbK03iMOV2MCmc
         7tzl0VxSZhlVhS2uewB2bGgTABLWf9Cq7JZqcfcV3n2AkpcLvJlDgCrvZovSpCtmTHND
         cwBh6ZrJes9/r2ALhglqY9FRd58xR6QfbTqYckZMGhR2lAR1HmClo5+9ky4voQKfEnTs
         RBJEkt/hJ8g08qlzsACin3zJdOkftZEQOFVrScVt+M6Ncb1+rA4udnxQ0xO5oxXN1AV/
         7vxfYw6XGjNq2qZHFnShtoi7e28TKicPqrIM0HoFfO0owU/Oi7Nd3Z6XZxKToXgAG7OE
         BNgg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:to:subject:message-id:date:from
         :references:in-reply-to:mime-version:dkim-signature
         :arc-authentication-results;
        bh=czek8S5eF95Piza+rp2ivO3kNxnfjNguwpvntTjdp28=;
        b=Hy5v4mrHgQn+ENKWnkJz4QfQW9Zaa6MwscExpDOhxRQrFPv0sZrmIkjotDioZ6nibh
         MWNiUpN0JLnJDnROOnY1U17e0uryK0WuKWFT2ILg3SUI9Y5/sHYMrNnNmkT7pgie+dgi
         lpj3c5zqSw21qvmNekvCOZJ9LJATkJ53dHERdAtfdTNEcAjdCranZE9pPAwm0/ERAuce
         yxSns7XP6VF40VRmTjU5dSLt1NvfeTEgANj5P5SThyOGq7IJ6Bl1nbwfflou8URMxlk6
         lfOP90b1gLlpMcHV4X7v+7JCAmNAJ7brlFwU/ZC589luuGbQLduzscLpXYTo8Vcz3Gyg
         osnA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=VO1SGFLw;
       spf=pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400c:c08::22e as permitted sender) smtp.mailfrom=ville.voutilainen@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-ua0-x22e.google.com (mail-ua0-x22e.google.com. [2607:f8b0:400c:c08::22e])
        by mx.google.com with ESMTPS id 91si387729uah.327.2017.07.21.07.15.25
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 21 Jul 2017 07:15:25 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400c:c08::22e as permitted sender) client-ip=2607:f8b0:400c:c08::22e;
Original-Received: by mail-ua0-x22e.google.com with SMTP id f9so46555377uaf.4
        for <std-proposals@isocpp.org>; Fri, 21 Jul 2017 07:15:25 -0700 (PDT)
X-Received: by 10.176.3.132 with SMTP id 4mr4864100uau.51.1500646525071; Fri,
 21 Jul 2017 07:15:25 -0700 (PDT)
Original-Received: by 10.103.103.65 with HTTP; Fri, 21 Jul 2017 07:15:24 -0700 (PDT)
In-Reply-To: <CAPCFJdSxx8TBEC+bdPr+MnZPBYvZKrFK350zOnwE7U7Ug0BmmQ@mail.gmail.com>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.b=VO1SGFLw;       spf=pass (google.com: domain of
 ville.voutilainen@gmail.com designates 2607:f8b0:400c:c08::22e as permitted
 sender) smtp.mailfrom=ville.voutilainen@gmail.com;       dmarc=pass (p=NONE
 sp=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-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:33272
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33272>

On 21 July 2017 at 17:04, Micha=C5=82 Dominiak <griwes@griwes.info> wrote:
> There is currently a customization point (or, a set of customization
> points...) for this feature in the language: std::tuple_size,
> std::tuple_element, and get(). They aren't pretty to use, but I'm not
> convinced your proposed way to customize the behavior is really better.

Right, however, in general, types convertible to types that can be
structured-bound aren't supported by structured
bindings. If you have
struct X : tuple<int, int> {};
you can't do structured bindings on it.

On the other hand, allowing conversions gets tricky; what if I have
data members in X? Then it 'obviously' shouldn't
do structured bindings via a conversion to tuple, so what we would get
via the conversions is not necessarily better.
It would certainly make the rules more complex.

>
> On Fri, Jul 21, 2017 at 3:42 PM Logan Song <ashenveilsong@gmail.com> wrot=
e:
>>
>> According to the C++ standard, structure binding has three cases right
>> now:
>>
>> binding an array
>> binding a tuple-like type
>> binding to public data members
>>
>> For example:
>> #include <cstddef>
>> #include <tuple>
>>
>> class tag_ptr {
>> private:
>>     void* holder;
>>
>> public:
>>     explicit operator ::std::tuple<void*, ::std::byte>() {
>>         return ::std::tuple(ptr(), tag());
>>     }
>>
>>     void* ptr() {...}
>>     ::std::byte tag() {...}
>> };
>>
>> tag_ptr tp;
>>
>> auto ptr =3D tp.ptr();
>> auto tag =3D tp.tag(); //Uhhhh
>>
>> //error: cannot decompose non-public member 'holder' of 'tag_ptr'
>> //auto [ptr, tag] =3D tp;
>>
>> Assume we have a class tag_ptr. It could store some bits compressed with=
 a
>> pointer, which we couldn't expose it directly.
>> As we can see, it's very cumbrous to init variables one by one.
>>
>> But if we relax the restrictions of rule2 to allow binding type which ha=
s
>> tuple-like type cast operator.
>> The code will be more clear and it could make interfaces more graceful.
>>
>> That's my proposal. :)
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/d992c1f5-72=
f1-4127-9b53-3a4d360a58d6%40isocpp.org.
>
> --
> 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/CAPCFJdSxx8T=
BEC%2BbdPr%2BMnZPBYvZKrFK350zOnwE7U7Ug0BmmQ%40mail.gmail.com.

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAFk2RUa%2B-_mw2QNh_pYR-QakwEh60OgoeCMaGsWW1yans=
RrV%2Bw%40mail.gmail.com.

.
