mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Fix returning buffers from std::visit
Last time I tried it references somehow didn't work.
This commit is contained in:
@@ -165,11 +165,11 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket,
|
||||
}
|
||||
|
||||
void* data = std::visit(
|
||||
overload{[&](std::nullptr_t) -> void* { return nullptr; },
|
||||
[&](std::string s) -> void* {
|
||||
overload{[&](const std::nullptr_t&) -> void* { return nullptr; },
|
||||
[&](const std::string& s) -> void* {
|
||||
return const_cast<char*>(s.c_str());
|
||||
},
|
||||
[&](std::array<char, max_string_length> buffer) -> void* {
|
||||
[&](std::array<char, max_string_length>& buffer) -> void* {
|
||||
return buffer.data();
|
||||
}},
|
||||
event.payload);
|
||||
|
||||
@@ -142,13 +142,16 @@ void Logger::log_event(bool is_dispatch,
|
||||
<< ", option = " << option << ", data = ";
|
||||
|
||||
std::visit(
|
||||
overload{[&](std::nullptr_t) { message << "<nullptr>"; },
|
||||
[&](std::string s) { message << "\"" << s << "\""; },
|
||||
[&](std::array<char, max_string_length>) {
|
||||
message << "<writeable_buffer>";
|
||||
}},
|
||||
overload{
|
||||
[&](const std::nullptr_t&) { message << "<nullptr>"; },
|
||||
[&](const std::string& s) { message << "\"" << s << "\""; },
|
||||
[&](const std::array<char, max_string_length>&) {
|
||||
message << "<writeable_buffer>";
|
||||
}},
|
||||
payload);
|
||||
|
||||
message << ")";
|
||||
|
||||
log(message.str());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user