In which access control context are evaluated concepts?

♀尐吖头ヾ 提交于 2019-12-01 16:17:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!