
On 11/25/2011 06:44 PM, Lorenzo Caminiti wrote:
On the contrary such a feature is not supported by the Phoenix solution *AFAIK* precisely because the functor is not local to the outer class (whereas the Local functor is local to the enclosing member function and therefore to the outer class). For example:
#include<boost/phoenix/core.hpp> #include<boost/phoenix/function.hpp> #include<iostream>
namespace impl { template<typename This> void f(This this_) { this_->publ(); // this_->prot(); // error :( // this_->priv(); // error :( } }
BOOST_PHOENIX_ADAPT_FUNCTION(void, globalf, impl::f, 1)
struct x { void f() { globalf(this)(); }
public: void publ() { std::cout<< "public"<< std::endl; } protected: void prot() { std::cout<< "protected"<< std::endl; } private: void priv() { std::cout<< "private"<< std::endl; } };
int main ( ) { x xx; xx.f(); return 0; }
DISCLAIMER: I apologize in advance if there's a way to do access priv and prot from the Phoenix global functor which I was not able to find. I'm sure Phoenix experts will be able to correct my example if such a possibility exists :)
It's not possible with Phoenix, though I believe there are hacks to make it possible somewhat. In any case I don't think this is even Phoenix code. There is no real phoenix expression involved, it's just a function being adapted into a function object.