Boost logo

Boost :

Subject: Re: [boost] [introspection] if a function is not public
From: Edward Diener (eldiener_at_[hidden])
Date: 2011-06-30 18:53:34

On 6/29/2011 8:02 PM, Lorenzo Caminiti wrote:
> Hello all,
> Is there any way (SFINAE, etc) to check at run-time or at compile-time
> if a member function is not public?
> class x {
> public:
> void f ( ) {};
> protected:
> void g ( ) {};
> private:
> void h ( ) {};
> bool is_public(...) { ... } // some implementation
> void check ( ) {
> std::cout<< is_public(x::f)<< std::endl; // 1
> std::cout<< is_public(x::g)<< std::endl; // 0
> std::cout<< is_public(x::h)<< std::endl; // 0
> }
> };
> Thanks a lot!
> --Lorenzo
> _______________________________________________
> Unsubscribe& other changes:

This is off the top of my head but...

It might be possible by declaring a friend class which does the
introspection ala my TTI generated classes. If the friend class can find
the function but a non-friend class can not find the function, then one
knows that the function is not public. Similarly if one could have an
introspection class derived from the actual class being introspected and
find the function while not finding it otherwise, one knows it is a
protected function. Whether either of these things can actually be done
by TTI I would have to take a much closer look at eventually. Of course
in any case one would have to know that the actual function exists in
the class else not finding the function in any situation could mean it
does not exist at all.

I know that Joel Falcou, who is the Review Manager for my TTI libary,
played around with 'friend' in introspecting class data, but I never
followed up looking at his idea when doing TTI. Your query gives me
something to think about for TTI, although I think the actual usefulness
might be pretty small even if it could be done even if you have found a
use for it.

BTW the review of TTI begins tomorrow, and any relevant idea is welcome
even if I choose to not actually try to implement it ( it may also be
impossible ).

Boost list run by bdawes at, gregod at, cpdaniel at, john at