template<typename T> concept R = requires (T i) { typename T::type; {*i} -> std::convertible_to<const typename T::type&>; };
template<typename T> requires requires (T x) { x + x; } T add(T a, T b) { return a + b; }
template<typename T> concept C = requires(T t, ...) { // error: terminates with an ellipsis t; };— end example
template<typename T> concept C = requires { new int[-(int)sizeof(T)]; // ill-formed, no diagnostic required };— end example
template<typename T> concept C = requires (T a, T b) { a + b; // C<T> is true if a + b is a valid expression };— end example
template<typename T, typename T::type = 0> struct S; template<typename T> using Ref = T&; template<typename T> concept C = requires { typename T::inner; // required nested member name typename S<T>; // required class template specialization typename Ref<T>; // required alias template substitution, fails if T is void };— end example
requires { { E1 } -> C; { E2 } -> D<A, ⋯, A>; };is equivalent to
requires { E1; requires C<decltype((E1))>; E2; requires D<decltype((E2)), A, ⋯, A>; };(including in the case where n is zero). — end example
template<typename T> concept C1 = requires(T x) { {x++}; };
template<typename T> concept C2 = requires(T x) { {*x} -> std::same_as<typename T::inner>; };
template<typename T> concept C3 = requires(T x) { {g(x)} noexcept; };
template<typename U> concept C = sizeof(U) == 1; template<typename T> concept D = requires (T t) { requires C<decltype (+t)>; };D<T> is satisfied if sizeof(decltype (+t)) == 1 ([temp.constr.atomic]).
template<typename T> concept C = requires (T a) { requires sizeof(a) == 4; // OK requires a == 0; // error: evaluation of a constraint variable };— end example