<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 16 Apr 2023 at 08:11, Ville Voutilainen &lt;<a href="mailto:ville.voutilainen@gmail.com">ville.voutilainen@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sun, 16 Apr 2023 at 13:40, Edward Catmur &lt;<a href="mailto:ecatmur@googlemail.com" target="_blank">ecatmur@googlemail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; Fine, and how do we specify the facility that such moves have undefined/unspecified behavior but the cases we want to allow do? I can&#39;t see a way.<br>
&gt;&gt;<br>
&gt;&gt; We don&#39;t. If I want to store these things in a vector and move the<br>
&gt;&gt; vector around, that&#39;s my business. I&#39;ll need to disable the elements<br>
&gt;&gt; if the vector<br>
&gt;&gt; has been moved. If I want to wrap these things in a shared_ptr after<br>
&gt;&gt; allocating them dynamically, and then store those shared_ptrs into a<br>
&gt;&gt; vector,<br>
&gt;&gt; that&#39;s my business, and none of the library&#39;s to prevent.<br>
&gt;<br>
&gt;<br>
&gt; And we need to know what happens when you do that, or know that it is unspecified. What I&#39;m saying is that the behavior needs to be specified, or explicitly unspecified. If the behavior is specified in terms of uncaught_exceptions(), that takes care of it, but leaves the coroutine case broken.<br>
<br>
I fail to see the problem. It&#39;s as if you&#39;re suggesting that there&#39;s<br>
some unknown specification challenge here, but we have the<br>
specification<br>
you speak of already, in the TS.<br></blockquote><div><br></div><div>And that specification breaks with coroutines.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt;&gt; No library type prevents using it as a subobject, or prevents itself<br>
&gt;&gt; completely from working with other library types. It sure as hell<br>
&gt;&gt; matters.<br>
&gt;<br>
&gt;<br>
&gt; std::typeinfo? std::chrono::time_zone?<br>
<br>
Yes? Neither of those needs other than pointers to them to work. Scope<br>
guards are not like them.<br>
You found two cases that presumably prove my statement wrong, but<br>
(pointers to) those types can<br>
be used as subobjects, that works fine, and they work with other<br>
library types without problems, since<br>
for them it&#39;s truly so that you don&#39;t need by-value subobjects of them.<br>
<br>
Try harder.<br></blockquote><div><br></div><div>And you can take pointers to scope guards. Consider also immovable types like scoped_lock - those won&#39;t work with most library components.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt;&gt; &gt; Working well can be dealt with by the vendor since these are library types. Wrong - maybe, but this is a scope guard! The name indicates it should be used in a scope.<br>
&gt;&gt; Yeah, which does include packaging them any which way I please and<br>
&gt;&gt; passing them down to helper functions for further processing,<br>
&gt;&gt; or just having a collection-bunch of them in a scope, rather than<br>
&gt;&gt; having to have individual objects of the scope guard type directly,<br>
&gt;&gt; without<br>
&gt;&gt; the possibility to bunch them.<br>
&gt; I&#39;ve never seen code where that would actually be useful.<br>
<br>
Uhh.. you&#39;ve never seen code that packages multiple individual objects<br>
into a bunch, to pass them as one object to be processed<br>
by a helper function? You can&#39;t fathom code where you&#39;d take a pack of<br>
callbacks and wrap scope guards on top of them, variadically?<br></blockquote><div><br></div><div>No, since you may as well wrap the lot into a single scope guard.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Yeah, sure, I can show you that example you asked for. In my copious free time.<br>
<br>
&gt;&gt; The current design in the TS is just fine. It specifies how the<br>
&gt;&gt; destructor of these things works, and tells you clearly enough what<br>
&gt;&gt; happens if you move a container of these things around into a scope<br>
&gt;&gt; that has a different value for uncaught_exceptions() than<br>
&gt;&gt; the original scope had.<br>
&gt; It&#39;s not fine, because it breaks with coroutines.<br>
<br>
Well, gee whizz, that&#39;s an acceptable cost, compared to preventing the<br>
use of scope guards as subobjects, which is not an<br>
acceptable cost.</blockquote><div><br></div><div>Using scope_guard outside block scope is a code smell, though it can be justified in some rare cases. Using scope_success or scope_failure outside block scope would not pass code review where I work.</div><div><br></div><div>Meanwhile, using scope_success and scope_failure in coroutine block scope across suspension points is completely natural; the only problem is that it can break. We should not be adding footguns like that to the standard.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> If we have a solution that doesn&#39;t do that prevention<br>
and solves the coroutine problem, I&#39;m all ears.<br></blockquote><div><br></div><div>There&#39;s Andrey&#39;s solution, but the overhead is substantial.</div></div></div>

