问题
[temp.concept]/5 says:
A concept is not instantiated ([temp.spec]). [ Note: An id-expression that denotes a concept specialization is evaluated as an expression ([expr.prim.id]). [...]]
Does it mean that this rule bellow ([temp.point]/8) does not apply?
If two different points of instantiation give a template specialization different meanings according to the one-definition rule, the program is ill-formed, no diagnostic required.
For example if this rule does not apply, this code bellow is well formed:
template<class T>
concept Complete = sizeof(T)==sizeof(T);
struct A;
constexpr inline bool b1 = Complete<A>; //Complete<A>==false;
struct A{};
constexpr inline bool b2 = Complete<A>; //Complete<A>==true;
This question is followed by this one
回答1:
Can a concept evaluation depend on where it is evaluated?
Yes. This was explicitly discussed during core wording review when merging Concepts into the working draft. The concept is re-evaluated every time.
As a result, this:
template<class T>
concept Complete = sizeof(T) == sizeof(T);
struct A;
static_assert(!Complete<A>);
struct A {};
static_assert(Complete<A>);
is well-formed. In other words, we don't "memoize" concepts in the same way we "memoize" template instantiations.
来源:https://stackoverflow.com/questions/53260099/can-a-concept-evaluation-depend-on-where-it-is-evaluated