fork download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. class Socket
  5. {
  6. public:
  7. void recv(const std::function<void(const std::string&)>& func) {}
  8. };
  9.  
  10. class Client
  11. {
  12. public:
  13. void handshake() {}
  14. };
  15.  
  16. int main()
  17. {
  18. Socket sock;
  19. Client client;
  20. sock.recv([&client](std::string data)
  21. {
  22. client.handshake();
  23. });
  24. }
  25.  
Success #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty