-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better approach to use std::variant #1093
Conversation
Signed-off-by: Maksim Derbasov <[email protected]>
0bdee12
to
4a655ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!! I agree we shouldn't use exceptions for flow control in C++. I'm concerned that std::get
might still throw an exception, but I can't think of a better way. std::get_if
is possible, but the resulting code would be a lot more verbose I think.
I do have one comment about the use of static
.
Signed-off-by: Maksim Derbasov <[email protected]>
@Mergifyio backport gz-rendering8 |
✅ Backports have been created
|
* Better approach to use std::variant Signed-off-by: Maksim Derbasov <[email protected]> * Iteration Signed-off-by: Maksim Derbasov <[email protected]> --------- Signed-off-by: Maksim Derbasov <[email protected]> (cherry picked from commit 7765666)
* Better approach to use std::variant Signed-off-by: Maksim Derbasov <[email protected]> * Iteration Signed-off-by: Maksim Derbasov <[email protected]> --------- Signed-off-by: Maksim Derbasov <[email protected]> (cherry picked from commit 7765666)
🦟 Bug fix
Fixes #
Summary
Using exception for a flow control is not a very good approach in a different points of view, like from a code structure, from a performance perspective (https://godbolt.org/z/s883vGr9f)
I'd propose to use std::holds_alternative as a more simple way to improve this part of code.
Also improved some typos
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.