220 31456 <CAGNvRgAwqbp=ZrDSCFAWPc=KAviqPa+Bx9XEL-3fvtqy2=VS1w@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: =?UTF-8?Q?Daniel_Kr=C3=BCgler?= <daniel.kruegler@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Allow access to std::array's underlying C-array
Date: Mon, 6 Mar 2017 19:33:16 +0100
Lines: 35
Approved: news@gmane.org
Message-ID: <CAGNvRgAwqbp=ZrDSCFAWPc=KAviqPa+Bx9XEL-3fvtqy2=VS1w@mail.gmail.com>
References: <52147c7c-ff38-4eaf-9f73-7f40628e9d58@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 1488825214 3199 195.159.176.226 (6 Mar 2017 18:33:34 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 6 Mar 2017 18:33:34 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCT7RVFA4QORB3OW63CQKGQESBYQCVI@isocpp.org Mon Mar 06 19:33:28 2017
Return-path: <std-proposals+bncBCT7RVFA4QORB3OW63CQKGQESBYQCVI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f72.google.com ([209.85.215.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCT7RVFA4QORB3OW63CQKGQESBYQCVI@isocpp.org>)
	id 1ckxRi-00088s-1A
	for gclcip-std-proposals@m.gmane.org; Mon, 06 Mar 2017 19:33:22 +0100
Original-Received: by mail-lf0-f72.google.com with SMTP id v2sf83955650lfi.2
        for <gclcip-std-proposals@m.gmane.org>; Mon, 06 Mar 2017 10:33:28 -0800 (PST)
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
         :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=hcMdcnfNYdZlUb4ohi8pqnFibwqPvfwmZdpXSpU+d/M=;
        b=0SmrIVClt0FFQ8zCJ1ltTmEyeKGbP81rWUC0Uz+wp2uPUWpKgxrf3NyEoEgBYOvqYr
         p5t1rVIMxCB1WFwxE8Yx0+0Yw8m72aU+RHlE+2YsxL9pWGNHg15vUdkVdAx5g05RXeqJ
         qMQ0tJIm+BSBUnmbPvbXuNCu0htimT8O775vOAX4z7HLX7eqls3bw99103kNXrJEe+VO
         hjiLGwqAGed0myPpZpvBAK6HCvRecJd9ygAdwD/JKTJUiYOGRvU5v73z0jmBGyDSzvro
         MTNJsHuVxhaBxdBBmMRg249R7v1rHEXDZmsDJiQtt/4kmZN5d3A3M7ZihRq2fjBpMjCD
         DKlA==
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: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=hcMdcnfNYdZlUb4ohi8pqnFibwqPvfwmZdpXSpU+d/M=;
        b=MV3fO50T/eky8Qxj1NYh+XIJsWvKL+j7SphD8W/ymWOF3tUdmf0i6ug8RUkihyToGZ
         +k0dZvKvCv2b3pgCRkX4s3fUgXjUTv/HREDOv+lQHbIguyFDWG2TJpggObSegiCKObkc
         FUzN7NiIo6ZZVrJklkHOyF88ZFtpeIwzXu7trKeoAsBws2pS1UjrNhUJD6flXv9YVlf7
         0Jyu8RaPJXr0iuP6ZlxdiEu9tkDar2PAEyZ1md8G/IgAYFDO6jGc9MwWR3N9UK22W6Es
         f+/MMJeHuztWLcjSnlC7AVx1sOGzYTC5V8w6BfsBILdAuUXmfCYUnNKW7dQO6DhR+AhK
         Vksg==
X-Gm-Message-State: AMke39myr2v4aGOKQrUOpK+iRw4wAKKr34g2NPYpGZ5sSC1VHgucEPaD3VXl2CgxEv6qXQ==
X-Received: by 10.25.169.14 with SMTP id s14mr2021166lfe.3.1488825208323;
        Mon, 06 Mar 2017 10:33:28 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.207.206 with SMTP id f197ls481250wmg.22.gmail; Mon, 06 Mar
 2017 10:33:17 -0800 (PST)
X-Received: by 10.28.31.139 with SMTP id f133mr15230775wmf.25.1488825197629;
        Mon, 06 Mar 2017 10:33:17 -0800 (PST)
Original-Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com. [2a00:1450:400c:c09::232])
        by mx.google.com with ESMTPS id e8si18807041wre.85.2017.03.06.10.33.17
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 06 Mar 2017 10:33:17 -0800 (PST)
Received-SPF: pass (google.com: domain of daniel.kruegler@gmail.com designates 2a00:1450:400c:c09::232 as permitted sender) client-ip=2a00:1450:400c:c09::232;
Original-Received: by mail-wm0-x232.google.com with SMTP id v186so71363346wmd.0
        for <std-proposals@isocpp.org>; Mon, 06 Mar 2017 10:33:17 -0800 (PST)
X-Received: by 10.28.218.80 with SMTP id r77mr14343750wmg.0.1488825197185;
 Mon, 06 Mar 2017 10:33:17 -0800 (PST)
Original-Received: by 10.28.47.211 with HTTP; Mon, 6 Mar 2017 10:33:16 -0800 (PST)
In-Reply-To: <52147c7c-ff38-4eaf-9f73-7f40628e9d58@isocpp.org>
X-Original-Sender: daniel.kruegler@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 daniel.kruegler@gmail.com designates 2a00:1450:400c:c09::232 as permitted
 sender) smtp.mailfrom=daniel.kruegler@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:31456
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31456>

2017-03-06 18:43 GMT+01:00  <dan@soundradix.com>:
> Following my question on SO, I'd like to propose changing the data() method
> of std::array to return a reference to the underlying C-array instead of
> returning a raw pointer.
> This would allow backwards compatibility with older functions which accept a
> reference/pointer to a C-array of a known size.
> Currently, if you use an std::array, and have such a function, there is no
> way AFAIK to call it on the underlying C-array without a reinterpret_cast.
>
> I see no real disadvantage to this change - if you really want, you can
> always decay the C-array reference to a raw pointer reference.
>
> Or at least, in case it's considered valuable to keep the data() method
> which returns the raw pointer by value, I suggest adding a c_array() method
> instead which returns a reference to the C-array.

Exactly this had been suggested in the past, but failed:

http://cplusplus.github.io/LWG/lwg-closed.html#930

If you want it, this requires a proposal. Some previous arguments
against it ("[..] until we have implementation experience with
reference qualifiers") are mood now, but nonetheless the proposal
should try to give a good rationale for it.

Thanks,

- Daniel

-- 
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/CAGNvRgAwqbp%3DZrDSCFAWPc%3DKAviqPa%2BBx9XEL-3fvtqy2%3DVS1w%40mail.gmail.com.

.
