requires 的主体是否块未评估的上下文?

Is the body of requires block unevaluated context?

概念定义的主体或 require 块是否未计算上下文?例如。我可以安全地使用 std::declval 吗?

template<typename T>
concept bool SomeConcept = requires(T a) {
    { a.someFunction(std::declval<int>()) } -> int;
};

是的。来自 [temp.constr.expr],N4641 的措辞:

An expression constraint is a constraint that specifies a requirement on the formation of an expression E through substitution of template arguments. An expression constraint is satisfied if substitution yielding E did not fail. Within an expression constraint, E is an unevaluated operand (Clause 5).

所以使用 declval 应该没问题。

或者,您可以只创建所需类型的对象,因为在需求上下文中,我们实际上并没有构建任何东西:

template<typename T>
concept bool SomeConcept = requires(T a, int i) {
    { a.someFunction(std::move(i)) } -> int;
};