Topic: Auto constructor to variable that has been declared type.


Author: otakuto otakuto <otakuto5648@gmail.com>
Date: Sun, 2 Feb 2014 07:16:44 -0800 (PST)
Raw View
------=_Part_530_127588.1391354204299
Content-Type: text/plain; charset=UTF-8

Now that in C++, auto constructor is calling constructors by type deduction
of constructor arguments.
But I want to call constructors by type deduction of variable when auto
constructor to variable that has been declared type.
Where you can not use auto variable, for example the type of the
initialization of the member variable will be able to be abbreviated.

#include <vector>
#include <type_traits>

struct foo
{
    std::vector<int> a;
    std::vector<int> *b;
    foo()
    {
        //This is the same as "a =
std::remove_pointer<decltype(a)>::type();" or "a = decltype(a)();"
        a = auto();

        //This is the same as "b = new
std::remove_pointer<decltype(b)>::type();"
        b = new auto();
    }
};

Thank you

--

---
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/.

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

<div dir=3D"ltr">Now that in C++, auto constructor is calling constructors =
by type deduction of constructor arguments.<br>But I want to call construct=
ors by type deduction of variable when auto constructor to variable that ha=
s been declared type.<br>Where you can not use auto variable, for example t=
he type of the initialization of the member variable will be able to be abb=
reviated.<br><br>#include &lt;vector&gt;<br>#include &lt;type_traits&gt;<br=
><br>struct foo<br>{<br>&nbsp;&nbsp;&nbsp; std::vector&lt;int&gt; a;<br>&nb=
sp;&nbsp;&nbsp; std::vector&lt;int&gt; *b;<br>&nbsp;&nbsp;&nbsp; foo()<br>&=
nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //This is=
 the same as "a =3D std::remove_pointer&lt;decltype(a)&gt;::type();" or "a =
=3D decltype(a)();"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a =3D aut=
o();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //This is the same a=
s "b =3D new std::remove_pointer&lt;decltype(b)&gt;::type();"<br>&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b =3D new auto();<br>&nbsp;&nbsp;&nbsp; }<=
br>};<br><br>Thank you<br></div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_530_127588.1391354204299--

.