From c1ead13df3d7d06d03cc682c5aaa0559e030b607 Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Wed, 30 Oct 2024 13:04:25 -0400 Subject: [PATCH] wallet2_api: use std::optional instead of handmade optional Cleaner, adheres to POLA, and allows for better compiler optimization. Declaration should be backwards compatible. Requires C++17. --- src/wallet/api/wallet2_api.h | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h index c374d1574..2bedcc7d2 100644 --- a/src/wallet/api/wallet2_api.h +++ b/src/wallet/api/wallet2_api.h @@ -31,14 +31,15 @@ #pragma once -#include -#include -#include -#include +#include #include #include +#include +#include +#include #include -#include +#include +#include // Public interface for libwallet library namespace Monero { @@ -54,18 +55,9 @@ enum NetworkType : uint8_t { void onStartup(); } + // backwards compatible shim for old declaration of handmade optional<> struct template - class optional { - public: - optional(): set(false) {} - optional(const T &t): t(t), set(true) {} - const T &operator*() const { return t; } - T &operator*() { return t; } - operator bool() const { return set; } - private: - T t; - bool set; - }; + using optional = std::optional; /** * @brief Transaction-like interface for sending money