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

Fix SFINAE bug in container base type #890

Merged

Conversation

stephenswat
Copy link
Member

This commit fixes a bug in the use of SFINAE in the container base type. In particuler, this issue has three layers:

  1. The existing code uses the typename = std::enable_if anti-pattern which is discouraged in the C++ standard.
  2. The code used std::enable_if without getting ::type from it, meaning that a specialization failure cannot ever occur, rendering the SFINAE useless.
  3. The check used about type equality is incorrect, it should rather check constructability.

This commit fixes the issues by converting the code to a C++20 requires clause and by modifying the conditions.

@stephenswat stephenswat added bug Something isn't working edm Changes to the data model labels Feb 25, 2025
Copy link
Member

@krasznaa krasznaa left a comment

Choose a reason for hiding this comment

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

I was a little afraid that you would've spent too much time on this code, which is on its way out. But glad to see that the size of the change is appropriate. 😄

Sure, let's do this!

@stephenswat
Copy link
Member Author

which is on its way out.

TIL 😆

@stephenswat stephenswat force-pushed the fix/container_base_sfinae branch from 52394d9 to aa65d4f Compare February 25, 2025 10:16
This commit fixes a bug in the use of SFINAE in the container base type.
In particuler, this issue has three layers:

1. The existing code uses the `typename = std::enable_if` anti-pattern
   which is discouraged in the C++ standard.
2. The code used `std::enable_if` without getting `::type` from it,
   meaning that a specialization failure cannot ever occur, rendering
   the SFINAE useless.
3. The check used about type equality is incorrect, it should rather
   check constructability.

This commit fixes the issues by converting the code to a C++20 requires
clause and by modifying the conditions.
@stephenswat stephenswat force-pushed the fix/container_base_sfinae branch from aa65d4f to 3be3318 Compare February 26, 2025 12:39
@stephenswat stephenswat merged commit bc90eb3 into acts-project:main Feb 26, 2025
26 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working edm Changes to the data model
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants