Replace SFINAE with C++20's Concepts and Constraints
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
C++20 includes features that allow clearer ways to constrain template instantiations, compared to SFINAE.
Concepts and constraints can replace SFINAE in two ways:
1. Constrained function template - a set of concepts can be declared (e.g. `concept Duration = is_duration();`) and used in template functions' declaration.
2. `requires` clauses - these map 1:1 to current SFINAE conditions, so replacement is straightforward.
Proposed course of action:
- [ ] Declare basic concepts (e.g. [Duration](https://github.com/rapidsai/cudf/pull/19512)) and apply where possible.
- [ ] Review remaining SFINAE/requires clauses, declare more concepts if more common patterns are identified.
- [ ] Convert remaining SFINAE into `requires` clauses, mechanical at this point.
- [ ] Turn on the [clang-tidy check](https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-constraints.html) to enforce constraints use.
Currently the first step is blocked on Doxygen, as the current version (1.9.1) does not support concepts, so they can't be declared in public headers. An upgrade to 1.9.8 has been proposed to unblock this issue.
Contributor guide
Assessment
This issue has not been assessed yet.