Closed L-Super closed 1 year ago
You need to explicitly cast to std::string_view in the call to the constructor. Or you could just use std::string_view instead of const char* in the first place.
I want to use it as a template function. How can I improve it?
template <typename String>
std::string send(String str)
{
//....
zmq::message_t m{str};
socket.send(m, zmq::send_flags::none);
//....
}
int main()
{
//...
send("hello");
}
Maybe just
std::string send(std::string_view str)
{
...
}
When I use the following code, I encounter an error
It seems that
const string&
andstring_view
are in conflict.