Skip to content

Commit 2d48314

Browse files
committed
Remove 'boost::optional'-related gcc warnings
1 parent 72ca72e commit 2d48314

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/optional.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@
55
#ifndef BITCOIN_OPTIONAL_H
66
#define BITCOIN_OPTIONAL_H
77

8+
#include <utility>
9+
810
#include <boost/optional.hpp>
911

1012
//! Substitute for C++17 std::optional
1113
template <typename T>
1214
using Optional = boost::optional<T>;
1315

16+
//! Substitute for C++17 std::make_optional
17+
template <typename T>
18+
Optional<T> MakeOptional(bool condition, T&& value)
19+
{
20+
return boost::make_optional(condition, std::forward<T>(value));
21+
}
22+
1423
//! Substitute for C++17 std::nullopt
1524
static auto& nullopt = boost::none;
1625

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,8 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
15911591
auto locked_chain = pwallet->chain().lock();
15921592
LOCK(pwallet->cs_wallet);
15931593

1594-
Optional<int> height; // Height of the specified block or the common ancestor, if the block provided was in a deactivated chain.
1594+
// The way the 'height' is initialized is just a workaround for the gcc bug #47679 since version 4.6.0.
1595+
Optional<int> height = MakeOptional(false, int()); // Height of the specified block or the common ancestor, if the block provided was in a deactivated chain.
15951596
Optional<int> altheight; // Height of the specified block, even if it's in a deactivated chain.
15961597
int target_confirms = 1;
15971598
isminefilter filter = ISMINE_SPENDABLE;

src/wallet/wallet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,8 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
16421642
fAbortRescan = false;
16431643
ShowProgress(strprintf("%s " + _("Rescanning..."), GetDisplayName()), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
16441644
uint256 tip_hash;
1645-
Optional<int> block_height;
1645+
// The way the 'block_height' is initialized is just a workaround for the gcc bug #47679 since version 4.6.0.
1646+
Optional<int> block_height = MakeOptional(false, int());
16461647
double progress_begin;
16471648
double progress_end;
16481649
{

0 commit comments

Comments
 (0)