if constexpr requires requires { requires }
Probably the two most useful features added to C++20 are requires
and requires
.
They make it so much easier to control overload resolution, and when combined with if constexpr
in C++17, they allow basic reflection-based optimizations in templates.
While requires requires
has gotten a lot of (negative?!) press for controlling overload resolution, its cousin requires { requires }
is a bit overlooked.
…
Read this blog post at think-cell's developer blog. Subscribe there to stay up-to-date!