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

remove exceptions #23

Open
wants to merge 13 commits into
base: kp/job-manager
Choose a base branch
from
Open

remove exceptions #23

wants to merge 13 commits into from

Conversation

koonpeng
Copy link
Member

@koonpeng koonpeng commented Nov 9, 2023

This is a preview of the work in removing exceptions.

Inspired from rust, Result<T> is the alternative to exceptions. Internally it uses std::variant to store either the result or a std::exception.

  • [[nodiscard]] should almost always be used when returning Result<T>. We don't have custom lint rules so it will have to be checked manually.
  • Result<void> is a special case that using std::optional instead.
  • One downside is that we cannot return a reference, Result<T&> does not work because std::variant cannot contain references.
    • In theory should be able to specialize Result<T> for all reference types and store a pointer internally instead.

@koonpeng koonpeng marked this pull request as draft November 9, 2023 07:55
@koonpeng koonpeng requested a review from Yadunund November 9, 2023 07:55
@koonpeng koonpeng changed the base branch from main to kp/job-manager November 9, 2023 08:20
@koonpeng koonpeng changed the title WIP remove exceptions remove exceptions Nov 20, 2023
@koonpeng koonpeng marked this pull request as ready for review November 20, 2023 02:56
@koonpeng
Copy link
Member Author

Integration test is working with the latest release of ros2 iron, but the docker images are not updated yet.

@Yadunund
Copy link
Member

Yadunund commented Dec 4, 2023

Could you merge the latest main into the base branch also rebase/update this branch?

Teo Koon Peng added 11 commits November 27, 2024 12:43
Signed-off-by: Teo Koon Peng <[email protected]>
Signed-off-by: Teo Koon Peng <[email protected]>
Signed-off-by: Teo Koon Peng <[email protected]>
Signed-off-by: Teo Koon Peng <[email protected]>
Signed-off-by: Teo Koon Peng <[email protected]>
Signed-off-by: Teo Koon Peng <[email protected]>
Signed-off-by: Teo Koon Peng <[email protected]>
Signed-off-by: Teo Koon Peng <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
@luca-della-vedova
Copy link
Member

I'm wondering, especially now that we bumped main to 24.04 and all the compiler versions are fairly recent, would it make sense to increase our C++ standard to C++23 and use std::expected rather than manually implementing our own Result type?

@koonpeng
Copy link
Member Author

koonpeng commented Dec 3, 2024

I'm wondering, especially now that we bumped main to 24.04 and all the compiler versions are fairly recent, would it make sense to increase our C++ standard to C++23 and use std::expected rather than manually implementing our own Result type?

I'm down for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants