Topic: const public:" and "const private:" to avoid
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 20 Nov 2014 15:51:23 -0800
Raw View
--bcaec51b984f780df4050853019e
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thu, Nov 20, 2014 at 3:17 PM, <corentin.schreiber@cea.fr> wrote:
> Le vendredi 21 novembre 2014 00:15:54 UTC+1, corentin....@cea.fr a =C3=A9=
crit :
>>
>> Le jeudi 20 novembre 2014 23:56:12 UTC+1, Matthew Woehlke a =C3=A9crit :
>>>
>>> On 2014-11-20 17:36, Richard Smith wrote:
>>> > A variant of the 'inline variables and encapsulated expressions'
>>> proposal
>>> > would allow this:
>>> >
>>> > class X {
>>> > int private_x;
>>> > public:
>>> > using public_x =3D +private_x;
>>> > };
>>> > X x;
>>> > int a =3D x.public_x; // ok, means the same thing as 'int a =3D
>>> +x.private_x;'
>>> > but access check is done inside X.
>>>
>>> How would you achieve this for a member of, say, a container type? (In
>>> my specific case, I have something like std::vector<Bar>...)
>>>
>>> --
>>> Matthew
>>>
>>>
>> using public_x =3D static_cast<const decltype(x)&>(private_x); ?
>>
>
> Sorry, typing too fast:
> using public_x =3D const_cast<const decltype(private_x)&>(private_x); ?
>
Yeah, kinda ugly. How about:
template<typename T> const T &add_const(T &t) { return t; }
using public_x =3D add_const(private_x);
That doesn't seem so bad.
--=20
---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--bcaec51b984f780df4050853019e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Nov 20, 2014 at 3:17 PM, <span dir=3D"ltr"><<a href=3D"mailto:coren=
tin.schreiber@cea.fr" target=3D"_blank">corentin.schreiber@cea.fr</a>></=
span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Le vendredi=
21 novembre 2014 00:15:54 UTC+1, <a href=3D"mailto:corentin....@cea.fr" ta=
rget=3D"_blank">corentin....@cea.fr</a> a =C3=A9crit=C2=A0:<span class=3D""=
><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bord=
er-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Le jeudi 20 novem=
bre 2014 23:56:12 UTC+1, Matthew Woehlke a =C3=A9crit=C2=A0:<blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc=
solid;padding-left:1ex">On 2014-11-20 17:36, Richard Smith wrote:
<br>> A variant of the 'inline variables and encapsulated expression=
s' proposal
<br>> would allow this:
<br>>=20
<br>> class X {
<br>> =C2=A0 int private_x;
<br>> public:
<br>> =C2=A0 using public_x =3D +private_x;
<br>> };
<br>> X x;
<br>> int a =3D x.public_x; // ok, means the same thing as 'int a =
=3D +x.private_x;'
<br>> but access check is done inside X.
<br>
<br>How would you achieve this for a member of, say, a container type? (In
<br>my specific case, I have something like std::vector<Bar>...)
<br>
<br>--=20
<br>Matthew
<br>
<br></blockquote><div><br>using public_x =3D static_cast<const decltype(=
x)&>(private_x); ? <br></div></div></blockquote></span><div><br>Sorr=
y, typing too fast:<br>using public_x =3D const_cast<const decltype(priv=
ate_x)&>(private_x); ?</div></div></blockquote><div><br></div><div>Y=
eah, kinda ugly. How about:</div><div><br></div><div>template<typename T=
> const T &add_const(T &t) { return t; }=C2=A0</div><div><br></d=
iv><div>=C2=A0 using public_x =3D add_const(private_x);</div><div><br></div=
><div>That doesn't seem so bad.</div></div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--bcaec51b984f780df4050853019e--
.
Author: corentin.schreiber@cea.fr
Date: Sat, 22 Nov 2014 09:20:30 -0800 (PST)
Raw View
------=_Part_1346_208964756.1416676830249
Content-Type: multipart/alternative;
boundary="----=_Part_1347_934891247.1416676830249"
------=_Part_1347_934891247.1416676830249
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Le vendredi 21 novembre 2014 00:51:25 UTC+1, Richard Smith a =C3=A9crit :
>
> On Thu, Nov 20, 2014 at 3:17 PM, <corentin....@cea.fr <javascript:>>=20
> wrote:
>
>> Le vendredi 21 novembre 2014 00:15:54 UTC+1, corentin....@cea.fr a=20
>> =C3=A9crit :
>>>
>>> Le jeudi 20 novembre 2014 23:56:12 UTC+1, Matthew Woehlke a =C3=A9crit =
:
>>>>
>>>> On 2014-11-20 17:36, Richard Smith wrote:=20
>>>> > A variant of the 'inline variables and encapsulated expressions'=20
>>>> proposal=20
>>>> > would allow this:=20
>>>> >=20
>>>> > class X {=20
>>>> > int private_x;=20
>>>> > public:=20
>>>> > using public_x =3D +private_x;=20
>>>> > };=20
>>>> > X x;=20
>>>> > int a =3D x.public_x; // ok, means the same thing as 'int a =3D=20
>>>> +x.private_x;'=20
>>>> > but access check is done inside X.=20
>>>>
>>>> How would you achieve this for a member of, say, a container type? (In=
=20
>>>> my specific case, I have something like std::vector<Bar>...)=20
>>>>
>>>> --=20
>>>> Matthew=20
>>>>
>>>>
>>> using public_x =3D static_cast<const decltype(x)&>(private_x); ?=20
>>>
>>
>> Sorry, typing too fast:
>> using public_x =3D const_cast<const decltype(private_x)&>(private_x); ?
>>
>
> Yeah, kinda ugly. How about:
>
> template<typename T> const T &add_const(T &t) { return t; }=20
>
> using public_x =3D add_const(private_x);
>
> That doesn't seem so bad.
>
No indeed, that's quite nice!
--=20
---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_1347_934891247.1416676830249
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Le vendredi 21 novembre 2014 00:51:25 UTC+1, Richard Smith=
a =C3=A9crit :<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><div><div class=3D"gmail_quote">On Thu, Nov 20, 2014 at 3:17 PM, =
<span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfusca=
ted-mailto=3D"vixT1hZI1e0J" onmousedown=3D"this.href=3D'javascript:';return=
true;" onclick=3D"this.href=3D'javascript:';return true;">corentin....@cea=
..fr</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr=
">Le vendredi 21 novembre 2014 00:15:54 UTC+1, <a>corentin....@cea.fr</a> a=
=C3=A9crit :<span><blockquote class=3D"gmail_quote" style=3D"margin:0=
;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D=
"ltr">Le jeudi 20 novembre 2014 23:56:12 UTC+1, Matthew Woehlke a =C3=A9cri=
t :<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex">On 2014-11-20 17:36, Richar=
d Smith wrote:
<br>> A variant of the 'inline variables and encapsulated expressions' p=
roposal
<br>> would allow this:
<br>>=20
<br>> class X {
<br>> int private_x;
<br>> public:
<br>> using public_x =3D +private_x;
<br>> };
<br>> X x;
<br>> int a =3D x.public_x; // ok, means the same thing as 'int a =3D +x=
..private_x;'
<br>> but access check is done inside X.
<br>
<br>How would you achieve this for a member of, say, a container type? (In
<br>my specific case, I have something like std::vector<Bar>...)
<br>
<br>--=20
<br>Matthew
<br>
<br></blockquote><div><br>using public_x =3D static_cast<const decltype(=
x)&>(private_x); ? <br></div></div></blockquote></span><div><br>Sorr=
y, typing too fast:<br>using public_x =3D const_cast<const decltype(priv=
ate_x)&>(private_<wbr>x); ?</div></div></blockquote><div><br></div><=
div>Yeah, kinda ugly. How about:</div><div><br></div><div>template<typen=
ame T> const T &add_const(T &t) { return t; } </div><div><b=
r></div><div> using public_x =3D add_const(private_x);</div><div><br>=
</div><div>That doesn't seem so bad.</div></div></div></div></blockquote><d=
iv><br>No indeed, that's quite nice!<br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1347_934891247.1416676830249--
------=_Part_1346_208964756.1416676830249--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Sat, 22 Nov 2014 19:51:53 +0200
Raw View
On 22 November 2014 at 19:20, <corentin.schreiber@cea.fr> wrote:
>> Yeah, kinda ugly. How about:
>>
>> template<typename T> const T &add_const(T &t) { return t; }
>>
>> using public_x = add_const(private_x);
>>
>> That doesn't seem so bad.
> No indeed, that's quite nice!
That certainly looks interesting. As far as I understood it, David
Krauss's inline-variable
proposal met feedback according to which the inline-variable part was
desirable, the
expression-alias-like part less so.
Now, I must admit I don't give a rat's ass about inline variables as
such. To me, the
requirement of explicitly stating where the storage, if any, of a
static/global variable
(even if constexpr) lands is reasonable and teachable. Being able to
write expression
aliases seems like a facility via which I can express abstractions I
can't express today, without
incurring overhead. So, Richard, are there any plans to proceed with such ideas?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Sat, 22 Nov 2014 12:03:23 -0800
Raw View
--047d7b33db6ac575220508780dc0
Content-Type: text/plain; charset=UTF-8
On 22 Nov 2014 09:58, "Ville Voutilainen" <ville.voutilainen@gmail.com>
wrote:
>
> On 22 November 2014 at 19:20, <corentin.schreiber@cea.fr> wrote:
> >> Yeah, kinda ugly. How about:
> >>
> >> template<typename T> const T &add_const(T &t) { return t; }
> >>
> >> using public_x = add_const(private_x);
> >>
> >> That doesn't seem so bad.
> > No indeed, that's quite nice!
>
>
> That certainly looks interesting. As far as I understood it, David
> Krauss's inline-variable
> proposal met feedback according to which the inline-variable part was
> desirable, the
> expression-alias-like part less so.
>
> Now, I must admit I don't give a rat's ass about inline variables as
> such. To me, the
> requirement of explicitly stating where the storage, if any, of a
> static/global variable
> (even if constexpr) lands is reasonable and teachable.
I agree in principle, but the requirement to define a static data member of
a class outside the class is a constant, albeit mild, source of pain to the
developers I work with.
> Being able to
> write expression
> aliases seems like a facility via which I can express abstractions I
> can't express today, without
> incurring overhead. So, Richard, are there any plans to proceed with such
ideas?
I think both features are valuable, and I'd be happy to write proposals for
both of them, if David isn't interested in doing so.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--047d7b33db6ac575220508780dc0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<p dir=3D"ltr">On 22 Nov 2014 09:58, "Ville Voutilainen" <<a h=
ref=3D"mailto:ville.voutilainen@gmail.com">ville.voutilainen@gmail.com</a>&=
gt; wrote:<br>
><br>
> On 22 November 2014 at 19:20,=C2=A0 <<a href=3D"mailto:corentin.sch=
reiber@cea.fr">corentin.schreiber@cea.fr</a>> wrote:<br>
> >> Yeah, kinda ugly. How about:<br>
> >><br>
> >> template<typename T> const T &add_const(T &t) {=
return t; }<br>
> >><br>
> >>=C2=A0 =C2=A0using public_x =3D add_const(private_x);<br>
> >><br>
> >> That doesn't seem so bad.<br>
> > No indeed, that's quite nice!<br>
><br>
><br>
> That certainly looks interesting. As far as I understood it, David<br>
> Krauss's inline-variable<br>
> proposal met feedback according to which the inline-variable part was<=
br>
> desirable, the<br>
> expression-alias-like part less so.<br>
><br>
> Now, I must admit I don't give a rat's ass about inline variab=
les as<br>
> such. To me, the<br>
> requirement of explicitly stating where the storage, if any, of a<br>
> static/global variable<br>
> (even if constexpr) lands is reasonable and teachable.</p>
<p dir=3D"ltr">I agree in principle, but the requirement to define a static=
data member of a class outside the class is a constant, albeit mild, sourc=
e of pain to the developers I work with.</p>
<p dir=3D"ltr">> Being able to<br>
> write expression<br>
> aliases seems like a facility via which I can express abstractions I<b=
r>
> can't express today, without<br>
> incurring overhead. So, Richard, are there any plans to proceed with s=
uch ideas?</p>
<p dir=3D"ltr">I think both features are valuable, and I'd be happy to =
write proposals for both of them, if David isn't interested in doing so=
..</p>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7b33db6ac575220508780dc0--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Sat, 22 Nov 2014 22:13:25 +0200
Raw View
On 22 November 2014 at 22:03, Richard Smith <richard@metafoo.co.uk> wrote:
>> Now, I must admit I don't give a rat's ass about inline variables as
>> such. To me, the
>> requirement of explicitly stating where the storage, if any, of a
>> static/global variable
>> (even if constexpr) lands is reasonable and teachable.
>
> I agree in principle, but the requirement to define a static data member of
> a class outside the class is a constant, albeit mild, source of pain to the
> developers I work with.
I understand those concerns. What I would like to see is a description
of a mechanism that works always properly in the presence of multiple
translation units. And, while we don't deal with it in the realm of
the standard,
there are practical concerns with dynamically loaded libraries. I would
be plenty happy with semantics that say "sure, almost-define it once,
the implementation will take care of it". I may not understand whether
there are true differences between functions and objects in this area.
>> Being able to
>> write expression
>> aliases seems like a facility via which I can express abstractions I
>> can't express today, without
>> incurring overhead. So, Richard, are there any plans to proceed with such
>> ideas?
>
> I think both features are valuable, and I'd be happy to write proposals for
> both of them, if David isn't interested in doing so.
That would surely be appreciated; I do think both features are worth
exploring, and it would be beneficial to advance them.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: =?UTF-8?B?0KHQtdGA0LPQtdC5INCa0YDQuNCy0L7QvdC+0YE=?= <sergeikrivonos@gmail.com>
Date: Tue, 26 Dec 2017 23:36:24 +0200
Raw View
--001a114fd0181c4f3805614513f5
Content-Type: text/plain; charset="UTF-8"
also wide const usage is why we also need to add default copy constructors
for classes with const fields
2017-12-25 9:23 GMT+02:00 <sergeikrivonos@gmail.com>:
> I am very agree with const modifiers for visibility and inheritance
> specifiers.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit https://groups.google.com/a/
> isocpp.org/d/topic/std-proposals/ngRKWPbEXqU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/a2005e3e-4e99-4fba-
> abfc-55401f7784ff%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a2005e3e-4e99-4fba-abfc-55401f7784ff%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
--
Sergei Krivonos
skype: sergio_krivonos
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGz9X0c%3DZQOeGGTA88ryR1dghTkuE6OXVZ67BzZrx-AQs9xv-Q%40mail.gmail.com.
--001a114fd0181c4f3805614513f5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">also wide const usage is why we also need to add default c=
opy constructors for classes with const fields</div><div class=3D"gmail_ext=
ra"><br><div class=3D"gmail_quote">2017-12-25 9:23 GMT+02:00 <span dir=3D"=
ltr"><<a href=3D"mailto:sergeikrivonos@gmail.com" target=3D"_blank">serg=
eikrivonos@gmail.com</a>></span>:<br><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div=
dir=3D"ltr">I am very agree with const modifiers for visibility and inheri=
tance specifiers.</div><span class=3D"HOEnZb"><font color=3D"#888888">
<p></p>
-- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/ngRKWPbEXqU/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/<wbr>isocpp.org/d/topic/std-<wbr>proposals/n=
gRKWPbEXqU/<wbr>unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_blank">std-prop=
osals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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/a2005e3e-4e99-4fba-abfc-55401f7784ff%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/a200=
5e3e-4e99-4fba-<wbr>abfc-55401f7784ff%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br><br clear=3D"all"><div><br></div>-- <b=
r><div class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><br>Ser=
gei Krivonos<br>skype: sergio_krivonos</div>
</div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/CAGz9X0c%3DZQOeGGTA88ryR1dghTkuE6OXVZ=
67BzZrx-AQs9xv-Q%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGz9X0c%3DZQOe=
GGTA88ryR1dghTkuE6OXVZ67BzZrx-AQs9xv-Q%40mail.gmail.com</a>.<br />
--001a114fd0181c4f3805614513f5--
.
Author: bastienpenava@gmail.com
Date: Tue, 26 Dec 2017 23:18:06 -0800 (PST)
Raw View
------=_Part_20686_1786363335.1514359086708
Content-Type: multipart/alternative;
boundary="----=_Part_20687_1083674960.1514359086709"
------=_Part_20687_1083674960.1514359086709
Content-Type: text/plain; charset="UTF-8"
On Saturday, November 22, 2014 at 9:03:26 PM UTC+1, Richard Smith wrote:
>
> On 22 Nov 2014 09:58, "Ville Voutilainen" <ville.vo...@gmail.com
> <javascript:>> wrote:
> >
> > On 22 November 2014 at 19:20, <corentin....@cea.fr <javascript:>>
> wrote:
> > >> Yeah, kinda ugly. How about:
> > >>
> > >> template<typename T> const T &add_const(T &t) { return t; }
> > >>
> > >> using public_x = add_const(private_x);
> > >>
> > >> That doesn't seem so bad.
> > > No indeed, that's quite nice!
> >
> >
> > That certainly looks interesting. As far as I understood it, David
> > Krauss's inline-variable
> > proposal met feedback according to which the inline-variable part was
> > desirable, the
> > expression-alias-like part less so.
> >
> > Now, I must admit I don't give a rat's ass about inline variables as
> > such. To me, the
> > requirement of explicitly stating where the storage, if any, of a
> > static/global variable
> > (even if constexpr) lands is reasonable and teachable.
>
> I agree in principle, but the requirement to define a static data member
> of a class outside the class is a constant, albeit mild, source of pain to
> the developers I work with.
>
> > Being able to
> > write expression
> > aliases seems like a facility via which I can express abstractions I
> > can't express today, without
> > incurring overhead. So, Richard, are there any plans to proceed with
> such ideas?
>
> I think both features are valuable, and I'd be happy to write proposals
> for both of them, if David isn't interested in doing so.
>
I really like the idea of aliased/inlined expression.
I know this is a bit off-topic but I was wondering if you considered
allowing them to be parameterized ?
something like this:
template<class... Args>
using print_cout(Args&&... x) = printer(std::cout, x...);
//print_count is not a function.
//there must be no difference between writing the actual expression
manually and the alias' result.
//No impact on constexpr-ness, no argument decay, arguments can be used as
constexpr value if the are without a need to add the constexpr qualifier,
//the return must be of the exact type (reference if reference value if
value), etc...
//Because of that std::forward shouldn't be used in this example as it
wouldn't forward print_count's arguments but the argument given to
print_count.
//Because of all of that no other definition/declaration other than an
other aliased expression can have the same name as it would most likely
break ODR.
The reason why I bring this up is because we recently had a thread about
how some would like to simplify std::forward by allowing the the template
parameter to be implicitly deduced through implementation defined hacks.
The same result could be achieve with this without having to resort to
hacks.
namespace std {
template<class T>
using forward(T&& expr) = static_cast<std::remove_reference_t<T>&&>(expr
);
}
I believe that this reduce the need/push for new keywords and would be a
better solution than macros as c++ aware and would be compatible with
modules.
For instance, during the last meeting after rejecting "forward without
forward" 's unary << operator, the committee tried to look for a keyword
to give an alternative to std::forward but no consensus was made.
I believe that the above is much cleaner to both using macros and adding a
new keyword would need to have different name from forward and forward
would anyway remain.
But it's not the only use-case.
It also would allow to define function aliases & push-through functions
easily :
template<class... Args>
using new_name(Args&&... x) = old_name(x...);
template<class... Args>
std::ostream &stream_fprintf(std::ostream&, std::string_view&&, Args&&...);
template<class... Args>
using stream_printf(std::string_view&& view, Args&&... args) =
stream_fprintf(std::cout, view, args...); //easy to write front default
argument
Also operator[] for std::tuple-like types:
template<class...>
struct tuple
{
using operator[](size_t index) = std::get<index>(*this);
};
tuple x = {...};
int i = 0;
x[i];//error: i not a valid template non-type parameter...
x[0];//ok. produce std::get<0>(x) expression
getter/setter for trivial types:
struct trivial
{
private:
int i;
public:
using get_i = +i;
using set_i_ignore(int new_i) = (new_i < 0 ? i : (i = new_i)); //the
ternary could be replaced with a contract once/if they're accepted.
using set_i_throw(int new_i) = (new_i < 0 ? (throw std::invalid_argument(
"..."), i) : (i = new_i)); //a throwing alternative.
};
trivial x = {42};
x.set_i_ignore(5); //ok
x.set_i_throw(-5); //throws
Generally speaking it could be a c++-aware alternative to macros in many
places without text replacement and lazy evaluation.
I believe it could be quite useful and clean a bunch of verbose and
repetitive code.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2c8d8548-edaf-4312-a3cf-e232256a111a%40isocpp.org.
------=_Part_20687_1083674960.1514359086709
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Saturday, November 22, 2014 at 9:03:26 PM UTC+1=
, Richard Smith wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p dir=
=3D"ltr">On 22 Nov 2014 09:58, "Ville Voutilainen" <<a href=3D=
"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"oi7y92h0KQIJ" rel=
=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';return true;=
" onclick=3D"this.href=3D'javascript:';return true;">ville.vo...@gm=
ail.com</a>> wrote:<br>
><br>
> On 22 November 2014 at 19:20,=C2=A0 <<a href=3D"javascript:" target=
=3D"_blank" gdf-obfuscated-mailto=3D"oi7y92h0KQIJ" rel=3D"nofollow" onmouse=
down=3D"this.href=3D'javascript:';return true;" onclick=3D"this.hre=
f=3D'javascript:';return true;">corentin....@cea.fr</a>> wrote:<=
br>
> >> Yeah, kinda ugly. How about:<br>
> >><br>
> >> template<typename T> const T &add_const(T &t) {=
return t; }<br>
> >><br>
> >>=C2=A0 =C2=A0using public_x =3D add_const(private_x);<br>
> >><br>
> >> That doesn't seem so bad.<br>
> > No indeed, that's quite nice!<br>
><br>
><br>
> That certainly looks interesting. As far as I understood it, David<br>
> Krauss's inline-variable<br>
> proposal met feedback according to which the inline-variable part was<=
br>
> desirable, the<br>
> expression-alias-like part less so.<br>
><br>
> Now, I must admit I don't give a rat's ass about inline variab=
les as<br>
> such. To me, the<br>
> requirement of explicitly stating where the storage, if any, of a<br>
> static/global variable<br>
> (even if constexpr) lands is reasonable and teachable.</p>
<p dir=3D"ltr">I agree in principle, but the requirement to define a static=
data member of a class outside the class is a constant, albeit mild, sourc=
e of pain to the developers I work with.</p>
<p dir=3D"ltr">> Being able to<br>
> write expression<br>
> aliases seems like a facility via which I can express abstractions I<b=
r>
> can't express today, without<br>
> incurring overhead. So, Richard, are there any plans to proceed with s=
uch ideas?</p>
<p dir=3D"ltr">I think both features are valuable, and I'd be happy to =
write proposals for both of them, if David isn't interested in doing so=
..</p></blockquote><div><br></div><div>I really like the idea of aliased/inl=
ined expression.</div><div>I know this is a bit off-topic but I was wonderi=
ng if you considered allowing them to be parameterized ?</div><div>somethin=
g like this:<br></div><div><div class=3D"prettyprint" style=3D"background-c=
olor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: s=
olid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint=
"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"style=
d-by-prettify">template</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">class</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">Args</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">></span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">using</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> print_cout</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #606;"=
class=3D"styled-by-prettify">Args</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&&</span><font color=3D"#666600"><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span></font><span style=3D"colo=
r: #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"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> printer</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><fon=
t color=3D"#000000"><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">cout</span></font><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">...);</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">//print_count is not a f=
unction.</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #800;" class=3D"styled-by-prettify">//there =
must be no difference between writing the actual expression manually and th=
e alias' result.</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">//No impact on constexpr-ness, no argument decay, arguments can be used=
as constexpr value if the are without a need to add the constexpr qualifie=
r,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">//the return m=
ust be of the exact type (reference if reference value if value), etc...</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">//Because of that s=
td::forward shouldn't be used in this example as it wouldn't forwar=
d print_count's arguments but the argument given to print_count.</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">//Because of all of tha=
t no other definition/declaration other than an other aliased expression ca=
n have the same name as it would most likely break ODR.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></di=
v></div><div><br></div><div>The reason why I bring this up is because we re=
cently had a thread about how some would like to simplify std::forward by a=
llowing the the template parameter to be implicitly deduced through impleme=
ntation defined hacks.</div><div>The same result could be achieve with this=
without having to resort to hacks.</div><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
border-style: solid; border-width: 1px; word-wrap: break-word;"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">namespace</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> std </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>=C2=A0 =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"><</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><font color=3D"#000000"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">=C2=A0 =C2=A0</span></font><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> forward</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&&</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> expr</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 s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">static_cast</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">remove_reference_t</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">>&&>(</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">expr</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span></div></code></div><div><br></div><div>I believe that this reduce t=
he need/push for new keywords and would be a better solution than macros as=
c++ aware and would be compatible with modules.</div><div>For instance, du=
ring the last meeting after rejecting "forward without forward" &=
#39;s=C2=A0 unary << operator, the committee tried to look for a keyw=
ord to give an alternative to std::forward but no consensus was made.</div>=
<div>I believe that the above is much cleaner to both using macros and addi=
ng a new keyword would need to have different name from forward and forward=
would anyway remain.</div><div><br></div><div>But it's not the only us=
e-case.=C2=A0</div><div>It also would allow to define function aliases &=
; push-through functions easily :<div class=3D"prettyprint" style=3D"border=
-width: 1px; border-style: solid; border-color: rgb(187, 187, 187); backgro=
und-color: rgb(250, 250, 250); word-wrap: break-word;"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D=
"styled-by-prettify">template</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">class</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Args</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></span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> new_name</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #6=
06;" class=3D"styled-by-prettify">Args</span><span style=3D"color: #660;" c=
lass=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"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
old_name</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">x</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">...);</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">class</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: #606;" class=3D"=
styled-by-prettify">Args</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>std</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ost=
ream </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">stream_fpr=
intf</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><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">ostream</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">string_view</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">&&,</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"s=
tyled-by-prettify">Args</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&&...);</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">template</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">class</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">Args</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">></span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> stream_printf</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">string_view</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&&</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> view</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Arg=
s</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&&=
;...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> args<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><font color=3D"#00=
0000"><span style=3D"color: #000;" class=3D"styled-by-prettify"> stream_fpr=
intf</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><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">cout</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> view</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> args</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">...);</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/easy to write front default argument</span></font></div></code></div></div=
><div><br></div><div>Also operator[] for std::tuple-like types:</div><div><=
br></div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250=
, 250); border-color: rgb(187, 187, 187); border-style: solid; border-width=
: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"su=
bprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">tem=
plate</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">...></span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> tuple<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 =C2=A0</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">[](</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">size_t index</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">get</span><sp=
an style=3D"color: #080;" class=3D"styled-by-prettify"><index></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(*</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">this</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>tuple x </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"style=
d-by-prettify">{...};</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i=
</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 st=
yle=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>x</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">[</span><font color=3D"#006666"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">i</span></font><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">];</span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">//error: i not a valid template non-type pa=
rameter...</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</sp=
an><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: #800;" class=3D"styled-by-prettify">//ok. produce std::get<0>=
(x) expression</span></div></code></div><div><br></div><div>getter/setter f=
or trivial types:</div><div><br></div><div class=3D"prettyprint" style=3D"b=
ackground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bord=
er-style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"=
prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> trivial<br></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">private</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">:</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-pret=
tify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
i</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 s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">public</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: #008;" class=3D"styled-by-prettify">using</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> get_i </span><span style=3D"colo=
r: #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: #000;" class=3D"style=
d-by-prettify">i</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</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-pretti=
fy">using</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
set_i_ignore</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> new_i</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #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: #000;" class=3D"style=
d-by-prettify">new_i </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</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"> i </span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">i </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> new_=
i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">));</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">//the ternary could be re=
placed with a contract once/if they're accepted.</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> set_i_throw</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> new_i</span><font color=3D"#666600"><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">new_i </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><sp=
an 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">(</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">throw</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>invalid_argument</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&q=
uot;..."</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i</s=
pan><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"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">i </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> new_i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">))=
;</span></font><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">//a throwin=
g alternative.</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><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>tr=
ivial x </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 st=
yle=3D"color: #066;" class=3D"styled-by-prettify">42</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>x</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">set_i_ignore</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">//ok</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>x</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">set_i_throw</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(-</span><span style=3D"colo=
r: #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"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//throws</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span></div></code></div><div><br></div><div>Generally sp=
eaking it could be a c++-aware alternative to macros in many places without=
text replacement and lazy evaluation.</div><div>I believe it could be quit=
e useful and clean a bunch of verbose and repetitive code.</div><div><br></=
div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/2c8d8548-edaf-4312-a3cf-e232256a111a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2c8d8548-edaf-4312-a3cf-e232256a111a=
%40isocpp.org</a>.<br />
------=_Part_20687_1083674960.1514359086709--
------=_Part_20686_1786363335.1514359086708--
.