Hi folks,

I've stumbled over a problem I cannot properly solve on my own. Usually I like to use helper functions in anonymous namespaces in order to keep class constructor/method implementations clean:

Code:
namespace {
    int calculate(int a, int b);
}

void data::process()
{
    ...
    auto result=calculate(a, b);
    ...
}
Now I have a base class that needs to be initialized with a callback function:

Code:
class base {
public:
    base(std::function<void (int, int)> callback);
};

class child: public base {
private:
    void method(bool, int);
    void method(bool, std::string);
};
The problem here is that I need to initialize the base class with a callback that uses the child::method member functions, which are number of private overloads.

Now implementing the child constructor like this:

Code:
child::child()
    : base([](auto a, auto b) {
        ...
        method(condition, parameter); // this works
        ...
    })
{}
works (the point being that child::method is accessible) but is quite ugly. The following obviously doesn't work, because 'child::method is private within this context':

Code:
namespace {
    std::function<void (int, int)> create(child& instance)
    {
         ...
         instance.method(condition, parameter); // this fails
         ...
    }
}

child::child()
    : base(create(*this))
{}
Is there any way for the 'create' function to access class internals just as the lambda does, without being a member function of the class (I'd like to keep the public interface clean)?

I'd really like to avoid the lambda option because in my particular case this callback is rather complex and requires a lot of code.
Thanks for any suggestions!