问题
This question is a follow up to this one
[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]). [...]]
So maybe an expression that name a concept specialization can have different value because of accessibility.
If it were the case, I wonder in which context would be evaluated the expression:
The context of the concept definition;
The context of the expression;
The context of the expression recursively applied to concepts expression appearing in concepts definition?
For example, what could be the value for A::b2
and A::b2_rec
?
template<class T>
concept has_private = requires(){ &T::private_;};
template<class T>
concept has_private_rec = has_private<T>;
class B{
int private_;
friend class A;
};
inline constexpr bool b1 = has_private<B>;//I expects false
inline constexpr bool b1_rec = has_private_rec<B>;//I expects false
class A{
static constexpr bool b2 = has_private<B>; //?
static constexpr bool b2_rec = has_private_rec<B>; //?
};
Note Clang experimental concepts and gcc concepts TS implementation produce compilation error for b1 and b1_rec, but b2 and b2_rec are true;
来源:https://stackoverflow.com/questions/53263299/in-which-access-control-context-are-evaluated-concepts