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 align 'iox::expected' with 'std::expected' #1969

Closed
9 tasks done
elBoberido opened this issue Apr 11, 2023 · 2 comments · Fixed by #1970 or #1981
Closed
9 tasks done

Better align 'iox::expected' with 'std::expected' #1969

elBoberido opened this issue Apr 11, 2023 · 2 comments · Fixed by #1970 or #1981
Assignees
Labels
refactoring Refactor code without adding features technical debt unclean code and design flaws

Comments

@elBoberido
Copy link
Member

elBoberido commented Apr 11, 2023

Brief feature description

Currently the iox::expected differs from the newly introduced C++23 std::expected. To make it easier for developer already familiar with std::expected the custom implementation in iceoryx should be aligned where possible.

Detailed information

In scope:

  • implicit conversion from T -> we will not have implicit conversion; for safety code it is better to be explicit
  • default ctor creates an expected with a T if T has a default ctor -> we will not have default ctors; for safety code it is better to be explicit
  • introduction of iox::unexpected, iox::unexpect_t and iox::unexpect
  • introduction of iox::ok(...) and iox::err(...) as convenience function due to missing CTAD in C++14
  • rename and move of iox::success and iox::error to iox::detail::ok and iox::detail::err
  • remove static iox::expected<T, E>::create_value and iox::expected<T, E>::create_error in favor of ctors with iox::in_place and iox::unexpect
  • introduction of iox::expected<T, E>::has_value
  • introduction of iox::expected<T, E>::value and deprecation of iox::expected<T, E>::get_value
  • introduction of iox::expected<T, E>::error and deprecation of iox::expected<T, E>::get_error

Out of scope

  • introduction of transform
  • aligning of the semantics of and_then and or_else
elBoberido added a commit to ApexAI/iceoryx that referenced this issue Apr 11, 2023
@elBoberido elBoberido self-assigned this Apr 11, 2023
@elBoberido elBoberido added refactoring Refactor code without adding features technical debt unclean code and design flaws labels Apr 11, 2023
@mossmaurice
Copy link
Contributor

@elBoberido Thanks for creating the issue! 🙏 Do you also see possible extensions like a try operator macro in the scope of this issue?

default ctor creates an expected with a T if T has a default ctor

I don't think having a default c'tor with expected is a good idea. An expected should always have a clear state. IMHO the committee did a mistake here.

@elBoberido
Copy link
Member Author

@mossmaurice this is just a proposal and we can omit some of the ctors or implicit conversion if we deem them unfit for safety. A try macro would be done in a separate issue. This is mainly for the alignment with the std::expected

elBoberido added a commit to ApexAI/iceoryx that referenced this issue Apr 18, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue Apr 18, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue Apr 18, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue Apr 18, 2023
elBoberido added a commit that referenced this issue Apr 18, 2023
…-expected

iox-#1969 rework constructors for expected
@elBoberido elBoberido linked a pull request Apr 18, 2023 that will close this issue
21 tasks
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit to ApexAI/iceoryx that referenced this issue May 5, 2023
elBoberido added a commit that referenced this issue Jun 6, 2023
…td-expected-and-add-convenience-free-functions

iox-#1969 align iox expected to std expected and add convenience free functions
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
musamaanjum pushed a commit to musamaanjum/iceoryx that referenced this issue Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactor code without adding features technical debt unclean code and design flaws
Projects
None yet
2 participants