This is more of an intellectual curiosity than a real problem. I was wondering if there is a way in C ++ to do the following: let Abe a class. I want to create a Bfriend class with all classes inheriting from A.
Before you say this: I obviously know that friendship is not inherited. I would like to make an expression template friend, possibly using SFINAE, to a friend Bwith each class Cto Cinherit from A.
Is this possible? I tried to start with the simplest case: can you make a cool friend with all the other classes? Obviously, I know that this makes no sense, you can just make something publicly available, but maybe from this starting point you can improve to select only those classes that inherit from A.
source
share