220 32090 <4259d7dc-f060-dc27-5004-37bf4726e456@wanadoo.fr> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Decomposition of std::complex.
Date: Fri, 14 Apr 2017 19:01:55 +0200
Lines: 1844
Approved: news@gmane.org
Message-ID: <4259d7dc-f060-dc27-5004-37bf4726e456@wanadoo.fr>
References: <74a45396-2e35-4231-86b9-4caceb531239@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------405F0B4D6009C044D992406E"
X-Trace: blaine.gmane.org 1492189320 27953 195.159.176.226 (14 Apr 2017 17:02:00 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 14 Apr 2017 17:02:00 +0000 (UTC)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0)
 Gecko/20100101 Thunderbird/45.8.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH67CONY4PBBBMBYTDQKGQEMM2NSRY@isocpp.org Fri Apr 14 19:01:55 2017
Return-path: <std-proposals+bncBDH67CONY4PBBBMBYTDQKGQEMM2NSRY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f69.google.com ([209.85.215.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDH67CONY4PBBBMBYTDQKGQEMM2NSRY@isocpp.org>)
	id 1cz4bb-0007AK-Cw
	for gclcip-std-proposals@m.gmane.org; Fri, 14 Apr 2017 19:01:55 +0200
Original-Received: by mail-lf0-f69.google.com with SMTP id p10sf14230159lfe.11
        for <gclcip-std-proposals@m.gmane.org>; Fri, 14 Apr 2017 10:02:01 -0700 (PDT)
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: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=u9A7y+OArsz/J0NwD8K6nfahgAQxY89YbZo5KXdvwrA=;
        b=yBO641uIDjq5sLw85HDPOnVCJ+qcKxZXinPlTcvIhU6FF/WkPBn4yKq0UkSHIS0Q5z
         0R1s3jDxCAYx006PdEcHDRtC6A4ND3i1gv1coqyB+FoqeBuFSrblQJDfJ9s/taLmALa+
         DpSnXR4uCy+c7iPWR3o5hwXX2O4I8P9io8hy8LLxYc/405CAtdEcRd7K4+1BAEG+FK8n
         r0VOV9gyYYwrYCFkMOC7AAsf1cG+JN9X/ox6W8k4MCTUg5mz8b7ud6yprHJg0pw1gtAU
         Uwqd3kK9wnoj6gBN8QGukPI7z8TI8xEJ5xGqWMtHlVUzamAxtgiEjzsbWuOpZsVvHaOo
         zP6g==
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: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=u9A7y+OArsz/J0NwD8K6nfahgAQxY89YbZo5KXdvwrA=;
        b=Gih5syfeQ3m2vRU29C0+U8H+S5eD7WSTfP1Ubp5Tyuh2otn4ZfrQhX+9pLqAO1inV5
         MLaZzpp8/6HUo3BD02DXLajo067VFUeOmOTypBp+TliI4y2d10rGPHQyVQAJ9X86apVW
         eQ8FXt466+/iGuDL/UYL2Oke9AAOYl+169Pes8XoSCmzmXefZnA7KKQzgpJ+mM+NOxQN
         /HRiYDDs82XVSfKvgo8kKauDI9FAHwlR6SLhnAkWfPWbw1KYYxeaLnNSFCId5Utcscs1
         QeRYbEGpY1zFeFIaJuNDoWZlXJZHjO21FgRwkDiiP6xj+fYg97y/i2Qne5kUqy4AQWik
         2ygw==
X-Gm-Message-State: AN3rC/4KEI/yjh0uk60DtACZlCXB5ra4Ottc2wIGiwMy7/k9qr6XbwHl
	OBwgE9je8pSnTQ==
X-Received: by 10.46.0.230 with SMTP id e99mr955225lji.15.1492189320970;
        Fri, 14 Apr 2017 10:02:00 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.208.1 with SMTP id h1ls341595wmg.16.gmail; Fri, 14 Apr 2017
 10:01:57 -0700 (PDT)
X-Received: by 10.28.69.147 with SMTP id l19mr8175553wmi.91.1492189317147;
        Fri, 14 Apr 2017 10:01:57 -0700 (PDT)
Original-Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr. [80.12.242.125])
        by mx.google.com with ESMTPS id i124si4177997wmd.116.2017.04.14.10.01.56
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=AES128-SHA bits=128/128);
        Fri, 14 Apr 2017 10:01:57 -0700 (PDT)
Received-SPF: neutral (google.com: 80.12.242.125 is neither permitted nor denied by best guess record for domain of vicente.botet@wanadoo.fr) client-ip=80.12.242.125;
Original-Received: from imac-de-vicente-botet-escriba.home ([81.53.17.208])
	by mwinf5d79 with ME
	id 8H1v1v00L4VM3XV03H1vAj; Fri, 14 Apr 2017 19:01:56 +0200
X-ME-Helo: imac-de-vicente-botet-escriba.home
X-ME-Auth: dmljZW50ZS5ib3RldEB3YW5hZG9vLmZy
X-ME-Date: Fri, 14 Apr 2017 19:01:56 +0200
X-ME-IP: 81.53.17.208
In-Reply-To: <74a45396-2e35-4231-86b9-4caceb531239@isocpp.org>
X-Original-Sender: vicente.botet@wanadoo.fr
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 80.12.242.125 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-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:32090
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32090>

This is a multi-part message in MIME format.
--------------405F0B4D6009C044D992406E
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 14/04/2017 =C3=A0 00:11, 3dw4rd@verizon.net a =C3=A9crit :
> In many uses of std::complex
> one wants to capture the real and imaginary parts in separate=20
> variables either to use them in subsequent calculations or to modify=20
> them individually.
> There are many options:
>
> These options reflect an over-encapsulation of std::complex, which=20
> everyone agrees is a struct with two floating point numbers, real part=20
> and imaginary part, in that order.
> Attempting to use a decomposition declaration for a complex number is=20
> an error because of the pretension (ostensibly for C compatibility)=20
> the complex numbers are opaque.
Humm, it is not so opaque as you can get the representation as a c-array.

This means that we should already be able to apply structured binding=20
using the cast

|auto&[p,q]=3D|||reinterpret_cast<Tp(&)[2]>(z)|;
|
Nevertheles I agree with you that your proposal makes this cleaner and=20
more explicit. Complex should be a ProductType.
>
> The rvalue and lvalue decomposition of std::complex can be=20
> accomplished with a simple pure-library extension:
> Provide a tuple interface to std::complex.
>
> |
> // Tuple interface to class template complex.
> #define__cxx_lib_tuple_complex 201705
>
> // Declare tuple_size.
> template<typenameRealTp>
> classtuple_size;
>
> // Partial specialization for std::complex.
> template<typenameRealTp>
> structtuple_size<std::complex<RealTp>>
> :publicintegral_constant<std::size_t,2>{};
>
> // Declare tuple_element.
> template<std::size_t _Int,typenameRealTp>
> classtuple_element;
>
> // Partial specialization for std::complex.
> template<std::size_t _Int,typenameRealTp>
> structtuple_element<_Int,std::complex<RealTp>>
> {
> static_assert(_Int <2,"index is out of bounds");
> typedefRealTptype;
> };
>
> // Decompose complex as rvalues.
> template<std::size_t _Int,typenameRealTp>
> constexprconstRealTp
> get(conststd::complex<RealTp>&z)
> {
> static_assert(_Int <2,"index is out of bounds");
> return_Int =3D=3D0?z.real():z.imag();
> }
>
> // Decompose complex as lvalues.
> template<std::size_t _Int,typenameRealTp>
> constexprRealTp&
> get(std::complex<RealTp>&z)
> {
> static_assert(_Int <2,"index is out of bounds");
> autow =3Dreinterpret_cast<RealTp(&)[2]>(z);
> return_Int =3D=3D0?w[0]:w[1];
> }
>
> |
>
I believed that this reinterpret_cast was UB, but as you note below, it=20
is defined by the standard.

>
> Then we have the following behavior:
>
> |
> template<typenameTp>
> void
>   test_complex_decomp()
> {
>     std::complex<Tp>z(1,2);
>
> auto[x,y]=3Dz;
>     std::cout <<"z =3D "<<z <<'\n';
>     std::cout <<"z parts:"<<' '<<x <<' '<<y <<'\n';
>
> |
|I'm not sure if you believe this implies a call to get to decomponse as=20
rvalues, but it isn't.
It just copies the complex to a temporary, ||and then calls get on this=20
temporary.

|
> |
>     z.real(3);
>     z.imag(4);
>     std::cout <<"z =3D "<<z <<'\n';
>     std::cout <<"z parts:"<<' '<<x <<' '<<y <<'\n';
>
>     std::complex<Tp>w(1,2);
>     std::cout <<"w =3D "<<w <<'\n';
> auto&[p,q]=3Dw;
>
> |
|I'm not sure if you believe this implies a call to get to decomponse as=20
lvalues, but it isn't.
||It just takes store a reference to the complex in a temporary, and=20
then calls get on this temporary reference.
|
> |
> |

> |
>     w.real(3);
>     w.imag(4);
>     std::cout <<"w =3D "<<w <<'\n';
>     std::cout <<"w parts:"<<' '<<p <<' '<<q <<'\n';
>
>     p =3D-5;
>     q =3D-6;
>     std::cout <<"w =3D "<<w <<'\n';
>     std::cout <<"w parts:"<<' '<<p <<' '<<q <<'\n';
>
> return;
> }
>
> int
> main()
> {
>   test_complex_decomp<double>();
> return0;
> }
>
> |
>
>
> -------------------
> z =3D (1,2)
> z parts: 1 2
> z =3D (3,4)
> z parts: 1 2
> w =3D (1,2)
> w =3D (3,4)
> w parts: 3 4
> w =3D (-5,-6)
> w parts: -5 -6
> -------------------
>
> The static cast, ugly as it is, is required to be valid by conforming=20
> implementations of complex.
Are you talking of the reinterpret_cast?
> 29.5 Complex numbers [complex.numbers] p4, specifically 4.1-4.3.
> This solution elegantly isolates user code from this wart.
I believe that you need const/non const lvalue/rvalue decomposition, but=20
maybe I'm wrong.

|template<std::size_t _Int,typenameRealTp>
constexprconstRealTp&&
get(const std::complex<RealTp>&& z)
{
static_assert(_Int <2,"index is out of bounds");
return_Int =3D=3D0?z.real():z.imag();
}

|
||template<std::size_t _Int,typenameRealTp>
constexprRealTp&&
get(std::complex<RealTp>&& z)
{
static_assert(_Int <2,"index is out of bounds");
return_Int =3D=3D0?z.real():z.imag();
}
| // Decompose complex as lvalues.
template<std::size_t _Int,typenameRealTp>
constexprRealTp&
get(std::complex<RealTp>&z)
{
static_assert(_Int <2,"index is out of bounds");
autow =3Dreinterpret_cast<RealTp(&)[2]>(z);
return_Int =3D=3D0?w[0]:w[1];
}
|
|// Decompose complex as lvalues.
template<std::size_t _Int,typenameRealTp>
constexprRealTpconst&
get(const std::complex<RealTp>&z)
{
static_assert(_Int <2,"index is out of bounds");
autow =3Dreinterpret_cast<RealTpconst(&)[2]>(z);
return_Int =3D=3D0?w[0]:w[1];
}
|
Vicente

--=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/4259d7dc-f060-dc27-5004-37bf4726e456%40wanadoo.f=
r.

--------------405F0B4D6009C044D992406E
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 14/04/2017 =C3=A0 00:11,
      <a class=3D"moz-txt-link-abbreviated" href=3D"mailto:3dw4rd@verizon.n=
et">3dw4rd@verizon.net</a> a =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:74a45396-2e35-4231-86b9-4caceb531239@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">In many uses of std::complex<br>
        one wants to capture the real and imaginary parts in separate
        variables either to use them in subsequent calculations or to
        modify them individually.<br>
        There are many options:<br>
        <br>
        These options reflect an over-encapsulation of std::complex,
        which everyone agrees is a struct with two floating point
        numbers, real part and imaginary part, in that order.<br>
        Attempting to use a decomposition declaration for a complex
        number is an error because of the pretension (ostensibly for C
        compatibility) the complex numbers are opaque.<br>
      </div>
    </blockquote>
    Humm, it is not so opaque as you can get the representation as a
    c-array.<br>
    <br>
    This means that we should already be able to apply structured
    binding using the cast<br>
    <br>
    <code class=3D"prettyprint"><span style=3D"color: #000;"
        class=3D"styled-by-prettify">=C2=A0 =C2=A0 </span><span style=3D"co=
lor:
        #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color=
:
        #660;" class=3D"styled-by-prettify">&amp;</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify">p</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> q</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span></code>=
<code
      class=3D"prettyprint"><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
            style=3D"color: #000;" class=3D"styled-by-prettify"></span><spa=
n
            style=3D"color: #008;" class=3D"styled-by-prettify">reinterpret=
_cast</span><span
            style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span>=
<span
            style=3D"color: #606;" class=3D"styled-by-prettify">Tp</span><s=
pan
            style=3D"color: #660;" class=3D"styled-by-prettify">(&amp;)[</s=
pan><span
            style=3D"color: #066;" class=3D"styled-by-prettify">2</span><sp=
an
            style=3D"color: #660;" class=3D"styled-by-prettify">]&gt;(</spa=
n><span
            style=3D"color: #000;" class=3D"styled-by-prettify">z</span><sp=
an
            style=3D"color: #660;" class=3D"styled-by-prettify">)</span></c=
ode></span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
      </span></code><br>
    Nevertheles I agree with you that your proposal makes this cleaner
    and more explicit. Complex should be a ProductType.<br>
    <blockquote
      cite=3D"mid:74a45396-2e35-4231-86b9-4caceb531239@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr"><br>
        The rvalue and lvalue decomposition of std::complex can be
        accomplished with a simple pure-library extension:<br>
        Provide a tuple interface to std::complex.<br>
        <br>
        <div style=3D"background-color: rgb(250, 250, 250); border-color:
          rgb(187, 187, 187); border-style: solid; border-width: 1px;
          overflow-wrap: break-word;" class=3D"prettyprint"><code
            class=3D"prettyprint">
            <div class=3D"subprettyprint"><span style=3D"color: #000;"
                class=3D"styled-by-prettify">=C2=A0 </span><span style=3D"c=
olor:
                #800;" class=3D"styled-by-prettify">// Tuple interface to
                class template complex.</span><span style=3D"color: #000;"
                class=3D"styled-by-prettify"><br>
              </span><span style=3D"color: #800;"
                class=3D"styled-by-prettify">#define</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">
                __cxx_lib_tuple_complex </span><span style=3D"color:
                #066;" class=3D"styled-by-prettify">201705</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 </span><span style=3D"color: #800;"
                class=3D"styled-by-prettify">// Declare tuple_size.</span><=
span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">template</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #008;" class=3D"styled-by-prettify">typenam=
e</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">class</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">
                tuple_size</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">;</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 </span><span style=3D"color: #800;"
                class=3D"styled-by-prettify">// Partial specialization for
                std::complex.</span><span style=3D"color: #000;"
                class=3D"styled-by-prettify"><br>
                =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">template</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #008;" class=3D"styled-by-prettify">typenam=
e</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">struct</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">
                tuple_size</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">&lt;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">std</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">complex=
</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;&gt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">:</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #008;" class=3D"styled-by-prettify">public<=
/span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">
                integral_constant</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">&lt;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">std</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">size_t<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">2</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">};</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 </span><span style=3D"color: #800;"
                class=3D"styled-by-prettify">// Declare tuple_element.</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">template</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify">std</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">size_t
                _Int</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">,</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #008;" class=3D"styled-by-prettify">typenam=
e</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">class</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">
                tuple_element</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">;</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 </span><span style=3D"color: #800;"
                class=3D"styled-by-prettify">// Partial specialization for
                std::complex.</span><span style=3D"color: #000;"
                class=3D"styled-by-prettify"><br>
                =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">template</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify">std</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">size_t
                _Int</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">,</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #008;" class=3D"styled-by-prettify">typenam=
e</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">struct</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">
                tuple_element</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">&lt;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">_Int</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">complex=
</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;&gt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">{</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">static_assert</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">_Int </=
span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">2</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"index
                is out of bounds"</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">);</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">typedef</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> type</=
span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">};</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 </span><span style=3D"color: #800;"
                class=3D"styled-by-prettify">// Decompose complex as
                rvalues.</span><span style=3D"color: #000;"
                class=3D"styled-by-prettify"><br>
                =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">template</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify">std</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">size_t
                _Int</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">,</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #008;" class=3D"styled-by-prettify">typenam=
e</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">constexpr</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #008;" class=3D"styled-by-prettify">const</=
span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">get</span><span style=3D"color=
:
                #660;" class=3D"styled-by-prettify">(</span><span
                style=3D"color: #008;" class=3D"styled-by-prettify">const</=
span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">complex=
</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;&am=
p;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> z</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">)</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">{</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">static_assert</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">_Int </=
span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">2</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"index
                is out of bounds"</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">);</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">return</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> _Int <=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D<=
/span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">0</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">?</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> z</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">.</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">real</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">()</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">:</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> z</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">.</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">imag</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">();</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">}</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 </span><span style=3D"color: #800;"
                class=3D"styled-by-prettify">// Decompose complex as
                lvalues.</span><span style=3D"color: #000;"
                class=3D"styled-by-prettify"><br>
                =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">template</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify">std</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">size_t
                _Int</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">,</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #008;" class=3D"styled-by-prettify">typenam=
e</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">constexpr</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</=
span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">get</span><span style=3D"color=
:
                #660;" class=3D"styled-by-prettify">(</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">std</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">complex=
</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;&am=
p;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> z</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">)</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">{</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">static_assert</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">_Int </=
span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">2</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"index
                is out of bounds"</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">);</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">auto</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> w </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">=3D</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #008;" class=3D"styled-by-prettify">reinter=
pret_cast</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #606;" class=3D"styled-by-prettify">RealTp<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(&amp;)=
[</span><span
                style=3D"color: #066;" class=3D"styled-by-prettify">2</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">]&gt;(<=
/span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">z</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">return</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> _Int <=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D<=
/span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">0</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">?</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> w</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">[</span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">0</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">]</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">:</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> w</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">[</span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">1</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">];</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">}</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                <br>
              </span></div>
          </code></div>
        <br>
      </div>
    </blockquote>
    I believed that this reinterpret_cast was UB, but as you note below,
    it is defined by the standard.<br>
    <br>
    <blockquote
      cite=3D"mid:74a45396-2e35-4231-86b9-4caceb531239@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr"><br>
        Then we have the following behavior:<br>
        <br>
        <div style=3D"background-color: rgb(250, 250, 250); border-color:
          rgb(187, 187, 187); border-style: solid; border-width: 1px;
          overflow-wrap: break-word;" class=3D"prettyprint"><code
            class=3D"prettyprint">
            <div class=3D"subprettyprint"><span style=3D"color: #008;"
                class=3D"styled-by-prettify">template</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #008;" class=3D"styled-by-prettify">typenam=
e</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #606;" class=3D"styled-by-prettify">Tp</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">void</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 test_complex_decomp</span><span style=3D"color: #660=
;"
                class=3D"styled-by-prettify">()</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">{</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">complex</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #606;" class=3D"styled-by-prettify">Tp</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> z</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">1</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">2</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">auto</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">[</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">x</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> y</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">]</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">=3D</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> z</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">cout </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"z =3D =
"</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> z </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">'\n'</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">cout </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"z
                parts:"</span><span style=3D"color: #000;"
                class=3D"styled-by-prettify"> </span><span style=3D"color:
                #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">' '</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> x </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">' '</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> y </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">'\n'</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                <br>
              </span></div>
          </code></div>
      </div>
    </blockquote>
    <code>I'm not sure if you believe this implies a call to get to
      decomponse as rvalues, but it isn't.<br>
      It just copies the complex to a temporary, </code><code>and then
      calls get on this temporary.<br>
      <br>
    </code>
    <blockquote
      cite=3D"mid:74a45396-2e35-4231-86b9-4caceb531239@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">
        <div style=3D"background-color: rgb(250, 250, 250); border-color:
          rgb(187, 187, 187); border-style: solid; border-width: 1px;
          overflow-wrap: break-word;" class=3D"prettyprint"><code
            class=3D"prettyprint">
            <div class=3D"subprettyprint"><span style=3D"color: #000;"
                class=3D"styled-by-prettify">=C2=A0 =C2=A0 z</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">.</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">real</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">3</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 z</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">.</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">imag</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">4</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">cout </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"z =3D =
"</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> z </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">'\n'</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">cout </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"z
                parts:"</span><span style=3D"color: #000;"
                class=3D"styled-by-prettify"> </span><span style=3D"color:
                #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">' '</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> x </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">' '</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> y </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">'\n'</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">complex</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #606;" class=3D"styled-by-prettify">Tp</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> w</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">1</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">2</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">cout </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"w =3D =
"</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> w </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">'\n'</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">auto</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</=
span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">[</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">p</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> q</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">]</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">=3D</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> w</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                <br>
              </span></div>
          </code></div>
      </div>
    </blockquote>
    <code>I'm not sure if you believe this implies a call to get to
      decomponse as lvalues, but it isn't.<br>
    </code><code>It just takes store a reference to the complex in a
      temporary, and then calls get on this temporary reference.<br>
    </code>
    <blockquote
      cite=3D"mid:74a45396-2e35-4231-86b9-4caceb531239@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">
        <div style=3D"background-color: rgb(250, 250, 250); border-color:
          rgb(187, 187, 187); border-style: solid; border-width: 1px;
          overflow-wrap: break-word;" class=3D"prettyprint"><code
            class=3D"prettyprint">
            <div class=3D"subprettyprint"><span style=3D"color: #000;"
                class=3D"styled-by-prettify"></span></div>
          </code></div>
      </div>
    </blockquote>
    <br>
    <blockquote
      cite=3D"mid:74a45396-2e35-4231-86b9-4caceb531239@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">
        <div style=3D"background-color: rgb(250, 250, 250); border-color:
          rgb(187, 187, 187); border-style: solid; border-width: 1px;
          overflow-wrap: break-word;" class=3D"prettyprint"><code
            class=3D"prettyprint">
            <div class=3D"subprettyprint"><span style=3D"color: #000;"
                class=3D"styled-by-prettify">=C2=A0 =C2=A0 w</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">.</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">real</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">3</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 w</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">.</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">imag</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">4</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">cout </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"w =3D =
"</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> w </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">'\n'</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">cout </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"w
                parts:"</span><span style=3D"color: #000;"
                class=3D"styled-by-prettify"> </span><span style=3D"color:
                #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">' '</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> p </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">' '</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> q </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">'\n'</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 =C2=A0 p </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">=3D</span><span style=3D"color=
:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">-</span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">5</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 q </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">=3D</span><span style=3D"color=
:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">-</span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">6</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">cout </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"w =3D =
"</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> w </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">'\n'</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0 std</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">cout </span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"w
                parts:"</span><span style=3D"color: #000;"
                class=3D"styled-by-prettify"> </span><span style=3D"color:
                #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">' '</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> p </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">' '</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> q </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">'\n'</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">return</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">}</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                <br>
              </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">int</span><span style=3D"color=
:
                #000;" class=3D"styled-by-prettify"><br>
                main</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">()</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
              </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">{</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 test_complex_decomp</span><span style=3D"color: #080=
;"
                class=3D"styled-by-prettify">&lt;double&gt;</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">();</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">return</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #066;" class=3D"styled-by-prettify">0</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
              </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">}</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                <br>
              </span></div>
          </code></div>
        <br>
        <br>
        -------------------<br>
        z =3D (1,2)<br>
        z parts: 1 2<br>
        z =3D (3,4)<br>
        z parts: 1 2<br>
        w =3D (1,2)<br>
        w =3D (3,4)<br>
        w parts: 3 4<br>
        w =3D (-5,-6)<br>
        w parts: -5 -6<br>
        -------------------<br>
        <br>
        The static cast, ugly as it is, is required to be valid by
        conforming implementations of complex.<br>
      </div>
    </blockquote>
    Are you talking of the reinterpret_cast?<br>
    <blockquote
      cite=3D"mid:74a45396-2e35-4231-86b9-4caceb531239@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">29.5 Complex numbers [complex.numbers] p4,
        specifically 4.1-4.3.<br>
        This solution elegantly isolates user code from this wart.</div>
    </blockquote>
    I believe that you need const/non const lvalue/rvalue decomposition,
    but maybe I'm wrong.<br>
    <br>
    <code class=3D"prettyprint"><span style=3D"color: #000;"
        class=3D"styled-by-prettify">=C2=A0 </span><span style=3D"color: #0=
08;"
        class=3D"styled-by-prettify">template</span><span style=3D"color:
        #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color=
:
        #000;" class=3D"styled-by-prettify">std</span><span style=3D"color:
        #660;" class=3D"styled-by-prettify">::</span><span style=3D"color:
        #000;" class=3D"styled-by-prettify">size_t _Int</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #008;" class=3D"styled-by-prettify">typename</span>=
<span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #606;" class=3D"styled-by-prettify">RealTp</span><s=
pan
        style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><spa=
n
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">constexpr</span><span style=3D"color:
        #000;" class=3D"styled-by-prettify"> </span><span style=3D"color:
        #008;" class=3D"styled-by-prettify">const</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #606;" class=3D"styled-by-prettify">RealTp</span><s=
pan
        style=3D"color: #000;" class=3D"styled-by-prettify">&amp;&amp;<br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">get</span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">(const </span><span style=3D"color:
        #000;" class=3D"styled-by-prettify">std</span><span style=3D"color:
        #660;" class=3D"styled-by-prettify">::</span><span style=3D"color:
        #000;" class=3D"styled-by-prettify">complex</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n
        style=3D"color: #606;" class=3D"styled-by-prettify">RealTp</span><s=
pan
        style=3D"color: #660;" class=3D"styled-by-prettify">&gt;&amp;</span=
><span
        style=3D"color: #000;" class=3D"styled-by-prettify">&amp; z</span><=
span
        style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">static_assert</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify">_Int </span><sp=
an
        style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #080;" class=3D"styled-by-prettify">"index is out o=
f
        bounds"</span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">);</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">return</span><span style=3D"color:
        #000;" class=3D"styled-by-prettify"> _Int </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><s=
pan
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">?</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> z</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify">real</span><spa=
n
        style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> z</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify">imag</span><spa=
n
        style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">}</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><br>
        <br>
      </span></code><br>
    <code class=3D"prettyprint"><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
            style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0 </sp=
an><span
            style=3D"color: #008;" class=3D"styled-by-prettify">template</s=
pan><span
            style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span>=
<span
            style=3D"color: #000;" class=3D"styled-by-prettify">std</span><=
span
            style=3D"color: #660;" class=3D"styled-by-prettify">::</span><s=
pan
            style=3D"color: #000;" class=3D"styled-by-prettify">size_t _Int=
</span><span
            style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an
            style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an
            style=3D"color: #008;" class=3D"styled-by-prettify">typename</s=
pan><span
            style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an
            style=3D"color: #606;" class=3D"styled-by-prettify">RealTp</spa=
n><span
            style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span>=
<span
            style=3D"color: #000;" class=3D"styled-by-prettify"><br>
            =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
            class=3D"styled-by-prettify">constexpr</span><span
            style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an
            style=3D"color: #000;" class=3D"styled-by-prettify"></span><spa=
n
            style=3D"color: #606;" class=3D"styled-by-prettify">RealTp&amp;=
&amp;</span><span
            style=3D"color: #000;" class=3D"styled-by-prettify"><br>
            =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
            class=3D"styled-by-prettify">get</span><span style=3D"color:
            #660;" class=3D"styled-by-prettify">(</span><span
            style=3D"color: #000;" class=3D"styled-by-prettify">std</span><=
span
            style=3D"color: #660;" class=3D"styled-by-prettify">::</span><s=
pan
            style=3D"color: #000;" class=3D"styled-by-prettify">complex</sp=
an><span
            style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span>=
<span
            style=3D"color: #606;" class=3D"styled-by-prettify">RealTp</spa=
n><span
            style=3D"color: #660;" class=3D"styled-by-prettify">&gt;&amp;</=
span><span
            style=3D"color: #000;" class=3D"styled-by-prettify">&amp; z</sp=
an><span
            style=3D"color: #660;" class=3D"styled-by-prettify">)</span><sp=
an
            style=3D"color: #000;" class=3D"styled-by-prettify"><br>
            =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
            class=3D"styled-by-prettify">{</span><span style=3D"color:
            #000;" class=3D"styled-by-prettify"><br>
            =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
            class=3D"styled-by-prettify">static_assert</span><span
            style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an
            style=3D"color: #000;" class=3D"styled-by-prettify">_Int </span=
><span
            style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span>=
<span
            style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an
            style=3D"color: #066;" class=3D"styled-by-prettify">2</span><sp=
an
            style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an
            style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an
            style=3D"color: #080;" class=3D"styled-by-prettify">"index is
            out of bounds"</span><span style=3D"color: #660;"
            class=3D"styled-by-prettify">);</span><span style=3D"color:
            #000;" class=3D"styled-by-prettify"><br>
            =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
            class=3D"styled-by-prettify">return</span><span style=3D"color:
            #000;" class=3D"styled-by-prettify"> _Int </span><span
            style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</spa=
n><span
            style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an
            style=3D"color: #066;" class=3D"styled-by-prettify">0</span><sp=
an
            style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an
            style=3D"color: #660;" class=3D"styled-by-prettify">?</span><sp=
an
            style=3D"color: #000;" class=3D"styled-by-prettify"> z</span><s=
pan
            style=3D"color: #660;" class=3D"styled-by-prettify">.</span><sp=
an
            style=3D"color: #000;" class=3D"styled-by-prettify">real</span>=
<span
            style=3D"color: #660;" class=3D"styled-by-prettify">()</span><s=
pan
            style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an
            style=3D"color: #660;" class=3D"styled-by-prettify">:</span><sp=
an
            style=3D"color: #000;" class=3D"styled-by-prettify"> z</span><s=
pan
            style=3D"color: #660;" class=3D"styled-by-prettify">.</span><sp=
an
            style=3D"color: #000;" class=3D"styled-by-prettify">imag</span>=
<span
            style=3D"color: #660;" class=3D"styled-by-prettify">();</span><=
span
            style=3D"color: #000;" class=3D"styled-by-prettify"><br>
            =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
            class=3D"styled-by-prettify">}</span><span style=3D"color:
            #000;" class=3D"styled-by-prettify"><br>
          </span></code>=C2=A0 </span><span style=3D"color: #800;"
        class=3D"styled-by-prettify">// Decompose complex as lvalues.</span=
><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">template</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n
        style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify">size_t _Int</sp=
an><span
        style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #008;" class=3D"styled-by-prettify">typename</span>=
<span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #606;" class=3D"styled-by-prettify">RealTp</span><s=
pan
        style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><spa=
n
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">constexpr</span><span style=3D"color:
        #000;" class=3D"styled-by-prettify"> </span><span style=3D"color:
        #606;" class=3D"styled-by-prettify">RealTp</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><sp=
an
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">get</span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">(</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify">std</span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">::</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify">complex</span><span style=3D"color:
        #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color=
:
        #606;" class=3D"styled-by-prettify">RealTp</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">&gt;&amp;</span=
><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> z</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">static_assert</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify">_Int </span><sp=
an
        style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #080;" class=3D"styled-by-prettify">"index is out o=
f
        bounds"</span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">);</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;=
"
        class=3D"styled-by-prettify"> w </span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">reinterpret_cast</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n
        style=3D"color: #606;" class=3D"styled-by-prettify">RealTp</span><s=
pan
        style=3D"color: #660;" class=3D"styled-by-prettify">(&amp;)[</span>=
<span
        style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">]&gt;(</span><s=
pan
        style=3D"color: #000;" class=3D"styled-by-prettify">z</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">return</span><span style=3D"color:
        #000;" class=3D"styled-by-prettify"> _Int </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><s=
pan
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">?</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> w</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> w</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">1</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">];</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">}</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><br>
      </span></code><br>
    <code class=3D"prettyprint"><span style=3D"color: #000;"
        class=3D"styled-by-prettify">=C2=A0 </span><span style=3D"color: #8=
00;"
        class=3D"styled-by-prettify">// Decompose complex as lvalues.</span=
><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">template</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n
        style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify">size_t _Int</sp=
an><span
        style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #008;" class=3D"styled-by-prettify">typename</span>=
<span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #606;" class=3D"styled-by-prettify">RealTp</span><s=
pan
        style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><spa=
n
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">constexpr</span><span style=3D"color:
        #000;" class=3D"styled-by-prettify"> </span><span style=3D"color:
        #606;" class=3D"styled-by-prettify">RealTp</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify"> const&amp;</sp=
an><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">get</span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">(const </span><span style=3D"color:
        #000;" class=3D"styled-by-prettify">std</span><span style=3D"color:
        #660;" class=3D"styled-by-prettify">::</span><span style=3D"color:
        #000;" class=3D"styled-by-prettify">complex</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n
        style=3D"color: #606;" class=3D"styled-by-prettify">RealTp</span><s=
pan
        style=3D"color: #660;" class=3D"styled-by-prettify">&gt;&amp;</span=
><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> z</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">static_assert</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify">_Int </span><sp=
an
        style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #080;" class=3D"styled-by-prettify">"index is out o=
f
        bounds"</span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">);</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;=
"
        class=3D"styled-by-prettify"> w </span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">reinterpret_cast</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n
        style=3D"color: #606;" class=3D"styled-by-prettify">RealTp</span><s=
pan
        style=3D"color: #660;" class=3D"styled-by-prettify"> const(&amp;)[<=
/span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">]&gt;(</span><s=
pan
        style=3D"color: #000;" class=3D"styled-by-prettify">z</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"
        class=3D"styled-by-prettify">return</span><span style=3D"color:
        #000;" class=3D"styled-by-prettify"> _Int </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><s=
pan
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">?</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> w</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"> w</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span
        style=3D"color: #066;" class=3D"styled-by-prettify">1</span><span
        style=3D"color: #660;" class=3D"styled-by-prettify">];</span><span
        style=3D"color: #000;" class=3D"styled-by-prettify"><br>
        =C2=A0 =C2=A0 </span><span style=3D"color: #660;"
        class=3D"styled-by-prettify">}</span><span style=3D"color: #000;"
        class=3D"styled-by-prettify"><br>
      </span></code><br>
    Vicente<br>
  </body>
</html>

<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/4259d7dc-f060-dc27-5004-37bf4726e456%=
40wanadoo.fr?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4259d7dc-f060-dc27-5004-37bf4726e456=
%40wanadoo.fr</a>.<br />

--------------405F0B4D6009C044D992406E--

.
