Replace std::monostate with std::nullptr_t

This represents the underlying meaning better since we're mostly dealing
with the `data` void pointer argument.
This commit is contained in:
Robbert van der Helm
2020-04-19 16:02:01 +02:00
parent 717ffb719d
commit 9f3ed85208
4 changed files with 7 additions and 10 deletions
+3 -3
View File
@@ -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 // because it was not zeroed out by the host) for an event that should
// report some data back? // report some data back?
const auto response_data = std::visit( const auto response_data = std::visit(
overload{[&](auto) -> EventResposnePayload { return std::monostate(); }, overload{[&](auto) -> EventResposnePayload { return nullptr; },
[&](const AEffect& updated_plugin) -> EventResposnePayload { [&](const AEffect& updated_plugin) -> EventResposnePayload {
// This is a bit of a special case! Instead of writing some // This is a bit of a special case! Instead of writing some
// return value, we will update values on the native VST // 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->uniqueID = updated_plugin.uniqueID;
plugin->version = updated_plugin.version; plugin->version = updated_plugin.version;
return std::monostate(); return nullptr;
}, },
[&](WantsChunkBuffer&) -> EventResposnePayload { [&](WantsChunkBuffer&) -> EventResposnePayload {
// In this case the plugin will have written its data // 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 = const auto time_info =
reinterpret_cast<const VstTimeInfo*>(return_value); reinterpret_cast<const VstTimeInfo*>(return_value);
if (time_info == nullptr) { if (time_info == nullptr) {
return std::monostate{}; return nullptr;
} else { } else {
return *time_info; return *time_info;
} }
+1 -1
View File
@@ -204,7 +204,7 @@ void Logger::log_event_response(bool is_dispatch,
std::visit( std::visit(
overload{ overload{
[&](const std::monostate&) {}, [&](const std::nullptr_t&) {},
[&](const std::string& s) { [&](const std::string& s) {
if (s.size() < 32) { if (s.size() < 32) {
message << ", \"" << s << "\""; message << ", \"" << s << "\"";
+2 -5
View File
@@ -295,11 +295,8 @@ struct Event {
* - A specific struct in response to an event such as `audioMasterGetTime` or * - A specific struct in response to an event such as `audioMasterGetTime` or
* `audioMasterIOChanged`. * `audioMasterIOChanged`.
* - An X11 window pointer for the editor window. * - 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<std::monostate, using EventResposnePayload = std::variant<std::nullptr_t,
std::string, std::string,
AEffect, AEffect,
VstIOProperties, VstIOProperties,
@@ -310,7 +307,7 @@ template <typename S>
void serialize(S& s, EventResposnePayload& payload) { void serialize(S& s, EventResposnePayload& payload) {
s.ext(payload, s.ext(payload,
bitsery::ext::StdVariant{ bitsery::ext::StdVariant{
[](S&, std::monostate&) {}, [](S&, std::nullptr_t&) {},
[](S& s, std::string& string) { [](S& s, std::string& string) {
// `binary_buffer_size` and not `max_string_length` // `binary_buffer_size` and not `max_string_length`
// because we also use this to send back large chunk // because we also use this to send back large chunk
+1 -1
View File
@@ -302,7 +302,7 @@ class HostCallbackDataConverter : DefaultDataConverter {
// Depending on whether the host supported the requested time // Depending on whether the host supported the requested time
// information this operations returns either a null pointer or // information this operations returns either a null pointer or
// a pointer to a `VstTimeInfo` object. // a pointer to a `VstTimeInfo` object.
if (std::holds_alternative<std::monostate>(response.payload)) { if (std::holds_alternative<std::nullptr_t>(response.payload)) {
time_info = std::nullopt; time_info = std::nullopt;
} else { } else {
time_info = std::get<VstTimeInfo>(response.payload); time_info = std::get<VstTimeInfo>(response.payload);