Quantcast
Channel: clean C++ granular friend equivalent? (Answer: Attorney-Client Idiom) - Stack Overflow
Browsing latest articles
Browse All 7 View Live

Answer by David Stone for clean C++ granular friend equivalent? (Answer:...

I have written a minor improvement to the solution given by Matthieu M. The limitation of his solution is that you can only grant access to a single class. What if I want to let any one of three...

View Article



Answer by Heathen for clean C++ granular friend equivalent? (Answer:...

I know this is an old question, but the problem is still relevant. While I like the idea of the Attorney-Client idiom, I wanted a transparent interface for client classes that had been granted private...

View Article

Answer by Matthieu M. for clean C++ granular friend equivalent? (Answer:...

There is a very simple pattern, which has retro-actively been dubbed PassKey, and which is very easy in C++11:template <typename T>class Key { friend T; Key() {} Key(Key const&) {} };And with...

View Article

Answer by Haspemulator for clean C++ granular friend equivalent? (Answer:...

You can use a pattern described in Jeff Aldger's book'C++ for real programmers'. It has no special name but there it is referred as 'gemstones and facets'. The basic idea is as following: among your...

View Article

Answer by Drew Hall for clean C++ granular friend equivalent? (Answer:...

The Attorney-Client idiom may be what you're looking for. The mechanics are not too different from your member proxy class solution, but this way is more idiomatic.

View Article


Answer by Staffan for clean C++ granular friend equivalent? (Answer:...

Something akin to the code below will allow you fine-grained control over which parts of your private state you make public through the friend keyword.class X { class SomewhatPrivate { friend class...

View Article

clean C++ granular friend equivalent? (Answer: Attorney-Client Idiom)

Why does C++ have public members that anyone can call and friend declarations that expose allprivate members to given foreign classes or methods but offer no syntax to expose particular members to...

View Article
Browsing latest articles
Browse All 7 View Live




Latest Images