Skip to content

refactor(util): migrate util/* SFINAE patterns to C++20 concepts#7632

Merged
DennisOSRM merged 3 commits into
masterfrom
sfinae-concepts-util-headers
Jun 22, 2026
Merged

refactor(util): migrate util/* SFINAE patterns to C++20 concepts#7632
DennisOSRM merged 3 commits into
masterfrom
sfinae-concepts-util-headers

Conversation

@DennisOSRM

Copy link
Copy Markdown
Collaborator

Issue

Closes #7534
Part of #7530

Replace enable_if / void_t / SFINAE patterns with requires clauses and standard C++20 concepts across four utility headers.

Changes

  • alias.hpp: Replace std::enable_if_t<!std::is_same<...>> default template parameter with trailing requires(!std::is_same_v<ToAlias, FromNumeric>) on to_alias()
  • filtered_integer_range.hpp: Replace std::enable_if<std::is_integral<Integer>::value> SFINAE parameter with requires std::integral<Integer>; replace now-unused <type_traits> with <concepts>
  • indexed_data.hpp: Replace IsValueIterator alias template + dual-overload return-type SFINAE with a single adapt() function using requires std::same_as<...> for the iterator constraint and if constexpr for the string_view dispatch
  • static_rtree.hpp: Replace template <typename = std::enable_if<Ownership == Container>> constructor SFINAE with trailing requires(Ownership == storage::Ownership::Container)

🤖 Generated with Claude Code, Claude Sonnet 4.6

Tasklist

  • self-review code for correctness and following the coding guidelines
  • add tests (existing unit tests cover all changed code paths)
  • review
  • adjust for comments

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
Copilot AI review requested due to automatic review settings June 21, 2026 19:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) and requires instead of std::enable_if.
  • Simplifies IndexedDataImpl::adapt() into a single constrained template using if constexpr for std::string_view handling.
  • Updates StaticRTree container-only constructor gating via a requires clause 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

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.23%. Comparing base (b9d7303) to head (e20be43).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DennisOSRM DennisOSRM merged commit 874ded3 into master Jun 22, 2026
25 checks passed
@DennisOSRM DennisOSRM deleted the sfinae-concepts-util-headers branch June 22, 2026 07:09
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.

SFINAE -> Concepts: Migrate util/* SFINAE to concepts

2 participants