From 4f6281e52d3183ae53510d59474f6e4708da40c3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 22 Aug 2022 13:06:56 -0400 Subject: Replace boost with standard C++17 facilities --- .clant.json | 4 +--- NEWS | 3 ++- meson/suppressions/meson.build | 6 ------ src/Action.hpp | 34 +++++++++++++++++----------------- src/AlsaDriver.cpp | 3 +-- src/Canvas.cpp | 2 +- src/CanvasPort.hpp | 40 ++++++++++++++++++++-------------------- src/Configuration.hpp | 11 +++++------ src/Event.hpp | 20 ++++++++++---------- src/JackLibDriver.cpp | 6 +++--- src/Metadata.cpp | 7 +++---- src/Metadata.hpp | 7 +++---- src/Patchage.cpp | 7 +++---- src/PortInfo.hpp | 12 ++++++------ src/Reactor.cpp | 8 +++----- src/Reactor.hpp | 2 -- src/Setting.hpp | 29 ++++++++++++++--------------- src/event_to_string.cpp | 9 +++------ src/handle_event.cpp | 6 ++---- 19 files changed, 97 insertions(+), 119 deletions(-) diff --git a/.clant.json b/.clant.json index d178369..23d71fd 100644 --- a/.clant.json +++ b/.clant.json @@ -1,8 +1,6 @@ { "version": "1.0.0", "mapping_files": [ - ".includes.imp", - "boost-1.64-all-private.imp", - "boost-1.64-all.imp" + ".includes.imp" ] } diff --git a/NEWS b/NEWS index 4166bee..7cb305f 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,9 @@ patchage (1.0.9) unstable; urgency=medium + * Replace boost with standard C++17 facilities * Upgrade to fmt 9.0.0 - -- David Robillard Tue, 16 Aug 2022 20:36:01 +0000 + -- David Robillard Mon, 22 Aug 2022 17:07:17 +0000 patchage (1.0.8) stable; urgency=medium diff --git a/meson/suppressions/meson.build b/meson/suppressions/meson.build index ea5d66e..99cb3b7 100644 --- a/meson/suppressions/meson.build +++ b/meson/suppressions/meson.build @@ -34,12 +34,6 @@ if is_variable('cpp') cpp_suppressions += [ '-Wno-documentation', # JACK '-Wno-documentation-deprecated-sync', # JACK - '-Wno-documentation-unknown-command', # boost - '-Wno-global-constructors', # boost - '-Wno-old-style-cast', # boost - '-Wno-redundant-parens', # boost - '-Wno-reserved-id-macro', # boost - '-Wno-zero-as-null-pointer-constant', # boost ] endif diff --git a/src/Action.hpp b/src/Action.hpp index 688a73c..c791445 100644 --- a/src/Action.hpp +++ b/src/Action.hpp @@ -9,7 +9,7 @@ #include "Setting.hpp" #include "SignalDirection.hpp" -#include +#include namespace patchage { namespace action { @@ -68,22 +68,22 @@ struct ZoomOut {}; } // namespace action /// A high-level action from the user -using Action = boost::variant; +using Action = std::variant; } // namespace patchage diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index ee52aed..83a0a48 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -22,13 +22,12 @@ PATCHAGE_RESTORE_WARNINGS #include #include -#include - #include #include #include #include #include +#include #include #include #include diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 574bb33..6dfad50 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -34,7 +34,6 @@ PATCHAGE_DISABLE_FMT_WARNINGS #include PATCHAGE_RESTORE_WARNINGS -#include #include #include #include @@ -42,6 +41,7 @@ PATCHAGE_RESTORE_WARNINGS #include #include #include +#include #include #include #include diff --git a/src/CanvasPort.hpp b/src/CanvasPort.hpp index 594fdfb..548c9e5 100644 --- a/src/CanvasPort.hpp +++ b/src/CanvasPort.hpp @@ -12,7 +12,6 @@ PATCHAGE_DISABLE_GANV_WARNINGS #include "ganv/Port.hpp" PATCHAGE_RESTORE_WARNINGS -#include #include #include #include @@ -22,6 +21,7 @@ PATCHAGE_RESTORE_WARNINGS #include #include +#include #include #include @@ -35,15 +35,15 @@ namespace patchage { class CanvasPort : public Ganv::Port { public: - CanvasPort(Ganv::Module& module, - PortType type, - PortID id, - const std::string& name, - const std::string& human_name, - bool is_input, - uint32_t color, - bool show_human_name, - boost::optional order = boost::optional()) + CanvasPort(Ganv::Module& module, + PortType type, + PortID id, + const std::string& name, + const std::string& human_name, + bool is_input, + uint32_t color, + bool show_human_name, + std::optional order = std::optional()) : Port(module, (show_human_name && !human_name.empty()) ? human_name : name, is_input, @@ -88,18 +88,18 @@ public: return true; } - PortType type() const { return _type; } - PortID id() const { return _id; } - const std::string& name() const { return _name; } - const std::string& human_name() const { return _human_name; } - const boost::optional& order() const { return _order; } + PortType type() const { return _type; } + PortID id() const { return _id; } + const std::string& name() const { return _name; } + const std::string& human_name() const { return _human_name; } + const std::optional& order() const { return _order; } private: - PortType _type; - PortID _id; - std::string _name; - std::string _human_name; - boost::optional _order; + PortType _type; + PortID _id; + std::string _name; + std::string _human_name; + std::optional _order; }; } // namespace patchage diff --git a/src/Configuration.hpp b/src/Configuration.hpp index 641d2b7..7837cd0 100644 --- a/src/Configuration.hpp +++ b/src/Configuration.hpp @@ -9,11 +9,10 @@ #include "Setting.hpp" #include "SignalDirection.hpp" -#include - #include #include #include +#include #include #include @@ -113,10 +112,10 @@ private: : split(s) {} - boost::optional input_location; - boost::optional output_location; - boost::optional inout_location; - bool split; + std::optional input_location; + std::optional output_location; + std::optional inout_location; + bool split; }; std::map _module_settings; diff --git a/src/Event.hpp b/src/Event.hpp index 0ad6b44..36166e7 100644 --- a/src/Event.hpp +++ b/src/Event.hpp @@ -10,7 +10,7 @@ #include "PortID.hpp" #include "PortInfo.hpp" -#include +#include namespace patchage { namespace event { @@ -56,15 +56,15 @@ struct PortsDisconnected { } // namespace event /// An event from drivers that represents a change to the system -using Event = boost::variant; +using Event = std::variant; } // namespace patchage diff --git a/src/JackLibDriver.cpp b/src/JackLibDriver.cpp index b519d7b..2813a92 100644 --- a/src/JackLibDriver.cpp +++ b/src/JackLibDriver.cpp @@ -26,7 +26,6 @@ PATCHAGE_DISABLE_FMT_WARNINGS #include PATCHAGE_RESTORE_WARNINGS -#include #include #include @@ -35,6 +34,7 @@ PATCHAGE_RESTORE_WARNINGS #include #include #include +#include #include #include #include @@ -230,8 +230,8 @@ JackLibDriver::get_port_info(const jack_port_t* const port) : SignalDirection::output); // Get port order from metadata if possible - boost::optional order; - const std::string order_str = get_property(uuid, JACKEY_ORDER); + std::optional order; + const std::string order_str = get_property(uuid, JACKEY_ORDER); if (!order_str.empty()) { order = std::stoi(order_str); } diff --git a/src/Metadata.cpp b/src/Metadata.cpp index aa60582..929b090 100644 --- a/src/Metadata.cpp +++ b/src/Metadata.cpp @@ -8,13 +8,12 @@ #include "PortID.hpp" #include "PortInfo.hpp" -#include - +#include #include namespace patchage { -boost::optional +std::optional Metadata::client(const ClientID& id) const { const auto i = _client_data.find(id); @@ -25,7 +24,7 @@ Metadata::client(const ClientID& id) const return i->second; } -boost::optional +std::optional Metadata::port(const PortID& id) const { const auto i = _port_data.find(id); diff --git a/src/Metadata.hpp b/src/Metadata.hpp index 15d9672..520b0ce 100644 --- a/src/Metadata.hpp +++ b/src/Metadata.hpp @@ -9,9 +9,8 @@ #include "PortID.hpp" #include "PortInfo.hpp" -#include - #include +#include namespace patchage { @@ -21,8 +20,8 @@ class Metadata public: Metadata() = default; - boost::optional client(const ClientID& id) const; - boost::optional port(const PortID& id) const; + std::optional client(const ClientID& id) const; + std::optional port(const PortID& id) const; void set_client(const ClientID& id, const ClientInfo& info); void set_port(const PortID& id, const PortInfo& info); diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 96af631..1f3d706 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -39,9 +39,6 @@ PATCHAGE_DISABLE_FMT_WARNINGS #include PATCHAGE_RESTORE_WARNINGS -#include -#include -#include #include #include #include @@ -95,7 +92,9 @@ PATCHAGE_RESTORE_WARNINGS #include #include #include +#include #include +#include #ifdef PATCHAGE_GTK_OSX @@ -769,7 +768,7 @@ Patchage::process_events() void Patchage::on_conf_change(const Setting& setting) { - boost::apply_visitor(*this, setting); + std::visit(*this, setting); } void diff --git a/src/PortInfo.hpp b/src/PortInfo.hpp index 860d1db..b6d88b5 100644 --- a/src/PortInfo.hpp +++ b/src/PortInfo.hpp @@ -7,18 +7,18 @@ #include "PortType.hpp" #include "SignalDirection.hpp" -#include +#include #include namespace patchage { /// Extra information about a port not expressed in its ID struct PortInfo { - std::string label; ///< Human-friendly label - PortType type; ///< Detailed port type - SignalDirection direction; ///< Signal direction - boost::optional order; ///< Order key on client - bool is_terminal; ///< True if this is a system port + std::string label; ///< Human-friendly label + PortType type; ///< Detailed port type + SignalDirection direction; ///< Signal direction + std::optional order; ///< Order key on client + bool is_terminal; ///< True if this is a system port }; } // namespace patchage diff --git a/src/Reactor.cpp b/src/Reactor.cpp index 3c634ab..44bca82 100644 --- a/src/Reactor.cpp +++ b/src/Reactor.cpp @@ -24,15 +24,13 @@ PATCHAGE_DISABLE_FMT_WARNINGS #include PATCHAGE_RESTORE_WARNINGS -#include +#include namespace patchage { class SettingVisitor { public: - using result_type = void; ///< For boost::apply_visitor - explicit SettingVisitor(Configuration& conf) : _conf{conf} {} @@ -61,7 +59,7 @@ void Reactor::operator()(const action::ChangeSetting& action) { SettingVisitor visitor{_conf}; - boost::apply_visitor(visitor, action.setting); + std::visit(visitor, action.setting); } void @@ -185,7 +183,7 @@ Reactor::operator()(const action::ZoomOut&) void Reactor::operator()(const Action& action) { - boost::apply_visitor(*this, action); + std::visit(*this, action); } std::string diff --git a/src/Reactor.hpp b/src/Reactor.hpp index 74af8b7..74b1a07 100644 --- a/src/Reactor.hpp +++ b/src/Reactor.hpp @@ -25,8 +25,6 @@ class ILog; class Reactor { public: - using result_type = void; ///< For boost::apply_visitor - explicit Reactor(Configuration& conf, Drivers& drivers, Canvas& canvas, diff --git a/src/Setting.hpp b/src/Setting.hpp index 1e1aa6f..4bcfc81 100644 --- a/src/Setting.hpp +++ b/src/Setting.hpp @@ -7,9 +7,8 @@ #include "Coord.hpp" #include "PortType.hpp" -#include - #include +#include namespace patchage { namespace setting { @@ -70,19 +69,19 @@ struct Zoom { } // namespace setting /// A configuration setting -using Setting = boost::variant; +using Setting = std::variant; } // namespace patchage diff --git a/src/event_to_string.cpp b/src/event_to_string.cpp index dc14a4d..1f32ce6 100644 --- a/src/event_to_string.cpp +++ b/src/event_to_string.cpp @@ -17,18 +17,15 @@ PATCHAGE_DISABLE_FMT_WARNINGS #include PATCHAGE_RESTORE_WARNINGS -#include -#include - +#include #include +#include namespace patchage { namespace { struct EventPrinter { - using result_type = std::string; ///< For boost::apply_visitor - std::string operator()(const ClientType type) { switch (type) { @@ -101,7 +98,7 @@ std::string event_to_string(const Event& event) { EventPrinter printer; - return boost::apply_visitor(printer, event); + return std::visit(printer, event); } std::ostream& diff --git a/src/handle_event.cpp b/src/handle_event.cpp index 710c4af..d75c42d 100644 --- a/src/handle_event.cpp +++ b/src/handle_event.cpp @@ -18,7 +18,7 @@ PATCHAGE_DISABLE_FMT_WARNINGS #include PATCHAGE_RESTORE_WARNINGS -#include +#include namespace patchage { @@ -27,8 +27,6 @@ namespace { class EventHandler { public: - using result_type = void; ///< For boost::apply_visitor - explicit EventHandler(Configuration& conf, Metadata& metadata, Canvas& canvas, @@ -145,7 +143,7 @@ handle_event(Configuration& conf, const Event& event) { EventHandler handler{conf, metadata, canvas, log}; - boost::apply_visitor(handler, event); + std::visit(handler, event); } } // namespace patchage -- cgit v1.2.1