I'm reading Josuttis' C++20 the Complete Guide, and I think I've absorbed that a clause like the one in the template below
template<typename T>
requires requires { typename std::remove_const_t<T>; }
…
is completely useless as it resolves to requires true because remove_const_t always returns a type when given a type.
However, I reasoned, that's not the case, for instance, for enable_if, so I came up with
requires { typename std::enable_if_t<std::is_integral_v<T>>; }
Now, since the requires expression simply checks that the requirements in the {…} are well-formed, I think that's basically what the following does
std::is_integral_v<T>
It seems pretty uncontroversial to me, but I'm asking because I'm new to C++ concepts and it is perfectly possible that I'm making a mistake.
The two expressions have the same effect as, in this case, the
requiresis a boolean expression itself.Specifically, the first expression works as
std::enable_ifis implemented in the following way:When the
fun_v<T>is true, the template partial-specialization is used, and the requires-expression is satisfied, since it simply verifies whethertypeis well-formed. Likewise, when thefun_v<T>is false, the first template is used, and the requires-expression is not satisfied, sincetypeis not well-formed.