Topic: Re: [std-proposals] Re: Question for Germ n Diago:


Author: Jeremy Maitin-Shepard <jeremy@jeremyms.com>
Date: Sun, 26 Oct 2014 19:11:39 -0700
Raw View
--f46d0444037016cd5105065e0d6c
Content-Type: text/plain; charset=UTF-8

On Sun, Oct 26, 2014 at 6:09 PM, Gor Nishanov <gornishanov@gmail.com> wrote:

>
> On Sunday, October 26, 2014 5:16:52 PM UTC-7, Jeremy Maitin-Shepard wrote:
>
>> the initial state, which is always possible.
>>
>>
> Look at the countdown example on page 5 and add "std::mutex m;" inside of
> the lambda, just before std::cout << ... Unless we change the definition of
> the std::mutex to allow it to move, the code won't compile at all as it
> would be impossible to generate the move constructor for the lambda.
>

My understanding is that the initial state would be the state where all of
the captures have been initialized but none of the code in the body has
executed nor have any of the local variables been initialized.

Based on that understanding (please correct me if I'm wrong):

Even if we add a local std::mutex variable, the initial state will only
have the capture variable n initialized.  There will be memory reserved for
the mutex but it will be uninitialized.

The generated move/copy constructor will test if the state is the initial
state, in which case it need only move/copy n.  The uninitialized memory
for the mutex variable will be ignored.  If the state is such that the
mutex variable *has* been initialized, then the copy and move constructors
throw.

--

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

--f46d0444037016cd5105065e0d6c
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 S=
un, Oct 26, 2014 at 6:09 PM, Gor Nishanov <span dir=3D"ltr">&lt;<a href=3D"=
mailto:gornishanov@gmail.com" target=3D"_blank">gornishanov@gmail.com</a>&g=
t;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span c=
lass=3D""><div><br>On Sunday, October 26, 2014 5:16:52 PM UTC-7, Jeremy Mai=
tin-Shepard wrote:</div><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border=
-left-width:1px;border-left-style:solid"><div dir=3D"ltr"><div>the initial =
state, which is always possible. <br></div><br></div></blockquote><div><br>=
</div></span><div>Look at the countdown example on page 5 and add &quot;std=
::mutex m;&quot;=C2=A0inside of the lambda, just before std::cout &lt;&lt; =
.... Unless we change the definition of the std::mutex to allow it to move,=
=C2=A0the code=C2=A0won&#39;t compile at all as it would be impossible to g=
enerate the move constructor for the lambda.</div></div></blockquote><div><=
br></div><div>My understanding is that the initial state would be the state=
 where all of the captures have been initialized but none of the code in th=
e body has executed nor have any of the local variables been initialized.<b=
r><br></div><div>Based on that understanding (please correct me if I&#39;m =
wrong):<br><br>Even if we add a local std::mutex variable, the initial stat=
e will only have the capture variable n initialized.=C2=A0 There will be me=
mory reserved for the mutex but it will be uninitialized.<br><br></div><div=
 class=3D"h5">The generated move/copy constructor will test if the state is=
 the initial state, in which case it need only move/copy n.=C2=A0 The unini=
tialized memory for the mutex variable will be ignored.=C2=A0 If the state =
is such that the mutex variable *has* been initialized, then the copy and m=
ove constructors throw.<br></div></div><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&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 />
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 />

--f46d0444037016cd5105065e0d6c--

.