diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/designator.h | 21 | ||||
-rw-r--r-- | src/util/result.h | 12 |
2 files changed, 9 insertions, 24 deletions
diff --git a/src/util/designator.h b/src/util/designator.h deleted file mode 100644 index 3670b11e00..0000000000 --- a/src/util/designator.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2022 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_UTIL_DESIGNATOR_H -#define BITCOIN_UTIL_DESIGNATOR_H - -/** - * Designated initializers can be used to avoid ordering mishaps in aggregate - * initialization. However, they do not prevent uninitialized members. The - * checks can be disabled by defining DISABLE_DESIGNATED_INITIALIZER_ERRORS. - * This should only be needed on MSVC 2019. MSVC 2022 supports them with the - * option "/std:c++20" - */ -#ifndef DISABLE_DESIGNATED_INITIALIZER_ERRORS -#define Desig(field_name) .field_name = -#else -#define Desig(field_name) -#endif - -#endif // BITCOIN_UTIL_DESIGNATOR_H diff --git a/src/util/result.h b/src/util/result.h index dcf5edaa5b..2f586a4c9b 100644 --- a/src/util/result.h +++ b/src/util/result.h @@ -6,6 +6,7 @@ #define BITCOIN_UTIL_RESULT_H #include <util/translation.h> + #include <variant> /* @@ -18,9 +19,9 @@ private: std::variant<bilingual_str, T> m_variant; public: - BResult() : m_variant(Untranslated("")) {} - BResult(const T& _obj) : m_variant(_obj) {} - BResult(const bilingual_str& error) : m_variant(error) {} + BResult() : m_variant{Untranslated("")} {} + BResult(T obj) : m_variant{std::move(obj)} {} + BResult(bilingual_str error) : m_variant{std::move(error)} {} /* Whether the function succeeded or not */ bool HasRes() const { return std::holds_alternative<T>(m_variant); } @@ -30,6 +31,11 @@ public: assert(HasRes()); return std::get<T>(m_variant); } + T ReleaseObj() + { + assert(HasRes()); + return std::move(std::get<T>(m_variant)); + } /* In case of failure, the error cause */ const bilingual_str& GetError() const { |