220 29567 <CAJwqTS_OGEOUiUE6rSRrREV6Yx9+4Sj5gA8CDHeYgXnPwErW6Q@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Peet Nick <peetnick2@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: "A Proposal to Relax Constexpr Restrictions for
 some Reinterpret Casts" ?
Date: Mon, 28 Nov 2016 23:50:33 +0100
Lines: 248
Approved: news@gmane.org
Message-ID: <CAJwqTS_OGEOUiUE6rSRrREV6Yx9+4Sj5gA8CDHeYgXnPwErW6Q@mail.gmail.com>
References: <afbaf79e-305d-4408-98ab-5b35cfb11f27@isocpp.org>
 <CALnjya_VWQUMYGGd9tYy_cJWiwvsyUF2joMuCMPsPy=T6e15XA@mail.gmail.com>
 <CAJwqTS9XiyDK+7wWCRTCTjcnFnKQk6WudsrRTidgf4Ygoc0yng@mail.gmail.com> <14dc989b-7a2f-478b-b16e-b9297fb1782f@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a114717b6a4b0f60542644c2a
X-Trace: blaine.gmane.org 1480373437 32579 195.159.176.226 (28 Nov 2016 22:50:37 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 28 Nov 2016 22:50:37 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDS5DQNDSALBBOXJ6LAQKGQE2VMW3KA@isocpp.org Mon Nov 28 23:50:32 2016
Return-path: <std-proposals+bncBDS5DQNDSALBBOXJ6LAQKGQE2VMW3KA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f71.google.com ([209.85.215.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDS5DQNDSALBBOXJ6LAQKGQE2VMW3KA@isocpp.org>)
	id 1cBUkp-0007ST-2D
	for gclcip-std-proposals@m.gmane.org; Mon, 28 Nov 2016 23:50:31 +0100
Original-Received: by mail-lf0-f71.google.com with SMTP id g12sf20470105lfe.5
        for <gclcip-std-proposals@m.gmane.org>; Mon, 28 Nov 2016 14:50:35 -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=Wjs7btUun0i3MFx6IWkFQqjXw9lgjzbKvl7EW4llq5A=;
        b=eANV1WChK7E4U4K/DUw7naixRAn17ioRl/sz2Mcs0UxkgxImdS2TRNpYBYa3BgPxSE
         cPCT0b2DrJePJyT/H6qX9+yMSYvG77OaJzZdGEOHy+hoV+bDWt9e2BhxhlKaUdmwqJwQ
         fSyXEBRHBl8shd1+JZN9ivXEYuQqofQLwqsBjTB3rm9vQppjYXn3CKPKW4BzhQAMWYjU
         ZkeI9IitzD/RetIB845Zf7jf4VW35PX0QAke6cV+iNYEJ19+RiKI+rhJVqcejLKajg5W
         VcF7RH/8xMiGo5K42mbQbElqeBrmALwWTLTHj61m4t8QTZuf+26IHWU2Xg9AdgfuftR+
         GTUA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        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=Wjs7btUun0i3MFx6IWkFQqjXw9lgjzbKvl7EW4llq5A=;
        b=PqpZriAiZ+4FHwc4dw6huvnTAwVzWYRQVbq1Mr9/SPc14Xx6X9yAGSWW75WTRrRXrO
         BjPS/RS+BIsPmq/YZA8rk/lV9m9GZ5oIIc0sB/xkx3tbbLybRJFhPJHJlFBG/BPXMvxQ
         u/O9CNYYHF60/dl3NDXUbFs+1EF4x4pliWPl7FTSG6hOEadF0kCrJjPxEUaPjTCLUBOV
         JFrGt9MGIAej5MeOWX5l7yGkTbp6p/ClkAho63BnS+6cO3Ux9hGhvo3dqA88Q9uwbWu+
         RuLs1PL2fsQJvRVbZyS/hfzaLBp3LRj3+AQIEEwamGBzcR4iIoYBpSJMdAC+32U1AWxa
         lJzA==
X-Gm-Message-State: AKaTC00MggcyYONUqhQxyj3UnHecD8Z2cfRYVMKDgU+mbc5UZ1N/J7aiiXw6ip879DcNow==
X-Received: by 10.46.71.77 with SMTP id u74mr3650800lja.14.1480373435112;
        Mon, 28 Nov 2016 14:50:35 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.25.65 with SMTP id 62ls2201641wmz.8.gmail; Mon, 28 Nov 2016
 14:50:34 -0800 (PST)
X-Received: by 10.28.51.141 with SMTP id z135mr20192460wmz.109.1480373434132;
        Mon, 28 Nov 2016 14:50:34 -0800 (PST)
Original-Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com. [2a00:1450:400c:c09::241])
        by mx.google.com with ESMTPS id eh3si56545241wjd.247.2016.11.28.14.50.34
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 28 Nov 2016 14:50:34 -0800 (PST)
Received-SPF: pass (google.com: domain of peetnick2@gmail.com designates 2a00:1450:400c:c09::241 as permitted sender) client-ip=2a00:1450:400c:c09::241;
Original-Received: by mail-wm0-x241.google.com with SMTP id a20so21545430wme.2
        for <std-proposals@isocpp.org>; Mon, 28 Nov 2016 14:50:34 -0800 (PST)
X-Received: by 10.28.141.143 with SMTP id p137mr20370554wmd.5.1480373433575;
 Mon, 28 Nov 2016 14:50:33 -0800 (PST)
Original-Received: by 10.80.159.78 with HTTP; Mon, 28 Nov 2016 14:50:33 -0800 (PST)
In-Reply-To: <14dc989b-7a2f-478b-b16e-b9297fb1782f@isocpp.org>
X-Original-Sender: peetnick2@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 peetnick2@gmail.com designates 2a00:1450:400c:c09::241 as permitted sender)
 smtp.mailfrom=peetnick2@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-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:29567
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29567>

--001a114717b6a4b0f60542644c2a
Content-Type: text/plain; charset=UTF-8

Ah, I understand. Although I understand this now, I am not entirely sure
how it will be actually implemented. How would someone implement bit_cast
as a constexpr without having std::memcpy constexpr?

On Mon, Nov 28, 2016 at 11:35 PM, Edward Catmur <ed@catmur.co.uk> wrote:

> On Monday, 28 November 2016 22:04:42 UTC, Peet Nick  wrote:
> > I am not sure how that would help? The destination type must have the
> same size as the source type, how would that help me getting the "raw byte
> view" of an scalar/pod?
>
> You would bit_cast to an array (or std::array) of unsigned char of the
> same size as your pod.
>
> > On Fri, Nov 25, 2016 at 4:32 PM, Mathias Gaunard <mat...@gaunard.com>
> wrote:
> >
> > I think you would have better luck with the new function bit_cast which
> might end up being constexpr.
> >
> >
> >
> >
> > On 25 November 2016 at 11:32, Peet <peet...@gmail.com> wrote:
> >
> > Hello,
> >
> >
> > I was basically trying to implement a hash function in C++ using
> constant expressions (constexpr).
> > Sometimes it is necessary to cast a scalar type (or arrays) to cv
> unsigned/signed char* to simply get the bytes and do some calculation.
> > Although it seems that reinterpret_casts aren't allowed in constexpr
> (5.20/2.14).
> > Quickly googling this issue got me to this proposal: "A Proposal to
> Relax Constexpr Restrictions for some Reinterpret Casts" by Antony Polukhin
> [1].
> > This proposal relaxes the rule for reinterpret_cast in constexpr so that
> we can actually cast cv void* to cv unsigned/signed char*.
> > Although I couldn't find any discussions about this online, also it
> seems that the proposal hasn't been sent to the openstd mailing-list.
> > Does anyone know if this proposal is still "alive" and if this is being
> considered proposing?
> >
> >
> > Regards,
> > Nick
> >
> >
> > [1] https://apolukhin.github.io/constexpr_algorithms/reinterpret.html
> >
> >
> >
> >
> > --
> >
> > 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-proposal...@isocpp.org.
> >
> > To post to this group, send email to std-pr...@isocpp.org.
> >
> > To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/afbaf79e-305d-4408-
> 98ab-5b35cfb11f27%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-proposal...@isocpp.org.
> >
> > To post to this group, send email to std-pr...@isocpp.org.
> >
> > To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/CALnjya_VWQUMYGGd9tYy_
> cJWiwvsyUF2joMuCMPsPy%3DT6e15XA%40mail.gmail.com.
>
> --
> 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/14dc989b-7a2f-478b-
> b16e-b9297fb1782f%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/CAJwqTS_OGEOUiUE6rSRrREV6Yx9%2B4Sj5gA8CDHeYgXnPwErW6Q%40mail.gmail.com.

--001a114717b6a4b0f60542644c2a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Ah, I understand. Although I understand this now, I am not=
 entirely sure how it will be actually implemented. How would someone imple=
ment bit_cast as a constexpr without having std::memcpy constexpr?</div><di=
v class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Mon, Nov 28, 2016=
 at 11:35 PM, Edward Catmur <span dir=3D"ltr">&lt;<a href=3D"mailto:ed@catm=
ur.co.uk" target=3D"_blank">ed@catmur.co.uk</a>&gt;</span> wrote:<br><block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><span class=3D"">On Monday, 28 November 2016 22:04=
:42 UTC, Peet Nick=C2=A0 wrote:<br>
&gt; I am not sure how that would help? The destination type must have the =
same size as the source type, how would that help me getting the &quot;raw =
byte view&quot; of an scalar/pod?<br>
<br>
</span>You would bit_cast to an array (or std::array) of unsigned char of t=
he same size as your pod.<br>
<span class=3D""><br>
&gt; On Fri, Nov 25, 2016 at 4:32 PM, Mathias Gaunard &lt;<a href=3D"mailto=
:mat...@gaunard.com">mat...@gaunard.com</a>&gt; wrote:<br>
&gt;<br>
&gt; I think you would have better luck with the new function bit_cast whic=
h might end up being constexpr.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</span><span class=3D"">&gt; On 25 November 2016 at 11:32, Peet &lt;<a href=
=3D"mailto:peet...@gmail.com">peet...@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hello,<br>
&gt;<br>
&gt;<br>
&gt; I was basically trying to implement a hash function in C++ using const=
ant expressions (constexpr).<br>
&gt; Sometimes it is necessary to cast a scalar type (or arrays) to cv unsi=
gned/signed char* to simply get the bytes and do some calculation.<br>
&gt; Although it seems that reinterpret_casts aren&#39;t allowed in constex=
pr (5.20/2.14).<br>
&gt; Quickly googling this issue got me to this proposal:=C2=A0&quot;A Prop=
osal to Relax Constexpr Restrictions for some Reinterpret Casts&quot; by=C2=
=A0Antony Polukhin [1].<br>
&gt; This proposal relaxes the rule for reinterpret_cast in constexpr so th=
at we can actually cast cv void* to cv unsigned/signed char*.<br>
&gt; Although I couldn&#39;t find any discussions about this online, also i=
t seems that the proposal hasn&#39;t been sent to the openstd mailing-list.=
<br>
&gt; Does anyone know if this proposal is still &quot;alive&quot; and if th=
is is being considered proposing?<br>
&gt;<br>
&gt;<br>
&gt; Regards,<br>
&gt; Nick<br>
&gt;<br>
&gt;<br>
&gt; [1]=C2=A0<a href=3D"https://apolukhin.github.io/constexpr_algorithms/r=
einterpret.html" rel=3D"noreferrer" target=3D"_blank">https://apolukhin.git=
hub.<wbr>io/constexpr_algorithms/<wbr>reinterpret.html</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt;<br>
&gt; You received this message because you are subscribed to the Google Gro=
ups &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
&gt;<br>
</span>&gt; To unsubscribe from this group and stop receiving emails from i=
t, send an email to <a href=3D"mailto:std-proposal...@isocpp.org">std-propo=
sal...@isocpp.org</a>.<br>
&gt;<br>
&gt; To post to this group, send email to <a href=3D"mailto:std-pr...@isocp=
p.org">std-pr...@isocpp.org</a>.<br>
<span class=3D"">&gt;<br>
&gt; To view this discussion on the web visit <a href=3D"https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/afbaf79e-305d-4408-98ab-5b35cfb1=
1f27%40isocpp.org" rel=3D"noreferrer" target=3D"_blank">https://groups.goog=
le.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/afbaf79e-305d-4408-<wbr=
>98ab-5b35cfb11f27%40isocpp.org</a><wbr>.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt;<br>
&gt; You received this message because you are subscribed to the Google Gro=
ups &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
&gt;<br>
</span>&gt; To unsubscribe from this group and stop receiving emails from i=
t, send an email to <a href=3D"mailto:std-proposal...@isocpp.org">std-propo=
sal...@isocpp.org</a>.<br>
&gt;<br>
&gt; To post to this group, send email to <a href=3D"mailto:std-pr...@isocp=
p.org">std-pr...@isocpp.org</a>.<br>
<span class=3D"">&gt;<br>
&gt; To view this discussion on the web visit <a href=3D"https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/CALnjya_VWQUMYGGd9tYy_cJWiwvsyUF=
2joMuCMPsPy%3DT6e15XA%40mail.gmail.com" rel=3D"noreferrer" target=3D"_blank=
">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/CA=
Lnjya_<wbr>VWQUMYGGd9tYy_<wbr>cJWiwvsyUF2joMuCMPsPy%<wbr>3DT6e15XA%40mail.g=
mail.com</a>.<br>
<br>
</span><span class=3D"">--<br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
</span>To view this discussion on the web visit <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msgid/std-proposals/14dc989b-7a2f-478b-b16e-b9297f=
b1782f%40isocpp.org" rel=3D"noreferrer" target=3D"_blank">https://groups.go=
ogle.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/14dc989b-7a2f-478b-<w=
br>b16e-b9297fb1782f%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAJwqTS_OGEOUiUE6rSRrREV6Yx9%2B4Sj5gA=
8CDHeYgXnPwErW6Q%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAJwqTS_OGEOUiU=
E6rSRrREV6Yx9%2B4Sj5gA8CDHeYgXnPwErW6Q%40mail.gmail.com</a>.<br />

--001a114717b6a4b0f60542644c2a--

.
