#include <iostream>
struct Obj
{
Obj* GetChild() const { return nullptr; }
};
template <typename F>
void DoWork(Obj* obj, int num, F&& func)
{
func(obj->GetChild());
}
void foo(Obj*) { }
void bar(const Obj*) { }
int main()
{
Obj obj;
DoWork(&obj, 42, &foo);
DoWork(&obj, 42, &bar);
DoWork(&obj, 555, [](const Obj* o){ std::cout << o << std::endl; });
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IE9iagp7CglPYmoqIEdldENoaWxkKCkgY29uc3QgeyByZXR1cm4gbnVsbHB0cjsgfQp9OwoKdGVtcGxhdGUgPHR5cGVuYW1lIEY+CnZvaWQgRG9Xb3JrKE9iaiogb2JqLCBpbnQgbnVtLCBGJiYgZnVuYykKewogICAgZnVuYyhvYmotPkdldENoaWxkKCkpOwp9Cgp2b2lkIGZvbyhPYmoqKSB7IH0Kdm9pZCBiYXIoY29uc3QgT2JqKikgeyB9CgppbnQgbWFpbigpCnsKCU9iaiBvYmo7CglEb1dvcmsoJm9iaiwgNDIsICZmb28pOwoJRG9Xb3JrKCZvYmosIDQyLCAmYmFyKTsKCURvV29yaygmb2JqLCA1NTUsIFtdKGNvbnN0IE9iaiogbyl7IHN0ZDo6Y291dCA8PCBvIDw8IHN0ZDo6ZW5kbDsgfSk7Cn0=