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

no make_unexpected with nsel_USES_STD_EXPECTED #66

Closed
psyinf opened this issue Jun 3, 2024 · 9 comments
Closed

no make_unexpected with nsel_USES_STD_EXPECTED #66

psyinf opened this issue Jun 3, 2024 · 9 comments

Comments

@psyinf
Copy link

psyinf commented Jun 3, 2024

I'm using the library indirectly via BehaviorTree.CPP.
Using a recent clang(17.0.3)/gcc(14.1) the code doesn't compile anymore due to make_unexpected not being available.

I currently patched this locally by adding this into the #if nsel_USES_STD_EXPECTED path (~ line 253):

constexpr auto make_unexpected(E&& value)
{
  return std::unexpected(std::forward<E>(value));
}

If wanted, I can submit a PR with the change or maybe I'm doing something wrong here?

@martinmoene
Copy link
Owner

Thanks for the heads-up.

Function make_expected() was part of the proposal for std::expected up to and including revision 3 and is available with the nonstd::expected implementation provided nsel_P0323R <= 3 (see section Configuration).

Consequently make_expected() is not available when std::expected is used for nonstd::expected when available and requested as you experience with the recent compilers. Note: in this case it will not help to -Dnsel_P0323R=3

The idea of excpected-lite being a migration path to std::expected, suggests (indeed) that make_expected() and comparison functions should be available in the case of std::expected being used for nonstd::expected AND -Dnsel_P0323R=3 (2 to also include comparison functions).

I'll look into that, unsure how quickly I'll get at it.

@psyinf
Copy link
Author

psyinf commented Jun 3, 2024

Thanks for looking into it.

The challenge here lies in the expected-lite being used by other libraries taking the liberty in using the P0323R suggested feature throughout their codebase. My suggestion is merely a quick-fix, trying to forward the ´std::unexpected{}´-idiom to the ´make_unexpected´ functionality.

@martinmoene
Copy link
Owner

martinmoene commented Jun 3, 2024

I'll add make_expected() unconditionally (assuming nsel_P0323R is already used) for use with std::expected().

Have yet to correct the test suite for use with std::expected, which wasn't yet available at the time of writing.

@martinmoene
Copy link
Owner

Argh, I now realise it's (also) about make_unexpected()...

Will continue tomorrow.

martinmoene added a commit that referenced this issue Jun 4, 2024
Available via nonstd namespace:
- std::expected;
- std::unexpected;
- std::bad_expected_access;
- std::unexpect_t;
- std::unexpect;
- make_unexpected()

Remove make_expected() from previous commit.
@psyinf
Copy link
Author

psyinf commented Jun 4, 2024

@martinmoene Thanks for tackeling the issue. I'll try to the current head in my scenario and advise the authors of BehaviorTree.CPP to use a new release, as soon as available.

@martinmoene
Copy link
Owner

Currently adapting the test suite for when std:: exception is being used.

Will make a release after that, presumably v0.8.0.

@psyinf
Copy link
Author

psyinf commented Jun 4, 2024

Just tested compliation with gcc and clang locally, looks good, so the issue can be closed,
Thank you again for the speedy solution

@martinmoene
Copy link
Owner

Thanks for your feedback & you're welcome.

@martinmoene
Copy link
Owner

@psyinf Released expected-lite v0.8.0.

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

No branches or pull requests

2 participants