/bitcoin/src/util/result.h
Line | Count | Source |
1 | | // Copyright (c) 2022 The Bitcoin Core developers |
2 | | // Distributed under the MIT software license, see the accompanying |
3 | | // file COPYING or https://www.opensource.org/licenses/mit-license.php. |
4 | | |
5 | | #ifndef BITCOIN_UTIL_RESULT_H |
6 | | #define BITCOIN_UTIL_RESULT_H |
7 | | |
8 | | #include <attributes.h> |
9 | | #include <util/translation.h> |
10 | | |
11 | | #include <variant> |
12 | | |
13 | | namespace util { |
14 | | |
15 | | struct Error { |
16 | | bilingual_str message; |
17 | | }; |
18 | | |
19 | | //! The util::Result class provides a standard way for functions to return |
20 | | //! either error messages or result values. |
21 | | //! |
22 | | //! It is intended for high-level functions that need to report error strings to |
23 | | //! end users. Lower-level functions that don't need this error-reporting and |
24 | | //! only need error-handling should avoid util::Result and instead use standard |
25 | | //! classes like std::optional, std::variant, and std::tuple, or custom structs |
26 | | //! and enum types to return function results. |
27 | | //! |
28 | | //! Usage examples can be found in \example ../test/result_tests.cpp, but in |
29 | | //! general code returning `util::Result<T>` values is very similar to code |
30 | | //! returning `std::optional<T>` values. Existing functions returning |
31 | | //! `std::optional<T>` can be updated to return `util::Result<T>` and return |
32 | | //! error strings usually just replacing `return std::nullopt;` with `return |
33 | | //! util::Error{error_string};`. |
34 | | template <class M> |
35 | | class Result |
36 | | { |
37 | | private: |
38 | | using T = std::conditional_t<std::is_same_v<M, void>, std::monostate, M>; |
39 | | |
40 | | std::variant<bilingual_str, T> m_variant; |
41 | | |
42 | | //! Disallow copy constructor, require Result to be moved for efficiency. |
43 | | Result(const Result&) = delete; |
44 | | |
45 | | //! Disallow operator= to avoid confusion in the future when the Result |
46 | | //! class gains support for richer error reporting, and callers should have |
47 | | //! ability to set a new result value without clearing existing error |
48 | | //! messages. |
49 | | Result& operator=(const Result&) = delete; |
50 | | Result& operator=(Result&&) = delete; |
51 | | |
52 | | template <typename FT> |
53 | | friend bilingual_str ErrorString(const Result<FT>& result); |
54 | | |
55 | | public: |
56 | 100k | Result() : m_variant{std::in_place_index_t<1>{}, std::monostate{}} {} // constructor for void |
57 | 1.62M | Result(T obj) : m_variant{std::in_place_index_t<1>{}, std::move(obj)} {} util::Result<std::set<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > > >::Result(std::set<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > >) Line | Count | Source | 57 | 1.59M | Result(T obj) : m_variant{std::in_place_index_t<1>{}, std::move(obj)} {} |
util::Result<std::pair<std::vector<FeeFrac, std::allocator<FeeFrac> >, std::vector<FeeFrac, std::allocator<FeeFrac> > > >::Result(std::pair<std::vector<FeeFrac, std::allocator<FeeFrac> >, std::vector<FeeFrac, std::allocator<FeeFrac> > >) Line | Count | Source | 57 | 231 | Result(T obj) : m_variant{std::in_place_index_t<1>{}, std::move(obj)} {} |
Unexecuted instantiation: util::Result<CBlockIndex*>::Result(CBlockIndex*) util::Result<std::unique_ptr<AddrMan, std::default_delete<AddrMan> > >::Result(std::unique_ptr<AddrMan, std::default_delete<AddrMan> >) Line | Count | Source | 57 | 11.0k | Result(T obj) : m_variant{std::in_place_index_t<1>{}, std::move(obj)} {} |
Unexecuted instantiation: util::Result<std::shared_ptr<CTransaction const> >::Result(std::shared_ptr<CTransaction const>) Unexecuted instantiation: util::Result<std::unique_ptr<interfaces::Wallet, std::default_delete<interfaces::Wallet> > >::Result(std::unique_ptr<interfaces::Wallet, std::default_delete<interfaces::Wallet> >) Unexecuted instantiation: util::Result<interfaces::WalletMigrationResult>::Result(interfaces::WalletMigrationResult) Unexecuted instantiation: util::Result<std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown> >::Result(std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown>) Unexecuted instantiation: util::Result<wallet::CreatedTransactionResult>::Result(wallet::CreatedTransactionResult) Unexecuted instantiation: util::Result<wallet::PreSelectedInputs>::Result(wallet::PreSelectedInputs) Unexecuted instantiation: util::Result<wallet::SelectionResult>::Result(wallet::SelectionResult) util::Result<fs::path>::Result(fs::path) Line | Count | Source | 57 | 22.1k | Result(T obj) : m_variant{std::in_place_index_t<1>{}, std::move(obj)} {} |
Unexecuted instantiation: util::Result<std::reference_wrapper<wallet::DescriptorScriptPubKeyMan> >::Result(std::reference_wrapper<wallet::DescriptorScriptPubKeyMan>) Unexecuted instantiation: util::Result<wallet::MigrationResult>::Result(wallet::MigrationResult) Unexecuted instantiation: util::Result<int>::Result(int) |
58 | 673 | Result(Error error) : m_variant{std::in_place_index_t<0>{}, std::move(error.message)} {} util::Result<void>::Result(util::Error) Line | Count | Source | 58 | 10 | Result(Error error) : m_variant{std::in_place_index_t<0>{}, std::move(error.message)} {} |
util::Result<std::set<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > > >::Result(util::Error) Line | Count | Source | 58 | 611 | Result(Error error) : m_variant{std::in_place_index_t<0>{}, std::move(error.message)} {} |
util::Result<std::pair<std::vector<FeeFrac, std::allocator<FeeFrac> >, std::vector<FeeFrac, std::allocator<FeeFrac> > > >::Result(util::Error) Line | Count | Source | 58 | 52 | Result(Error error) : m_variant{std::in_place_index_t<0>{}, std::move(error.message)} {} |
Unexecuted instantiation: util::Result<CBlockIndex*>::Result(util::Error) Unexecuted instantiation: util::Result<std::unique_ptr<AddrMan, std::default_delete<AddrMan> > >::Result(util::Error) Unexecuted instantiation: util::Result<std::shared_ptr<CTransaction const> >::Result(util::Error) Unexecuted instantiation: util::Result<std::unique_ptr<interfaces::Wallet, std::default_delete<interfaces::Wallet> > >::Result(util::Error) Unexecuted instantiation: util::Result<interfaces::WalletMigrationResult>::Result(util::Error) Unexecuted instantiation: util::Result<std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown> >::Result(util::Error) Unexecuted instantiation: util::Result<wallet::PreSelectedInputs>::Result(util::Error) Unexecuted instantiation: util::Result<wallet::SelectionResult>::Result(util::Error) Unexecuted instantiation: util::Result<wallet::CreatedTransactionResult>::Result(util::Error) Unexecuted instantiation: util::Result<fs::path>::Result(util::Error) Unexecuted instantiation: util::Result<std::reference_wrapper<wallet::DescriptorScriptPubKeyMan> >::Result(util::Error) Unexecuted instantiation: util::Result<wallet::MigrationResult>::Result(util::Error) Unexecuted instantiation: util::Result<int>::Result(util::Error) |
59 | 0 | Result(Result&&) = default; Unexecuted instantiation: util::Result<wallet::SelectionResult>::Result(util::Result<wallet::SelectionResult>&&) Unexecuted instantiation: util::Result<wallet::CreatedTransactionResult>::Result(util::Result<wallet::CreatedTransactionResult>&&) |
60 | 1.73M | ~Result() = default; util::Result<void>::~Result() Line | Count | Source | 60 | 100k | ~Result() = default; |
util::Result<std::unique_ptr<AddrMan, std::default_delete<AddrMan> > >::~Result() Line | Count | Source | 60 | 11.0k | ~Result() = default; |
util::Result<std::pair<std::vector<FeeFrac, std::allocator<FeeFrac> >, std::vector<FeeFrac, std::allocator<FeeFrac> > > >::~Result() Line | Count | Source | 60 | 283 | ~Result() = default; |
Unexecuted instantiation: util::Result<CBlockIndex*>::~Result() util::Result<std::set<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > > >::~Result() Line | Count | Source | 60 | 1.59M | ~Result() = default; |
Unexecuted instantiation: util::Result<wallet::CreatedTransactionResult>::~Result() Unexecuted instantiation: util::Result<wallet::PreSelectedInputs>::~Result() Unexecuted instantiation: util::Result<wallet::MigrationResult>::~Result() Unexecuted instantiation: util::Result<std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown> >::~Result() Unexecuted instantiation: util::Result<wallet::SelectionResult>::~Result() util::Result<fs::path>::~Result() Line | Count | Source | 60 | 22.1k | ~Result() = default; |
Unexecuted instantiation: util::Result<std::reference_wrapper<wallet::DescriptorScriptPubKeyMan> >::~Result() Unexecuted instantiation: util::Result<int>::~Result() |
61 | | |
62 | | //! std::optional methods, so functions returning optional<T> can change to |
63 | | //! return Result<T> with minimal changes to existing code, and vice versa. |
64 | 6.46M | bool has_value() const noexcept { return m_variant.index() == 1; } util::Result<void>::has_value() const Line | Count | Source | 64 | 100k | bool has_value() const noexcept { return m_variant.index() == 1; } |
util::Result<std::unique_ptr<AddrMan, std::default_delete<AddrMan> > >::has_value() const Line | Count | Source | 64 | 22.1k | bool has_value() const noexcept { return m_variant.index() == 1; } |
util::Result<std::set<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > > >::has_value() const Line | Count | Source | 64 | 6.29M | bool has_value() const noexcept { return m_variant.index() == 1; } |
util::Result<std::pair<std::vector<FeeFrac, std::allocator<FeeFrac> >, std::vector<FeeFrac, std::allocator<FeeFrac> > > >::has_value() const Line | Count | Source | 64 | 797 | bool has_value() const noexcept { return m_variant.index() == 1; } |
Unexecuted instantiation: util::Result<CBlockIndex*>::has_value() const Unexecuted instantiation: util::Result<wallet::CreatedTransactionResult>::has_value() const Unexecuted instantiation: util::Result<wallet::PreSelectedInputs>::has_value() const Unexecuted instantiation: util::Result<wallet::MigrationResult>::has_value() const Unexecuted instantiation: util::Result<std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown> >::has_value() const Unexecuted instantiation: util::Result<wallet::SelectionResult>::has_value() const util::Result<fs::path>::has_value() const Line | Count | Source | 64 | 44.3k | bool has_value() const noexcept { return m_variant.index() == 1; } |
Unexecuted instantiation: util::Result<std::reference_wrapper<wallet::DescriptorScriptPubKeyMan> >::has_value() const Unexecuted instantiation: util::Result<int>::has_value() const |
65 | | const T& value() const LIFETIMEBOUND |
66 | 22.6k | { |
67 | 22.6k | assert(has_value()); Branch (67:9): [True: 462, False: 0]
Branch (67:9): [True: 22.1k, False: 0]
Branch (67:9): [True: 0, False: 0]
|
68 | 22.6k | return std::get<1>(m_variant); |
69 | 22.6k | } util::Result<std::pair<std::vector<FeeFrac, std::allocator<FeeFrac> >, std::vector<FeeFrac, std::allocator<FeeFrac> > > >::value() const Line | Count | Source | 66 | 462 | { | 67 | 462 | assert(has_value()); Branch (67:9): [True: 462, False: 0]
| 68 | 462 | return std::get<1>(m_variant); | 69 | 462 | } |
util::Result<fs::path>::value() const Line | Count | Source | 66 | 22.1k | { | 67 | 22.1k | assert(has_value()); Branch (67:9): [True: 22.1k, False: 0]
| 68 | 22.1k | return std::get<1>(m_variant); | 69 | 22.1k | } |
Unexecuted instantiation: util::Result<int>::value() const |
70 | | T& value() LIFETIMEBOUND |
71 | 1.66M | { |
72 | 1.66M | assert(has_value()); Branch (72:9): [True: 11.0k, False: 0]
Branch (72:9): [True: 1.65M, False: 0]
Branch (72:9): [True: 0, False: 0]
Branch (72:9): [True: 0, False: 0]
Branch (72:9): [True: 0, False: 0]
Branch (72:9): [True: 0, False: 0]
Branch (72:9): [True: 0, False: 0]
Branch (72:9): [True: 0, False: 0]
Branch (72:9): [True: 0, False: 0]
|
73 | 1.66M | return std::get<1>(m_variant); |
74 | 1.66M | } util::Result<std::unique_ptr<AddrMan, std::default_delete<AddrMan> > >::value() Line | Count | Source | 71 | 11.0k | { | 72 | 11.0k | assert(has_value()); Branch (72:9): [True: 11.0k, False: 0]
| 73 | 11.0k | return std::get<1>(m_variant); | 74 | 11.0k | } |
util::Result<std::set<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > > >::value() Line | Count | Source | 71 | 1.65M | { | 72 | 1.65M | assert(has_value()); Branch (72:9): [True: 1.65M, False: 0]
| 73 | 1.65M | return std::get<1>(m_variant); | 74 | 1.65M | } |
Unexecuted instantiation: util::Result<CBlockIndex*>::value() Unexecuted instantiation: util::Result<wallet::CreatedTransactionResult>::value() Unexecuted instantiation: util::Result<wallet::PreSelectedInputs>::value() Unexecuted instantiation: util::Result<wallet::MigrationResult>::value() Unexecuted instantiation: util::Result<std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown> >::value() Unexecuted instantiation: util::Result<wallet::SelectionResult>::value() Unexecuted instantiation: util::Result<std::reference_wrapper<wallet::DescriptorScriptPubKeyMan> >::value() |
75 | | template <class U> |
76 | | T value_or(U&& default_value) const& |
77 | | { |
78 | | return has_value() ? value() : std::forward<U>(default_value); |
79 | | } |
80 | | template <class U> |
81 | | T value_or(U&& default_value) && |
82 | 1.49M | { |
83 | 1.49M | return has_value() ? std::move(value()) : std::forward<U>(default_value); Branch (83:16): [True: 1.49M, False: 0]
|
84 | 1.49M | } |
85 | 3.28M | explicit operator bool() const noexcept { return has_value(); } util::Result<void>::operator bool() const Line | Count | Source | 85 | 100k | explicit operator bool() const noexcept { return has_value(); } |
util::Result<std::unique_ptr<AddrMan, std::default_delete<AddrMan> > >::operator bool() const Line | Count | Source | 85 | 11.0k | explicit operator bool() const noexcept { return has_value(); } |
util::Result<std::set<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > > >::operator bool() const Line | Count | Source | 85 | 3.14M | explicit operator bool() const noexcept { return has_value(); } |
util::Result<std::pair<std::vector<FeeFrac, std::allocator<FeeFrac> >, std::vector<FeeFrac, std::allocator<FeeFrac> > > >::operator bool() const Line | Count | Source | 85 | 52 | explicit operator bool() const noexcept { return has_value(); } |
Unexecuted instantiation: util::Result<CBlockIndex*>::operator bool() const Unexecuted instantiation: util::Result<wallet::CreatedTransactionResult>::operator bool() const Unexecuted instantiation: util::Result<wallet::PreSelectedInputs>::operator bool() const Unexecuted instantiation: util::Result<wallet::MigrationResult>::operator bool() const Unexecuted instantiation: util::Result<std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown> >::operator bool() const Unexecuted instantiation: util::Result<wallet::SelectionResult>::operator bool() const util::Result<fs::path>::operator bool() const Line | Count | Source | 85 | 22.1k | explicit operator bool() const noexcept { return has_value(); } |
Unexecuted instantiation: util::Result<std::reference_wrapper<wallet::DescriptorScriptPubKeyMan> >::operator bool() const Unexecuted instantiation: util::Result<int>::operator bool() const |
86 | | const T* operator->() const LIFETIMEBOUND { return &value(); } |
87 | 22.1k | const T& operator*() const LIFETIMEBOUND { return value(); } |
88 | 0 | T* operator->() LIFETIMEBOUND { return &value(); } Unexecuted instantiation: util::Result<wallet::PreSelectedInputs>::operator->() Unexecuted instantiation: util::Result<wallet::MigrationResult>::operator->() Unexecuted instantiation: util::Result<wallet::SelectionResult>::operator->() Unexecuted instantiation: util::Result<wallet::CreatedTransactionResult>::operator->() |
89 | 168k | T& operator*() LIFETIMEBOUND { return value(); } util::Result<std::unique_ptr<AddrMan, std::default_delete<AddrMan> > >::operator*() Line | Count | Source | 89 | 11.0k | T& operator*() LIFETIMEBOUND { return value(); } |
util::Result<std::set<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > > >::operator*() Line | Count | Source | 89 | 157k | T& operator*() LIFETIMEBOUND { return value(); } |
Unexecuted instantiation: util::Result<CBlockIndex*>::operator*() Unexecuted instantiation: util::Result<wallet::CreatedTransactionResult>::operator*() Unexecuted instantiation: util::Result<std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown> >::operator*() Unexecuted instantiation: util::Result<wallet::PreSelectedInputs>::operator*() Unexecuted instantiation: util::Result<wallet::SelectionResult>::operator*() |
90 | | }; |
91 | | |
92 | | template <typename T> |
93 | | bilingual_str ErrorString(const Result<T>& result) |
94 | 600 | { |
95 | 600 | return result ? bilingual_str{} : std::get<0>(result.m_variant); Branch (95:12): [True: 0, False: 10]
Branch (95:12): [True: 0, False: 0]
Branch (95:12): [True: 0, False: 52]
Branch (95:12): [True: 0, False: 0]
Branch (95:12): [True: 0, False: 538]
Branch (95:12): [True: 0, False: 0]
Branch (95:12): [True: 0, False: 0]
Branch (95:12): [True: 0, False: 0]
Branch (95:12): [True: 0, False: 0]
Branch (95:12): [True: 0, False: 0]
Branch (95:12): [True: 0, False: 0]
Branch (95:12): [True: 0, False: 0]
Branch (95:12): [True: 0, False: 0]
|
96 | 600 | } bilingual_str util::ErrorString<void>(util::Result<void> const&) Line | Count | Source | 94 | 10 | { | 95 | 10 | return result ? bilingual_str{} : std::get<0>(result.m_variant); Branch (95:12): [True: 0, False: 10]
| 96 | 10 | } |
Unexecuted instantiation: bilingual_str util::ErrorString<std::unique_ptr<AddrMan, std::default_delete<AddrMan> > >(util::Result<std::unique_ptr<AddrMan, std::default_delete<AddrMan> > > const&) bilingual_str util::ErrorString<std::pair<std::vector<FeeFrac, std::allocator<FeeFrac> >, std::vector<FeeFrac, std::allocator<FeeFrac> > > >(util::Result<std::pair<std::vector<FeeFrac, std::allocator<FeeFrac> >, std::vector<FeeFrac, std::allocator<FeeFrac> > > > const&) Line | Count | Source | 94 | 52 | { | 95 | 52 | return result ? bilingual_str{} : std::get<0>(result.m_variant); Branch (95:12): [True: 0, False: 52]
| 96 | 52 | } |
Unexecuted instantiation: bilingual_str util::ErrorString<CBlockIndex*>(util::Result<CBlockIndex*> const&) bilingual_str util::ErrorString<std::set<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > > >(util::Result<std::set<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > > > const&) Line | Count | Source | 94 | 538 | { | 95 | 538 | return result ? bilingual_str{} : std::get<0>(result.m_variant); Branch (95:12): [True: 0, False: 538]
| 96 | 538 | } |
Unexecuted instantiation: bilingual_str util::ErrorString<wallet::CreatedTransactionResult>(util::Result<wallet::CreatedTransactionResult> const&) Unexecuted instantiation: bilingual_str util::ErrorString<wallet::MigrationResult>(util::Result<wallet::MigrationResult> const&) Unexecuted instantiation: bilingual_str util::ErrorString<wallet::SelectionResult>(util::Result<wallet::SelectionResult> const&) Unexecuted instantiation: bilingual_str util::ErrorString<std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown> >(util::Result<std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown> > const&) Unexecuted instantiation: bilingual_str util::ErrorString<wallet::PreSelectedInputs>(util::Result<wallet::PreSelectedInputs> const&) Unexecuted instantiation: bilingual_str util::ErrorString<fs::path>(util::Result<fs::path> const&) Unexecuted instantiation: bilingual_str util::ErrorString<std::reference_wrapper<wallet::DescriptorScriptPubKeyMan> >(util::Result<std::reference_wrapper<wallet::DescriptorScriptPubKeyMan> > const&) Unexecuted instantiation: bilingual_str util::ErrorString<int>(util::Result<int> const&) |
97 | | } // namespace util |
98 | | |
99 | | #endif // BITCOIN_UTIL_RESULT_H |