#include <iostream>
#include <functional>
class Foo
{
public:
Foo() = default;
~Foo() = default;
void write(std::string message, const std::function<void()>& callback) { /* Do something with callback */ }
private:
};
class Bar
{
public:
Bar() = default;
~Bar() = default;
void callback(){ /* Do something */ }
void start() { foo.write("hi", &Bar::callback); }
private:
Foo foo;
};
int main(int argc, char* argv[])
{
Bar bar;
bar.start();
}
1 2 3 4 5 6 7
Undefined symbols for architecture x86_64:
"std::__1::__any::__any(...)", referenced from:
void std::__1::__invoke_void_return_wrapper<void>::__call<void (Bar::*)()>(void (Bar::*)()) in main.o
"std::__1::__invoke(std::__1::__any, ...)", referenced from:
void std::__1::__invoke_void_return_wrapper<void>::__call<void (Bar::*)()>(void (Bar::*)()) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)