🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++
Article #1005

Re: A better experimental::scope_exit

#1005
From: Bonita Montero
Date: Mon, 23 Nov 2026 14:07
42 lines
3227 bytes
Am 23.11.2026 um 10:41 schrieb Tristan Wibberley:

> A little excess irregularity, I feel; why not provide a static instance
> of "empty" which can be used to terminate the list of deps then provide
> an explicit template specialisation for the sugar of using "void"?

The code is correct. If the node our node depends on isn't void

> Furthermore "assert" is a bit risky because it's /always/ invalid to
> flow the control onward when the condition isn't met, not only in builds
> other than NDEBUG, yet C++ has exceptions to abort and avoid invalid
> continuation too.

The code should result in a debug break point and usually the debugger
doesn't allow any further execution. That's exactly what I want. An
exception is the wrong thing here.

> Do you mean it to be dual pattern either:
>   a) pointer to instance of any type with the required interface which
>      re-implements the necessary member functions
>   b) all work provided exactly when the client code has only a function

If you have a disable() on the last node in a chain all nodes we're
depending on should also be disabled. If you call a run in the same
manner all nodes we depend on should be executed also.
Why is that so hard to understand ? It's one screenpage of code.

> I feel there could be some improvement also by making the basic features
> of disablement and forwarding available to derived classes which merely
> then need to override a virtual member function to complete their
> typical implementation. Which brings me to ...

With virtual functions this woudln't be that lightweight I implemented
it.

> I'm a bit out of date, I suppose "final" prevents derivation, but why
> prevent it? Some need to restrict all "new" instances to some special
> array, perhaps? It would be a bit odd.

An extension woudln't make sense. Also because the innards of the class
are private.
Technical Details
Message-ID: <11e1hab$1u79m$1@raubtier-asyl.eternal-september.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
References: <11dsk17$8ske$2@raubtier-asyl.eternal-september.org> <11e11p1$1o6vh$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita Montero <Bonita.Montero@gmail.com>
Newsgroups: comp.lang.c++
Subject: Re: A better experimental::scope_exit
Date: Mon, 23 Nov 2026 15:07:08 +0100
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <11e1hab$1u79m$1@raubtier-asyl.eternal-september.org>
References: <11dsk17$8ske$2@raubtier-asyl.eternal-september.org>
 <11e11p1$1o6vh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 23 Nov 2026 14:07:08 +0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org;
	logging-data="2039094"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18ly6V/g0QViP/G/NwPyiPvHxV78BEWYzU="; posting-host="6d91dc74f77a8fc154aca66c0d8ca15e"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:OX9zMPWWOZ9xIoDYrnMBVYMjgkw= sha256:Jg4qOBo90S3u0AfJOWI1OAwljdE5GO8ejXMkewIQZjg=
	sha1:5KTjEao+WI1/e/ymYbulnkx5NjY= sha256:LUJjVu7gKTR0Ijgii3saqKT1mSmSW6OwXxhhHFEodGQ=
In-Reply-To: <11e11p1$1o6vh$1@dont-email.me>
Content-Language: de-DE