mirror of
https://github.com/monero-project/monero.git
synced 2024-12-25 12:29:22 -05:00
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.
This commit is contained in:
parent
9866a0e902
commit
c1ead13df3
@ -31,14 +31,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <cstdint>
|
||||||
#include <vector>
|
|
||||||
#include <list>
|
|
||||||
#include <set>
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
#include <optional>
|
||||||
|
#include <set>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cstdint>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// Public interface for libwallet library
|
// Public interface for libwallet library
|
||||||
namespace Monero {
|
namespace Monero {
|
||||||
@ -54,18 +55,9 @@ enum NetworkType : uint8_t {
|
|||||||
void onStartup();
|
void onStartup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// backwards compatible shim for old declaration of handmade optional<> struct
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class optional {
|
using optional = std::optional<T>;
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Transaction-like interface for sending money
|
* @brief Transaction-like interface for sending money
|
||||||
|
Loading…
Reference in New Issue
Block a user