#include <iostream>
#include <thread>
class Bar
{
public:
void foo(int a)
{
std::cout << a << '\n';
}
};
int main()
{
Bar bar;
// Create and execute the thread
std::thread thread{ &Bar::foo, &bar, 10 }; // Pass 10 to member function
// The member function will be executed in a separate thread
// Wait for the thread to finish, this is a blocking operation
thread.join();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dGhyZWFkPgogCmNsYXNzIEJhcgp7CnB1YmxpYzoKICAgIHZvaWQgZm9vKGludCBhKQogICAgewogICAgICAgIHN0ZDo6Y291dCA8PCBhIDw8ICdcbic7CiAgICB9Cn07CiAKaW50IG1haW4oKQp7CiAgICBCYXIgYmFyOwogICAgCiAgICAvLyBDcmVhdGUgYW5kIGV4ZWN1dGUgdGhlIHRocmVhZAogICAgc3RkOjp0aHJlYWQgdGhyZWFkeyAmQmFyOjpmb28sICZiYXIsIDEwIH07IC8vIFBhc3MgMTAgdG8gbWVtYmVyIGZ1bmN0aW9uCiAKICAgIC8vIFRoZSBtZW1iZXIgZnVuY3Rpb24gd2lsbCBiZSBleGVjdXRlZCBpbiBhIHNlcGFyYXRlIHRocmVhZAogCiAgICAvLyBXYWl0IGZvciB0aGUgdGhyZWFkIHRvIGZpbmlzaCwgdGhpcyBpcyBhIGJsb2NraW5nIG9wZXJhdGlvbgogICAgdGhyZWFkLmpvaW4oKTsKIAogICAgcmV0dXJuIDA7Cn0=