[Idea] Use Raii + operator bool instead of begin/end functions #9531
Closed
light-and-ray
started this conversation in
New Users Build/Link/Run issues ONLY!
Replies: 1 comment 2 replies
|
Please don’t use Discussions for this, it is clearly highlighted in many locations.
I typed “raii” into the search box and immediately found for #2096 for discussions about Raii. |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello. I'm exploring your library. And it looks very neat! But I don't see the need in
End...functions:ImGui::EndMenu,ImGui::EndMenuBar, etcInstead of returning
boolfromImGui::BeginMenu, it can return an object with overriddenoperator bool, and in the destructor it callsImGui::EndMenu()Here is a quick example:
I'm sorry if this idea is banal and was discussed many times 😅 I haven't found a similar discussion. But the fact that you have to write end functions looks out of place, so if it has never been considered, it worth consider this.. Maybe there are some use cases for begin/end functions in more complex scenarios, where you need to call them earlier, or begin menu earlier. But an alternative have these Raii equivalents would be very neat
It also can be generalized with a class template:
All reactions