C++ Logo


Advanced search

Re: [std-proposals] Quick Idea: Enable/Disable Auto Gens

From: Jens Maurer <Jens.Maurer_at_[hidden]>
Date: Fri, 8 Jul 2022 13:47:16 +0200
On 08/07/2022 11.57, Oktlryk via Std-Proposals wrote:
> Hello
> I was doing a course over at Udemy on Unreal Engine C++ programming, and tons of the code (I mean there were a lotta functions involving this) enabled or disabled some boolean or set some value to true/false, as like in semaphore types.
> And I had to write two functions for each like: void EnableStuff() + void DisableStuff(). Which got me thinking, why not handle this at the language level. Like you could indicate if a function was a Enable/Disable actuator and only require the expressed inclusion of the function in definition. For example:
> void *endis* Stuff(bool setMe); // endis (Enable/Disable keyword)
> then when calling:
> Stuff.enable() = enable // sets setMe to true
> Stuff.disable() = disable // sets setMe to false

Please show a complete class definition that has a data
member and one of these "endis" functions setting the
data member. Is a getter for the bool also in view?

And then show the declaration of a variable of that class
type with an invocation of one of "endis" functions.

And then, please tell me which constructs are supposed
to be new keywords. And then, please do some research
to show how much existing code that uses those new
keywords in other ways would break.


Received on 2022-07-08 11:47:21