|
Boost : |
Subject: Re: [boost] [local] Any "active Boost library author" in favor of Boost.Local?
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2011-11-25 12:18:46
On Fri, Nov 25, 2011 at 11:06 AM, Vicente Botet
<vicente.botet_at_[hidden]> wrote:
> I think that most of us would admit that local functions are useful, but as
> discussed during the review, Boost.Local doesn't provides local functions.
> The missing features been:
> * implicit access to the accessible variables
Yes, in the example below you explicitly have to say "bind this".
> * access to the non public functions of the embedding class (in case of a
> local function of a member function).
Can you explain this point better? This example shows that you can
access public, protected, and private members of a bound object (from
within a member of the same class):
#include <boost/local/function.hpp>
#include <iostream>
struct x {
void f() {
void BOOST_LOCAL_FUNCTION_PARAMS(bind this) {
this_->priv();
this_->prot();
this_->publ();
} BOOST_LOCAL_FUNCTION_NAME(l)
l();
}
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;
}
Thanks a lot for the clarification.
--Lorenzo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk