Skip to content
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

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

ntfshard
Copy link
Contributor

@ntfshard ntfshard commented Dec 17, 2024

🦟 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

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

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.

@ntfshard ntfshard requested a review from iche033 as a code owner December 17, 2024 16:54
@github-actions github-actions bot added 🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty labels Dec 17, 2024
@ntfshard ntfshard force-pushed the better_variant_using branch from 0bdee12 to 4a655ff Compare December 17, 2024 17:12
Copy link
Contributor

@azeey azeey left a 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.

ogre2/src/Ogre2GpuRays.cc Outdated Show resolved Hide resolved
Signed-off-by: Maksim Derbasov <[email protected]>
@ntfshard ntfshard requested a review from azeey December 18, 2024 13:20
@azeey azeey merged commit 7765666 into gazebosim:gz-rendering9 Dec 18, 2024
10 of 11 checks passed
@azeey
Copy link
Contributor

azeey commented Dec 18, 2024

@Mergifyio backport gz-rendering8

Copy link

mergify bot commented Dec 18, 2024

backport gz-rendering8

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Dec 18, 2024
* 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)
@ntfshard ntfshard deleted the better_variant_using branch December 19, 2024 09:40
iche033 pushed a commit that referenced this pull request Dec 19, 2024
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants