using onSnap = stdfunctionvoidbool success const stdstring &err_msg;
This line of code declares a variable named onSnap of type std::function. The std::function is a general-purpose polymorphic function wrapper that can hold and invoke any callable target (e.g., function pointers, lambda expressions, member function pointers).
The std::function type is templated with the signature of the callable target it will hold. In this case, the signature is void(bool success, const std::string &err_msg). This means that the onSnap variable can hold any callable target that takes two arguments: a bool named success and a const std::string& named err_msg, and returns void.
The purpose of this variable is to store a callback function that can be executed when a certain event occurs. The callback function will be called with two arguments: a bool indicating the success of the event and a const std::string& containing an error message if the event was not successful
原文地址: http://www.cveoy.top/t/topic/iiay 著作权归作者所有。请勿转载和采集!