// { dg-do compile { target c++20 } } // { dg-additional-options "-fconcepts" } #include inline constexpr bool and_impl() { return true; } template constexpr bool and_impl(OperandFirst operand_first, OperandsRest... operands_rest) { return operand_first && and_impl(operands_rest...); } template constexpr bool and_(Operands... operands) { return and_impl(operands...); } template concept C = true; // v1 template requires (and_(C...)) constexpr int f(const Xs&... xs) { return 0; } // v2 template constexpr int f(const Xs&... xs) { return 1; } int main() { static_assert(f<10>(3.0, 2.0f) == 0); return 0; } // 2nd example template concept AreType = (std::is_same::value && ...); // return true; gives the same overloaded error // Function with constraint template... Us> constexpr bool isValid(Us... us) { return true; } // Function with no constraint template constexpr bool isValid(U... u) { return false; } int main2() { static_assert(isValid(1)); // also isValid(1, 2, 3); etc return 0; }