Topic: Bikeshedding a name for a new is_constructible trait


Author: eric@efcs.ca
Date: Mon, 23 Jan 2017 19:33:53 -0800 (PST)
Raw View
------=_Part_974_342523014.1485228833178
Content-Type: multipart/alternative;
 boundary="----=_Part_975_1750053323.1485228833178"

------=_Part_975_1750053323.1485228833178
Content-Type: text/plain; charset=UTF-8

Hi,

The is_constructible trait has problems when used on references. It will
correctly check if the construction is well formed, but that well-formed
reference construction may bind to a materialized temporary. When
is_constructible is being used to constrain "constructors" for containers
which store  references it gets the answer effectively wrong (e.g. pair,
tuple, variant?)

So I'm proposing a new is_constructible trait, one that disallows reference
binding if it constructs a temporary. The catchy name I have is:

is_constructible_and_also_doesnt_bind_a_reference_to_a_materialized_temporary

But for now lets call it 'my_is_constructible'. Below is an example of how
it functions differently from

  static_assert(is_constructible_v<int&&, long&> == true);
  static_assert(my_is_constructible_v<int&&, long&> == false);;


Maybe somebody has something better?

/Eric

--
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/01a45b7c-e1c2-4a4b-b6d6-a2bb2bd837bf%40isocpp.org.

------=_Part_975_1750053323.1485228833178
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div style=3D"font-family: arial, sans-serif; font-size: s=
mall;">Hi,</div><div style=3D"font-family: arial, sans-serif; font-size: sm=
all;"><br></div><div style=3D"font-family: arial, sans-serif; font-size: sm=
all;">The is_constructible trait has problems when used on references. It w=
ill correctly check if the construction is well formed, but that well-forme=
d reference construction may bind to a materialized temporary. When is_cons=
tructible is being used to constrain &quot;constructors&quot; for container=
s which store =C2=A0references it gets the answer effectively wrong (e.g. p=
air, tuple, variant?)=C2=A0</div><div style=3D"font-family: arial, sans-ser=
if; font-size: small;"><br></div><div style=3D"font-family: arial, sans-ser=
if; font-size: small;">So I&#39;m proposing a new is_constructible trait, o=
ne that disallows reference binding if it constructs a temporary. The catch=
y name I have is:</div><div style=3D"font-family: arial, sans-serif; font-s=
ize: small;"><br></div><div style=3D"font-family: arial, sans-serif; font-s=
ize: small;">is_constructible_and_also_<wbr>doesnt_bind_a_reference_to_a_<w=
br>materialized_temporary</div><div style=3D"font-family: arial, sans-serif=
; font-size: small;"><br></div><div style=3D"font-family: arial, sans-serif=
; font-size: small;">But for now lets call it &#39;my_is_constructible&#39;=
.. Below is an example of how it functions differently from=C2=A0</div><div =
style=3D"font-family: arial, sans-serif; font-size: small;"><br></div><div =
style=3D"font-family: arial, sans-serif; font-size: small;">=C2=A0 static_a=
ssert(is_<wbr>constructible_v&lt;int&amp;&amp;, long&amp;&gt; =3D=3D true);=
</div><div style=3D"font-family: arial, sans-serif; font-size: small;">=C2=
=A0 static_assert(my_is_<wbr>constructible_v&lt;int&amp;&amp;, long&amp;&gt=
; =3D=3D false);;</div><div style=3D"font-family: arial, sans-serif; font-s=
ize: small;"><br></div><div style=3D"font-family: arial, sans-serif; font-s=
ize: small;"><br></div><div style=3D"font-family: arial, sans-serif; font-s=
ize: small;">Maybe somebody has something better?</div><div style=3D"font-f=
amily: arial, sans-serif; font-size: small;"><br></div><div style=3D"font-f=
amily: arial, sans-serif; font-size: small;">/Eric</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/01a45b7c-e1c2-4a4b-b6d6-a2bb2bd837bf%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/01a45b7c-e1c2-4a4b-b6d6-a2bb2bd837bf=
%40isocpp.org</a>.<br />

------=_Part_975_1750053323.1485228833178--

------=_Part_974_342523014.1485228833178--

.