220 34220 <74349bfe-bb5a-a2ce-4142-5d46103d1d9f@technion.ac.il> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Eyal Rozenberg <eyalroz@technion.ac.il>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Idea: Extension of structured bindings to
 definition of structs
Date: Wed, 30 Aug 2017 09:59:25 +0200
Lines: 80
Approved: news@gmane.org
Message-ID: <74349bfe-bb5a-a2ce-4142-5d46103d1d9f@technion.ac.il>
References: <59dcbbbc-c536-4b7b-9c88-0638fb0cd58a@technion.ac.il>
 <7b9bf263-d3ca-42bf-aed6-4c7606782a28@isocpp.org>
 <1762295.OciJaA9sdk@tjmaciei-mobl1>
 <ff2ceb41-caca-4659-9a7d-4da9c2046810@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: blaine.gmane.org 1504079995 5954 195.159.176.226 (30 Aug 2017 07:59:55 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 30 Aug 2017 07:59:55 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.2.1
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDHKZN7LR4ARB3XATHGQKGQEKAGOYDI@isocpp.org Wed Aug 30 09:59:49 2017
Return-path: <std-proposals+bncBDHKZN7LR4ARB3XATHGQKGQEKAGOYDI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f71.google.com ([74.125.82.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDHKZN7LR4ARB3XATHGQKGQEKAGOYDI@isocpp.org>)
	id 1dmxuS-0000eE-EH
	for gclcip-std-proposals@m.gmane.org; Wed, 30 Aug 2017 09:59:36 +0200
Original-Received: by mail-wm0-f71.google.com with SMTP id b187sf82813wmh.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 30 Aug 2017 00:59:43 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1504079983; cv=pass;
        d=google.com; s=arc-20160816;
        b=ctAjr955WZEOLY4xx8NpRt860XX8T96iJUXO7ERukFcHFQ6sgM0tncr4FrgTiSlWm/
         BN2fmubUzKZJ2HpDoUycLdePDA3Yg4XqI1vPzUm5LHBdzW58WvScVWPVtzFFNsu0bTWn
         ONM2IMEJ9CaqQjy30kDMRa/vQk8kQHlcEAWrzh+ah/pMZzQlt8fc81/T3PJf+FacJtFW
         tYtZlN2Lfv0quqxBt+t+yE/+uRFI1LZ5IQtB7gv/Tnlv2i/0sIg3xSpUvqZOWunm+5xZ
         QaDRh1WutorNd4R0i5ppEj8ydx63yqqBpDM6ahudU4Qi74AMWmZYnNNE6c5dHwONo2Ck
         3jHQ==
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-language
         :in-reply-to:mime-version:user-agent:date:message-id:from:references
         :to:subject:arc-authentication-results:arc-message-signature
         :dkim-signature:arc-authentication-results;
        bh=n5nuORGCCZtOMTyM1/g4R4AGmcdzpPzc36aD2FABAMc=;
        b=M+Ra2MvtF4wgrD8F95mXiJJcisVLYgOOm7CF2ko9GiawogbNQ7aHunRC/vxP7RNR9O
         GmHxjj1O/2m4TnzmSV9zpEdB5MN1gkHSuGTKnzdT7x3URs+hJ58DbF93U5Cd3OF77RIf
         77qKw9qeLAGH0hKlnHgCMNfqZ4igm3Upsmlhu0koPRs6Z801L1kd5NZ8aAniLoan/2VT
         IJqFpoDzSCao7RdJDFshJ1IQ/fAnm48RkPIAC7mF+f7L1m2NeOVgzXUNcK8Rv0THAPpb
         Y0VvjA7NxCaXRrBcBUxlKRSBsbKtvM6t4q2nghiYCrgn1I6n/fC0r5TEhxs1rJhoKxyb
         3uCQ==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of srs0=r1jhs=aa=technion.ac.il=eyalroz@cwi.nl designates 192.16.191.27 as permitted sender) smtp.mailfrom=SRS0=r1jhs=AA=technion.ac.il=eyalroz@cwi.nl
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-language: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=n5nuORGCCZtOMTyM1/g4R4AGmcdzpPzc36aD2FABAMc=;
        b=wvNC1HPmgn/8aHz/yhUEHwRz7QEr71x33rKII8R7ABnXALR42c/XHnpkhEZBZ6viqq
         63rECWZh9YfGVe+GBI6k01Gm810mla9RxKWjFC3Rj727A7O6/YVVv7QKzwXmFzj8/g5F
         p0Wn8WkR27S+iH8WhiuAoyUbBZgZEqnURUmc7RbiU1s1d9iq+tGROcPLDW2lZ6NAe0wW
         0X0EPXM4+9Qa22gQ6JW/TObKy7dVVgQV090fDRaan88KZ3OEyrlIT8drth8TkQDU+jCR
         6aAJKCczySWNh20YGht3Z0UHcaVdhXiucOOF1mIih7dBWVyc3GWKu5m8exU3wG3jx+cI
         IHmg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-language
         :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=n5nuORGCCZtOMTyM1/g4R4AGmcdzpPzc36aD2FABAMc=;
        b=tRJgM85Why0DWwWe9gQ2fS0y4Xgguwx7Ay5paqu/c5L47kV3vfAD7mxXgJqubWY4DV
         2C7NbkhtLDT1p+mvL7xxM98qa8LUFvTwsCjBhOSQuB1V54t0VQhQA73iSE5/HDwYqJuF
         WJcE82STDiP0gkV+H6whPuKMd7R8eRmWyK93RCdE5j23Ji+/LrzFSWCfGAiZ2FCZZznX
         4pdY/aQX6fCUm+1OE5O/GLcPuknNUwF6wvXKfjMYm7DTBgGubHFymsrGp/P0dtPEttQD
         5l1N6EvfzMMx9769UCQim88uMmPmIKCbPzOJitbiV/vhUh/BTuq2yH0MzIcJhx8XIf6H
         s 
X-Gm-Message-State: AHYfb5hhyXBdApof2/kUSH+KaqfqDnNIuByaxnzSMBJhIFwIjJCONLhM
	9H3rhbanqLsobA==
X-Google-Smtp-Source: ADKCNb4ikygJ5viUviY8f51slBURSDynFvb6mRcZn4DGKxdymNkqPXWw8rxVr9zpi1jQymhOkTiVnw==
X-Received: by 10.223.173.15 with SMTP id p15mr34382wrc.3.1504079983507;
        Wed, 30 Aug 2017 00:59:43 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.224.134 with SMTP id x128ls179195wmg.19.gmail; Wed, 30 Aug
 2017 00:59:41 -0700 (PDT)
X-Received: by 10.80.212.39 with SMTP id t39mr976443edh.228.1504079981935;
        Wed, 30 Aug 2017 00:59:41 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1504079981; cv=none;
        d=google.com; s=arc-20160816;
        b=IRkrlz5l8EQxClUg7qhBd12wmwPIA1bR+rbIysAYsmyoEOtlsKHo1zh1mrEyO3DgY2
         evBpeGUQsdrg2r8vQ6++efXlm7eLNDxxy9tDlWIEqgcKAstHR19EgrEKP+hJqQ+vuwWN
         MLfjmRtjqA0DjvEfpBLxGWV0B57K4v9sa3rPXcSR9E6W2lU0E3HFDJ8eAg6wJoZx+UHS
         e6bLyI0sIKYVPKhF9v3ffEtIC914EO8qWKmewb8GS7Kw1tc4ayxEewoRGlojqztwRFnz
         zELvGmAyGm3ynfm7kgRQDBbYucQKlo/Bto7/z9W7e3LR+ISDSkjaWolm7jOreB/SjzAP
         EDNQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:content-language:in-reply-to:mime-version
         :user-agent:date:message-id:from:references:to:subject
         :arc-authentication-results;
        bh=rSy1euFgOkdNBIqc0rqGvDQ2BISvZhVuWnZ45OsyKgU=;
        b=0uYlD8mg71MEsfFA4Y6AODgL+5HD+0Z7oDrWI9x52LJ7aN0tcnOmbRYdJsUtK9cEMS
         YvzOVSPFtEiXgh/ChewqmiLE37rnxlcX7du2/X0PM7CBDSCP/xTYBAdGO4v5RjmwU8st
         KoWe6pXveZad+NKEmh8NiXynrjtxm0D41rC4iEBfesOoMyW7vygeUIlGClQ+73xvnE6s
         iItFTJGRZQRFW/XgiPt+oiVcIw636wmZ7+NsCYLrUQjhUm62fG3iVTZCZkEO29e1nzjb
         CFhh3tpNrTHNuh6t+dLcUjnHnNBNLejcSpZbAMFrDkVK+36Dq0vmTGT79oQD+vHzr9nU
         80pA==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of srs0=r1jhs=aa=technion.ac.il=eyalroz@cwi.nl designates 192.16.191.27 as permitted sender) smtp.mailfrom=SRS0=r1jhs=AA=technion.ac.il=eyalroz@cwi.nl
Original-Received: from fester.cwi.nl (fester.cwi.nl. [192.16.191.27])
        by mx.google.com with ESMTPS id j4si4160131edk.222.2017.08.30.00.59.41
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 30 Aug 2017 00:59:41 -0700 (PDT)
Received-SPF: pass (google.com: domain of srs0=r1jhs=aa=technion.ac.il=eyalroz@cwi.nl designates 192.16.191.27 as permitted sender) client-ip=192.16.191.27;
Original-Received: from fester.cwi.nl (fester.cwi.nl [192.16.191.27])
	by fester.cwi.nl (8.14.4/8.12.3) with ESMTP id v7U7xfiq007276;
	Wed, 30 Aug 2017 09:59:41 +0200
Original-Received: from [10.180.31.178] (host191-2.natpool.mwn.de [138.246.2.191])
	(authenticated bits=0)
	by fester.cwi.nl (8.14.4/8.12.3) with ESMTP id v7U7xVfh007269
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);
	Wed, 30 Aug 2017 09:59:39 +0200
In-Reply-To: <ff2ceb41-caca-4659-9a7d-4da9c2046810@isocpp.org>
Content-Language: en-GB
X-Original-Sender: eyalroz@technion.ac.il
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of srs0=r1jhs=aa=technion.ac.il=eyalroz@cwi.nl designates
 192.16.191.27 as permitted sender) smtp.mailfrom=SRS0=r1jhs=AA=technion.ac.il=eyalroz@cwi.nl
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:34220
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/34220>

You would be using an unnamed struct for the same reason you use an
"unnamed type" for non-struct variables with auto. We write:

  auto x = expr;

although we could write

  using whatever_t = decltype(expr);

  // ...

  whatever_t x = expr;

except we do it for several values which are grouped together in a
struct. The second option does the exact same thing, but it's annoying
and verbose.


On 27/08/17 16:11, Nicol Bolas wrote:
> difficult to understand the code when actually using a tuple, why would
> I be using an /unnamed/ struct to solve this? Would it not make more
> sense to do this:
> 
> |
> structRealName
> {
>   RealName(conststd::tuple<int,double>&);
> 
>   inta_member;
>   doubleother_member;
> };
> |
> 
> And then in the actual function:
> 
> |
> RealNames =std::make_tuple(1,2.3);
> |
> 
> This improves code reuse, since `RealName` can be used in multiple
> places. It improves readability, since `RealName` would convey semantic
> information about the collection of values that `decltype(s)` cannot.
> And so forth. The trivial repetition of typing the type names in two (or
> even three) places in `RealName` will be meaningless next to how often
> `RealName` is used.
> 
> Presumably, the reason I'm /not/ using structured binding is because I
> want to pass the collection `s` around to other people, yes? Otherwise,
> you would just use structured binding to provide the semantic info.
> Given that this is the case, we need a proper name so that we understand
> what this aggregate actually means.
> 
> If this is a one-off case, where you're only calling one function that
> has a `tuple` API in one place... why are you creating an object for the
> values at all? If it's a one-off, use structured binding, or just
> tough-through the `get<>` interface for that one function.
> 
> What circumstances would I be in where I would be writing an /inline
> struct/ to convert this object? If it happens frequently enough to
> obfuscate my code, the best solution is a named struct. If it's not that
> frequent, just use structured binding or the actual return value.
> 
> -- 
> 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
> <mailto:std-proposals+unsubscribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org
> <mailto:std-proposals@isocpp.org>.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ff2ceb41-caca-4659-9a7d-4da9c2046810%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ff2ceb41-caca-4659-9a7d-4da9c2046810%40isocpp.org?utm_medium=email&utm_source=footer>.

-- 
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/74349bfe-bb5a-a2ce-4142-5d46103d1d9f%40technion.ac.il.

.
