ZeroMQ中定义的smessage()方法在哪个头文件中?

In which header file is the method smessage() defined in ZeroMQ?

下面是ZeroMQ中使用smessage方法的代码。我在 zhelpers.hpp 头文件中搜索了它的定义,但那里没有。

#include "zhelpers.hpp"
#include <string>

int main (int argc, char *argv[])
{
    //  Process tasks forever
    while (1) {

        zmq::message_t message;
        int workload;           //  Workload in msecs

        receiver.recv(&message);
        std::string smessage(static_cast<char*>(message.data()), message.size());

        std::istringstream iss(smessage);
        iss >> workload;

        //  Do the work
        s_sleep(workload);

        //  Send results to sink
        message.rebuild();
        sender.send(message);

        //  Simple progress indicator for the viewer
        std::cout << "." << std::flush;
    }
    return 0;
}
std::string smessage(static_cast<char*>(message.data()), message.size());

不是对函数的调用smessage而是调用构造函数std::string的变量的定义

basic_string( const CharT* s,
              size_type count, 
              const Allocator& alloc = Allocator() );

smessage 不是一种方法。它是一个 std::string 类型的变量,它是通过使用带指针和大小的重载构造函数创建的。

顺便说一句,你可以直接使用zmq::message_t::str()函数得到一个std::string.

例如:

zmq::message_t msg;
// read some data...
std::string smessage = msg.str();