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

iox-#1969 align iox expected to std expected and add convenience free functions #1981

Conversation

elBoberido
Copy link
Member

@elBoberido elBoberido commented May 5, 2023

Pre-Review Checklist for the PR Author

  1. Code follows the coding style of CONTRIBUTING.md
  2. Tests follow the best practice for testing
  3. Changelog updated in the unreleased section including API breaking changes
  4. Branch follows the naming format (iox-123-this-is-a-branch)
  5. Commits messages are according to this guideline
  6. Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  7. Relevant issues are linked
  8. Add sensible notes for the reviewer
  9. All checks have passed (except task-list-completed)
  10. All touched (C/C++) source code files from iceoryx_hoofs are added to ./clang-tidy-diff-scans.txt
  11. Assign PR to reviewer

Notes for Reviewer

This PR aligns the iox::expected better to the std::expected

  • remove expected<E> in favor of expected<void, E>
  • replace get_error with error
  • introduce has_value
  • introduce ok and error free functions
  • introduce unexpect_t helper struct for direct initialization

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Code according to our coding style and naming conventions
  • Unit tests have been written for new behavior
  • Public API changes are documented via doxygen
  • Copyright owner are updated in the changed files
  • All touched (C/C++) source code files from iceoryx_hoofs have been added to ./clang-tidy-diff-scans.txt
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

@elBoberido elBoberido added bugfix Solves a bug refactoring Refactor code without adding features labels May 5, 2023
@elBoberido elBoberido self-assigned this May 5, 2023
@elBoberido elBoberido force-pushed the iox-1969-align-iox-expected-to-std-expected-and-add-convenience-free-functions branch from 1720ed6 to af7f994 Compare May 5, 2023 15:42
@elBoberido elBoberido marked this pull request as ready for review May 5, 2023 15:42
@codecov
Copy link

codecov bot commented May 5, 2023

Codecov Report

Merging #1981 (af7f994) into master (7fa9160) will decrease coverage by 0.11%.
The diff coverage is 67.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1981      +/-   ##
==========================================
- Coverage   74.23%   74.13%   -0.11%     
==========================================
  Files         413      405       -8     
  Lines       16067    15942     -125     
  Branches     2250     2242       -8     
==========================================
- Hits        11928    11818     -110     
+ Misses       3425     3413      -12     
+ Partials      714      711       -3     
Flag Coverage Δ
unittests 73.91% <67.57%> (+<0.01%) ⬆️
unittests_timing 14.92% <13.84%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...oryx_dust/include/iceoryx_dust/design/creation.hpp 100.00% <ø> (ø)
...st/include/iceoryx_dust/internal/cli/arguments.inl 0.00% <0.00%> (ø)
.../include/iceoryx_dust/posix_wrapper/named_pipe.hpp 100.00% <ø> (ø)
...ude/iceoryx_hoofs/internal/posix_wrapper/mutex.hpp 100.00% <ø> (ø)
.../include/iceoryx_hoofs/posix_wrapper/file_lock.hpp 100.00% <ø> (ø)
...de/iceoryx_hoofs/posix_wrapper/named_semaphore.hpp 100.00% <ø> (ø)
...ofs/include/iceoryx_hoofs/posix_wrapper/thread.hpp 100.00% <ø> (ø)
.../iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp 100.00% <ø> (ø)
...ceoryx_hoofs/posix/filesystem/include/iox/file.hpp 100.00% <ø> (ø)
iceoryx_hoofs/vocabulary/include/iox/expected.hpp 100.00% <ø> (ø)
... and 91 more

... and 13 files with indirect coverage changes

Copy link
Contributor

@mossmaurice mossmaurice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM content-wise, thanks! Sorry for being a smug here, but would you mind updating the year in the copyright headers? 😅

@@ -51,7 +51,7 @@ class FunctionalInterface_test : public testing::Test
};

/// @brief This types is used for testing the functional interface in the case
/// of a value and a get_error method
/// of a 'value' and a 'error' method
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

using DummyValueType = bool;
static constexpr DummyValueType DUMMY_VALUE{true};

iox::variant<DummyValueType, ErrorType> data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that should be enough, right?

Suggested change
iox::variant<DummyValueType, ErrorType> data;
variant<DummyValueType, ErrorType> data;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The additional namespace does not hurt :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's not needed :)

/// @brief helper struct to create an expected which is signalling success more easily
/// @param T type which the success helper class should contain
template <typename T = void>
using success = detail::ok<T>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be deprecated?

Copy link
Contributor

@mossmaurice mossmaurice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved under the condition that the copyright header is updated in a follow-up.

@elBoberido
Copy link
Member Author

Sorry, all relevant copyright header are updated. A mass search and replace does not warrant an update of the copyright header.

@elBoberido elBoberido merged commit 06799c9 into eclipse-iceoryx:master Jun 6, 2023
@elBoberido elBoberido deleted the iox-1969-align-iox-expected-to-std-expected-and-add-convenience-free-functions branch June 6, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Solves a bug refactoring Refactor code without adding features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

expected<void, Error> is unusable due to final Better align 'iox::expected' with 'std::expected'
3 participants