refactor(util): migrate util/* SFINAE patterns to C++20 concepts#7632
Merged
Conversation
Replace enable_if / void_t / SFINAE patterns with requires clauses and standard concepts across four utility headers: - alias.hpp: replace enable_if_t<!is_same<...>> with requires clause - filtered_integer_range.hpp: replace enable_if<is_integral<...>> with requires std::integral<Integer>, drop now-unused <type_traits> - indexed_data.hpp: replace IsValueIterator alias + return-type SFINAE with requires std::same_as<...> and if constexpr dispatch - static_rtree.hpp: replace enable_if constructor template with trailing requires(Ownership == Container) clause Part of #7530
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors several include/util/* headers to replace SFINAE (enable_if, void_t) constraints with C++20 requires-clauses and standard concepts, improving compile-time diagnostics while keeping runtime behavior the same.
Changes:
- Constrains utility APIs using C++20 concepts (
std::integral,std::same_as) andrequiresinstead ofstd::enable_if. - Simplifies
IndexedDataImpl::adapt()into a single constrained template usingif constexprforstd::string_viewhandling. - Updates
StaticRTreecontainer-only constructor gating via arequiresclause rather than a templated SFINAE parameter.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| include/util/alias.hpp | Replaces enable_if-based exclusion on to_alias() with a requires clause; minor formatting-only adjustments. |
| include/util/filtered_integer_range.hpp | Switches filtered_irange() constraint to requires std::integral<Integer> and updates includes accordingly. |
| include/util/indexed_data.hpp | Replaces iterator SFINAE + overload set with a single adapt() constrained by std::same_as plus if constexpr dispatch. |
| include/util/static_rtree.hpp | Replaces constructor SFINAE gating with requires(Ownership == storage::Ownership::Container); minor formatting-only adjustments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7632 +/- ##
==========================================
+ Coverage 90.83% 94.23% +3.40%
==========================================
Files 484 484
Lines 37816 37815 -1
==========================================
+ Hits 34350 35635 +1285
+ Misses 3466 2180 -1286 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Closes #7534
Part of #7530
Replace
enable_if/void_t/ SFINAE patterns withrequiresclauses and standard C++20 concepts across four utility headers.Changes
std::enable_if_t<!std::is_same<...>>default template parameter with trailingrequires(!std::is_same_v<ToAlias, FromNumeric>)onto_alias()std::enable_if<std::is_integral<Integer>::value>SFINAE parameter withrequires std::integral<Integer>; replace now-unused<type_traits>with<concepts>IsValueIteratoralias template + dual-overload return-type SFINAE with a singleadapt()function usingrequires std::same_as<...>for the iterator constraint andif constexprfor thestring_viewdispatchtemplate <typename = std::enable_if<Ownership == Container>>constructor SFINAE with trailingrequires(Ownership == storage::Ownership::Container)🤖 Generated with Claude Code, Claude Sonnet 4.6
Tasklist