The standard library provides many useful "is" typetraits that tell about the relationship of two classes, such as is_base_of
, is_convertible
, is_same
, etc. Is there any way to implement a typetrait is_friend
to tell whether class A is a friend of class B?
Sample code:
class A {};
class B { friend class A; };
class C { friend class B; };
is_friend<A, B>; // true
is_friend<B, A>; // false
is_friend<B, C>; // true
is_friend<A, C>; // false