Topic: Extending N4371 (incomplete type support for


Author: Zhihao Yuan <zy@miator.net>
Date: Thu, 19 Jul 2018 15:32:57 -0400
Raw View
This is a multi-part message in MIME format.

--b1_9b8831af320e4fa9d2ece6c53840aa6a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

That use case is not very strong, because extending
std::variant is easier.  I have my own implementation
variant which supports an =E2=80=9CIncompleteType[]=E2=80=9D syntax
to spell the recursive wrapper.  A recursive wrapper,
after all, has an identifiable type in the type list.  The
incomplete type support for containers are =E2=80=9Cdirect,=E2=80=9D
indistinguishable from the complete element types.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

From: itsjimporter@gmail.com <itsjimporter@gmail.com>
Sent: Thursday, July 19, 2018 2:08 PM

struct json : std::variant<
  double,
  std::string,
  std::vector<json>,
  std::map<std::string, json>// not allowed (yet)...
>{
   using std::variant</*...*/>::variant;
};

This would eliminate the need to use things like Boost's `make_recursive_va=
riant` for common cases like JSON (and similar) data types without requirin=
g full recursive-variant support in the standard. I'm happy to help push th=
is forward, but my understanding is that the main concern is what standard =
library implementers think of this.

--=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/Sh0hCBLOqEtt_F1HRdDKeP6J1DA6ISJo5ZetKyad8TgR5gGn=
b-XlvzsBo5x406dsYDhmDAeCXpl7FrHD8lbPRyLBPPRMW-KStyHf0Ayuk4M%3D%40miator.net=
..

--b1_9b8831af320e4fa9d2ece6c53840aa6a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"WordSection1"><p class=3D"MsoNormal"=
>That use case is not very strong, because extending<br/>std::variant is ea=
sier.=C2=A0 I have my own implementation<br/>variant which supports an =E2=
=80=9CIncompleteType[]=E2=80=9D syntax<br/>to spell the recursive wrapper.=
=C2=A0 A recursive wrapper,<br/>after all, has an identifiable type in the =
type list.=C2=A0 The<br/>incomplete type support for containers are =E2=80=
=9Cdirect,=E2=80=9D<br/>indistinguishable from the complete element types.<=
br/><br/><o:p></o:p></p><p class=3D"MsoNormal">--<br/>Zhihao Yuan, ID lichr=
ay<br/>The best way to predict the future is to invent it.<br/>____________=
___________________________________<o:p></o:p></p><p class=3D"MsoNormal"><o=
:p>=C2=A0</o:p></p><div style=3D"border:none;border-left:solid blue 1.5pt;p=
adding:0in 0in 0in 4.0pt"><div><div style=3D"border:none;border-top:solid #=
E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in"><p class=3D"MsoNormal"><b>From:</b>=
 itsjimporter@gmail.com &lt;itsjimporter@gmail.com&gt; <br/><b>Sent:</b> Th=
ursday, July 19, 2018 2:08 PM<o:p></o:p></p></div></div><div><div><p class=
=3D"MsoNormal"><o:p>=C2=A0</o:p></p></div><div style=3D"border:solid #BBBBB=
B 1.0pt;padding:0in 0in 0in 0in;overflow-wrap: break-word"><div><p class=3D=
"MsoNormal" style=3D"background:#FAFAFA"><span class=3D"styled-by-prettify"=
><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:#0=
00088">struct</span></span><span class=3D"styled-by-prettify"><span style=
=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:black"> json <=
/span></span><span class=3D"styled-by-prettify"><span style=3D"font-size:10=
..0pt;font-family:&#34;Courier New&#34;;color:#666600">:</span></span><span =
class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#=
34;Courier New&#34;;color:black"> std</span></span><span class=3D"styled-by=
-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34=
;;color:#666600">::</span></span><span class=3D"styled-by-prettify"><span s=
tyle=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:black">var=
iant</span></span><span class=3D"styled-by-prettify"><span style=3D"font-si=
ze:10.0pt;font-family:&#34;Courier New&#34;;color:#666600">&lt;</span></spa=
n><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:b=
lack"><br/><span class=3D"styled-by-prettify">=C2=A0 </span></span><span cl=
ass=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#34=
;Courier New&#34;;color:#000088">double</span></span><span class=3D"styled-=
by-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#=
34;;color:#666600">,</span></span><span style=3D"font-size:10.0pt;font-fami=
ly:&#34;Courier New&#34;;color:black"><br/><span class=3D"styled-by-prettif=
y">=C2=A0 std</span></span><span class=3D"styled-by-prettify"><span style=
=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:#666600">::</s=
pan></span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0=
pt;font-family:&#34;Courier New&#34;;color:#000088">string</span></span><sp=
an class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family=
:&#34;Courier New&#34;;color:#666600">,</span></span><span style=3D"font-si=
ze:10.0pt;font-family:&#34;Courier New&#34;;color:black"><br/><span class=
=3D"styled-by-prettify">=C2=A0 std</span></span><span class=3D"styled-by-pr=
ettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;c=
olor:#666600">::</span></span><span class=3D"styled-by-prettify"><span styl=
e=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:black">vector=
</span></span><span class=3D"styled-by-prettify"><span style=3D"font-size:1=
0.0pt;font-family:&#34;Courier New&#34;;color:#008800">&lt;json&gt;</span><=
/span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;fo=
nt-family:&#34;Courier New&#34;;color:#666600">,</span></span><span style=
=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:black"><br/><s=
pan class=3D"styled-by-prettify">=C2=A0 std</span></span><span class=3D"sty=
led-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier N=
ew&#34;;color:#666600">::</span></span><span class=3D"styled-by-prettify"><=
span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:blac=
k">map</span></span><span class=3D"styled-by-prettify"><span style=3D"font-=
size:10.0pt;font-family:&#34;Courier New&#34;;color:#666600">&lt;</span></s=
pan><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font=
-family:&#34;Courier New&#34;;color:black">std</span></span><span class=3D"=
styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courie=
r New&#34;;color:#666600">::</span></span><span class=3D"styled-by-prettify=
"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:#=
000088">string</span></span><span class=3D"styled-by-prettify"><span style=
=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:#666600">,</sp=
an></span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0p=
t;font-family:&#34;Courier New&#34;;color:black"> json</span></span><span c=
lass=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#3=
4;Courier New&#34;;color:#666600">&gt;</span></span><span class=3D"styled-b=
y-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#3=
4;;color:black"> </span></span><span class=3D"styled-by-prettify"><span sty=
le=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:#880000">// =
not allowed (yet)...</span></span><span style=3D"font-size:10.0pt;font-fami=
ly:&#34;Courier New&#34;;color:black"><br/></span><span class=3D"styled-by-=
prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;=
;color:#666600">&gt;</span></span><span class=3D"styled-by-prettify"><span =
style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:black"> <=
/span></span><span class=3D"styled-by-prettify"><span style=3D"font-size:10=
..0pt;font-family:&#34;Courier New&#34;;color:#666600">{</span></span><span =
style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:black"><b=
r/><span class=3D"styled-by-prettify">=C2=A0 =C2=A0</span></span><span clas=
s=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;C=
ourier New&#34;;color:#000088">using</span></span><span class=3D"styled-by-=
prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;=
;color:black"> std</span></span><span class=3D"styled-by-prettify"><span st=
yle=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:#666600">::=
</span></span><span class=3D"styled-by-prettify"><span style=3D"font-size:1=
0.0pt;font-family:&#34;Courier New&#34;;color:black">variant</span></span><=
span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-fami=
ly:&#34;Courier New&#34;;color:#666600">&lt;</span></span><span class=3D"st=
yled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier =
New&#34;;color:#880000">/*...*/</span></span><span class=3D"styled-by-prett=
ify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;colo=
r:#666600">&gt;::</span></span><span class=3D"styled-by-prettify"><span sty=
le=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:black">varia=
nt</span></span><span class=3D"styled-by-prettify"><span style=3D"font-size=
:10.0pt;font-family:&#34;Courier New&#34;;color:#666600">;</span></span><sp=
an style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:black"=
><br/></span><span class=3D"styled-by-prettify"><span style=3D"font-size:10=
..0pt;font-family:&#34;Courier New&#34;;color:#666600">};</span></span><span=
 style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;"><o:p></o:p></=
span></p></div></div><div><p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p></div=
><div><p class=3D"MsoNormal">This would eliminate the need to use things li=
ke Boost&#39;s `make_recursive_variant` for common cases like JSON (and sim=
ilar) data types without requiring full recursive-variant support in the st=
andard. I&#39;m happy to help push this forward, but my understanding is th=
at the main concern is what standard library implementers think of this.<o:=
p></o:p></p></div></div><p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p></div><=
/div></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/Sh0hCBLOqEtt_F1HRdDKeP6J1DA6ISJo5ZetK=
yad8TgR5gGnb-XlvzsBo5x406dsYDhmDAeCXpl7FrHD8lbPRyLBPPRMW-KStyHf0Ayuk4M%3D%4=
0miator.net?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/Sh0hCBLOqEtt_F1HRdDKeP6J1DA6ISJo5ZetK=
yad8TgR5gGnb-XlvzsBo5x406dsYDhmDAeCXpl7FrHD8lbPRyLBPPRMW-KStyHf0Ayuk4M%3D%4=
0miator.net</a>.<br />

--b1_9b8831af320e4fa9d2ece6c53840aa6a--


.