How does one use concepts in if constexpr
?
Given the example below, what would one give to if constexpr
to return 1 in case T
meets the requirements of integral
and else 0?
template<typename T>
concept integral = std::is_integral_v<T>;
struct X{};
template<typename T>
constexpr auto a () {
if constexpr (/* T is integral */) {
return 1;
}
else {
return 0;
}
}
int main () {
return a<X>();
}