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 6
6
#define BITCOIN_UTIL_RESULT_H
7
7
8
8
#include < util/translation.h>
9
+
9
10
#include < variant>
10
11
11
12
/*
@@ -18,9 +19,9 @@ class BResult {
18
19
std::variant<bilingual_str, T> m_variant;
19
20
20
21
public:
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)} {}
24
25
25
26
/* Whether the function succeeded or not */
26
27
bool HasRes () const { return std::holds_alternative<T>(m_variant); }
@@ -30,6 +31,11 @@ class BResult {
30
31
assert (HasRes ());
31
32
return std::get<T>(m_variant);
32
33
}
34
+ T ReleaseObj ()
35
+ {
36
+ assert (HasRes ());
37
+ return std::move (std::get<T>(m_variant));
38
+ }
33
39
34
40
/* In case of failure, the error cause */
35
41
const bilingual_str& GetError () const {
You can’t perform that action at this time.
0 commit comments