How do I use concepts in if-constexpr?
Concepts are named boolean predicates on template parameters, evaluated at compile time.
In a constexpr if
statement, the value of the condition must be a contextually converted constant expression of type bool
.
So in this case, usage is simple:
if constexpr ( integral<T> )
It is sufficient to do:
if constexpr ( integral<T> )
since integral<T>
is already testable as bool