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

Adopt LWG-3541 indirectly_readable_traits should be SFINAE-friendly for all types #1992

Merged

Conversation

miscco
Copy link
Contributor

@miscco miscco commented Jun 9, 2021

No description provided.

This makes indirectly_readable_traits SFINAE friendly and adds some tests for that

Addresses microsoft#1965
@miscco miscco requested a review from a team as a code owner June 9, 2021 11:14
@StephanTLavavej StephanTLavavej added the LWG Library Working Group issue label Jun 10, 2021
@StephanTLavavej StephanTLavavej changed the title Adopt LWG-3541 Adopt LWG-3541 indirectly_readable_traits should be SFINAE-friendly for all types Jun 10, 2021
@CaseyCarter CaseyCarter mentioned this pull request Jun 10, 2021
36 tasks
@barcharcraz barcharcraz self-assigned this Jun 16, 2021
Comment on lines 3391 to 3394
STATIC_ASSERT(same_as<SFINAE<int>::value_type, int>);
STATIC_ASSERT(same_as<SFINAE<int const>::value_type, int>);
STATIC_ASSERT(same_as<SFINAE<int volatile>::value_type, int>);
STATIC_ASSERT(same_as<SFINAE<int const volatile>::value_type, int>);
Copy link
Member

Choose a reason for hiding this comment

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

Why not simply STATIC_ASSERT(same_as<indirectly_readable_traits<iterish<int meow>>, int>)? And don't we already have coverage for these cases elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wasnt the whole point of the issue to ensure that it is SFINAE friendly?

AFAIK STATIC_ASSERT(same_as<indirectly_readable_traits<iterish<int meow>>, int>) does not check that?

Copy link
Member

Choose a reason for hiding this comment

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

We can't determine if something is SFINAE-friendly with test cases that don't cause substitution failure. The iterish<float meow> test cases validate the point of the change; without it, has_member_value_type<indirectly_readable_traits<iterish<float meow>>> would produce a compile error instead of evaluating to false. These test cases are simply verifying that things that worked before continue to work, which - as I suggested - I suspect we have coverage of elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interestingly we already have exactly that test directly above.

This suggests, that the change is not really needed. I have removed the duplicated tests

Copy link
Member

Choose a reason for hiding this comment

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

Interestingly we already have exactly that test directly above. This suggests, that the change is not really needed. I have removed the duplicated tests

Oh 🤦. This is the issue I've been talking with our compiler devs and EDG about for the last couple of weeks: MSVC and Clang non-conformingly are treating ambiguity while choosing a partial template specialization as being a SFINAE-able error in cases where they should not be doing so. The test cases were passing because of the bug, but will need the product code change to keep working once the compiler bugs are fixed.

Copy link
Member

Choose a reason for hiding this comment

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

I'm leaving this unresolved - despite that there's nothing here to resolve - to point out why we're adding no new test coverage in this PR.

tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp Outdated Show resolved Hide resolved
@StephanTLavavej StephanTLavavej self-assigned this Jun 24, 2021
@StephanTLavavej StephanTLavavej merged commit 61ff9e6 into microsoft:main Jun 29, 2021
@StephanTLavavej
Copy link
Member

Thanks for making the STL friendlier to SFINAE! 😻 🎉 🚀

@miscco miscco deleted the LWG-3541-indirectly-readable-trait branch June 30, 2021 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LWG Library Working Group issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants