I found that some CppCon speakers used and
instead of &&
to define concepts and used &&
in "normal" boolean expressions, but I can't figure out the benefits of doing so.
The only material about naming convensions of concepts that I can found is P1851: Guidelines For snake_case Concept Naming, but it says nothing about this.
Can anyone tell me why?
Example:
template <typename T>
concept boolean_testable
= std::convertible_to<T, bool>
and requires(T&& t) {
{ !std::forward<T>(t) } -> std::convertible_to<bool>;
};
Instead of:
template <typename T>
concept boolean_testable
= std::convertible_to<T, bool>
&& requires(T&& t) {
{ !std::forward<T>(t) } -> std::convertible_to<bool>;
};
Although the complete substitutability between &&
and and
caught my eye, I still can't figure out why some programmers deliberately choose to use and
only when defining concepts. I noticed they still used &&
in other context (boolean expressions, T&&
...). I can't figure out the benefits they got from such style.
I'm not asking for the difference between and
and &&
but the motivation of using and
instead of &&
only when in concept definition. There's no duplicate question as far as I know.