From 9f3ed8520823e89e1ead1a9ced617ff003ad40a4 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 19 Apr 2020 16:02:01 +0200 Subject: [PATCH] Replace std::monostate with std::nullptr_t This represents the underlying meaning better since we're mostly dealing with the `data` void pointer argument. --- src/common/events.h | 6 +++--- src/common/logging.cpp | 2 +- src/common/serialization.h | 7 ++----- src/wine-host/plugin-bridge.cpp | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/common/events.h b/src/common/events.h index ae414c9d..2293350d 100644 --- a/src/common/events.h +++ b/src/common/events.h @@ -236,7 +236,7 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket, // because it was not zeroed out by the host) for an event that should // report some data back? const auto response_data = std::visit( - overload{[&](auto) -> EventResposnePayload { return std::monostate(); }, + overload{[&](auto) -> EventResposnePayload { return nullptr; }, [&](const AEffect& updated_plugin) -> EventResposnePayload { // This is a bit of a special case! Instead of writing some // return value, we will update values on the native VST @@ -261,7 +261,7 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket, plugin->uniqueID = updated_plugin.uniqueID; plugin->version = updated_plugin.version; - return std::monostate(); + return nullptr; }, [&](WantsChunkBuffer&) -> EventResposnePayload { // In this case the plugin will have written its data @@ -290,7 +290,7 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket, const auto time_info = reinterpret_cast(return_value); if (time_info == nullptr) { - return std::monostate{}; + return nullptr; } else { return *time_info; } diff --git a/src/common/logging.cpp b/src/common/logging.cpp index 554cc9c2..ad547832 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -204,7 +204,7 @@ void Logger::log_event_response(bool is_dispatch, std::visit( overload{ - [&](const std::monostate&) {}, + [&](const std::nullptr_t&) {}, [&](const std::string& s) { if (s.size() < 32) { message << ", \"" << s << "\""; diff --git a/src/common/serialization.h b/src/common/serialization.h index e4d05d39..47b29274 100644 --- a/src/common/serialization.h +++ b/src/common/serialization.h @@ -295,11 +295,8 @@ struct Event { * - A specific struct in response to an event such as `audioMasterGetTime` or * `audioMasterIOChanged`. * - An X11 window pointer for the editor window. - * - * TODO: Replace `std::monostate` with `std::nullptr_t` as it's more expressive - * in what it actually represents. */ -using EventResposnePayload = std::variant void serialize(S& s, EventResposnePayload& payload) { s.ext(payload, bitsery::ext::StdVariant{ - [](S&, std::monostate&) {}, + [](S&, std::nullptr_t&) {}, [](S& s, std::string& string) { // `binary_buffer_size` and not `max_string_length` // because we also use this to send back large chunk diff --git a/src/wine-host/plugin-bridge.cpp b/src/wine-host/plugin-bridge.cpp index 36e9a195..daeb3b47 100644 --- a/src/wine-host/plugin-bridge.cpp +++ b/src/wine-host/plugin-bridge.cpp @@ -302,7 +302,7 @@ class HostCallbackDataConverter : DefaultDataConverter { // Depending on whether the host supported the requested time // information this operations returns either a null pointer or // a pointer to a `VstTimeInfo` object. - if (std::holds_alternative(response.payload)) { + if (std::holds_alternative(response.payload)) { time_info = std::nullopt; } else { time_info = std::get(response.payload);