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

Modify constructor constraints to make 'optional<any>' work on libc++ #99

Merged

Conversation

jiixyj
Copy link
Contributor

@jiixyj jiixyj commented Dec 31, 2024

For enable_forward_value, I just reordered the constraints so that the check against optional comes first. This fixes a "satisfaction of constraint 'detail::enable_forward_value<T, U>' depends on itself" error on clang.

For enable_from_other I introduced a !std::is_same_v<T, U> as the first check. This also fixes a "satisfaction of constraint ... depends on itself" error. This check should lead to no change in behavior as in the case where T and U are the same, optional<T>'s copy/move constructors should be used anyway.

@coveralls
Copy link

coveralls commented Dec 31, 2024

Coverage Status

coverage: 93.443% (+0.2%) from 93.22%
when pulling 7cb9b44 on jiixyj:reorder-constructor-constraints
into bb60b34 on bemanproject:main.

Copy link
Member

@steve-downey steve-downey 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 these and related PRs! I will take a look at all of them in the next few days.

Copy link
Member

@steve-downey steve-downey left a comment

Choose a reason for hiding this comment

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

I've reproduced this against a few versions of clang/libc++. Older versions fail instead on !std::is_convertible_v<optional<U>&, T> && not being a constant expression, which I'm pretty sure is a bug in libc++.

Still making sure I understand the changes in enable_from_other. I may have been smarter when I wrote that.

!std::is_constructible_v<T, const optional<U>&&> && !std::is_convertible_v<optional<U>&, T> &&
!std::is_convertible_v<optional<U>&&, T> && !std::is_convertible_v<const optional<U>&, T> &&
!std::is_convertible_v<const optional<U>&&, T>;
!std::is_same_v<T, U> && std::is_constructible_v<T, Other> && //
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the // at the end of line needs to be there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it doesn't need to be there. Sometimes I do this out of habit to force clang-format to break a line. In this case it makes it so that the next two lines are the is_constructible_vs and the two lines after that are the "matching" is_convertible_vs.

Should I remove it? The diff would certainly look nicer.

Copy link
Member

Choose a reason for hiding this comment

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

I think removing it will make the diff look a little cleaner. I'm making a note to come back to this to clean up formatting, or refactor into smaller concepts, so it's more obvious what is intended and how they fit together.

The primary template was really, originally, just to have a base case for the optional<T&> part and I didn't expect to have to revisit it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I reverted the formatting change and merged main.

Copy link
Member

Choose a reason for hiding this comment

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

Would it be OK to put you in the acknowledgements for the next rev of the paper? It's going out in the next few days and hopefully reviewed and forwarded for C++26 in a few weeks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be OK to put you in the acknowledgements for the next rev of the paper? It's going out in the next few days and hopefully reviewed and forwarded for C++26 in a few weeks.

Sure, thank you!

Copy link
Member

@steve-downey steve-downey left a comment

Choose a reason for hiding this comment

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

👍

@steve-downey steve-downey merged commit 4e8377f into bemanproject:main Jan 6, 2025
9 checks passed
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