Do any OO languages have a concept of granular compile-time access-control lists beyond public/private/protected?
Every so often when doing a class hierarchy design, I find myself in a situation where I want class A to be able to call method X of class B, but X is considered somewhat internal and not part of the public API of B.
My options are to make X public (implying it's part of the public API) or protected/private and then make A a friend (giving it access to all of the internals of B).
There's no way to say "expose these 3 methods to this other class, but they're not for public consumption)
My first thought for how to do this ins C++ is to make X take one extra argument, a reference/instance of some kind of special nested class that's private to A.
Thus, only A can create an instance of the class (which need not have any members, I think if it's empty the argument will get optimized out at compile time) and thus call the method.
Ugly, but is there a better option?