File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 66#define BITCOIN_UTIL_RESULT_H
77
88#include < util/translation.h>
9+
910#include < variant>
1011
1112/*
@@ -18,9 +19,9 @@ class BResult {
1819 std::variant<bilingual_str, T> m_variant;
1920
2021public:
21- BResult () : m_variant( Untranslated(" " )) {}
22- BResult (const T& _obj ) : m_variant(_obj) {}
23- BResult (const bilingual_str& error) : m_variant(error) {}
22+ BResult () : m_variant{ Untranslated (" " )} {}
23+ BResult (T obj ) : m_variant{ std::move (obj)} {}
24+ BResult (bilingual_str error) : m_variant{ std::move (error)} {}
2425
2526 /* Whether the function succeeded or not */
2627 bool HasRes () const { return std::holds_alternative<T>(m_variant); }
@@ -30,6 +31,11 @@ class BResult {
3031 assert (HasRes ());
3132 return std::get<T>(m_variant);
3233 }
34+ T ReleaseObj ()
35+ {
36+ assert (HasRes ());
37+ return std::move (std::get<T>(m_variant));
38+ }
3339
3440 /* In case of failure, the error cause */
3541 const bilingual_str& GetError () const {
You can’t perform that action at this time.
0 commit comments