Skip to content

Commit dd34204

Browse files
author
MarcoFalke
committed
Merge #13769: Mark single-argument constructors "explicit"
1ac3c98 Mark single-argument constructors "explicit" (practicalswift) Pull request description: Mark single-argument constructors `explicit`. Rationale: * Avoid unexpected implicit promotions. From the developer notes: > **By default, declare single-argument constructors explicit.** > Rationale: This is a precaution to avoid unintended conversions that might arise when single-argument constructors are used as implicit conversion functions. Tree-SHA512: 7901ed5be808c9d0ecb5ca501e1bc0395987fe1b7941b8548cebac2ff08a14f7dab61fab374a69b9ba29a9295a04245c814325c7f95b97ae558af0780f111dfa
2 parents f180e81 + 1ac3c98 commit dd34204

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

src/interfaces/handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace {
1515
class HandlerImpl : public Handler
1616
{
1717
public:
18-
HandlerImpl(boost::signals2::connection connection) : m_connection(std::move(connection)) {}
18+
explicit HandlerImpl(boost::signals2::connection connection) : m_connection(std::move(connection)) {}
1919

2020
void disconnect() override { m_connection.disconnect(); }
2121

src/interfaces/wallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace {
3131
class PendingWalletTxImpl : public PendingWalletTx
3232
{
3333
public:
34-
PendingWalletTxImpl(CWallet& wallet) : m_wallet(wallet), m_key(&wallet) {}
34+
explicit PendingWalletTxImpl(CWallet& wallet) : m_wallet(wallet), m_key(&wallet) {}
3535

3636
const CTransaction& get() override { return *m_tx; }
3737

@@ -117,7 +117,7 @@ static WalletTxOut MakeWalletTxOut(CWallet& wallet, const CWalletTx& wtx, int n,
117117
class WalletImpl : public Wallet
118118
{
119119
public:
120-
WalletImpl(const std::shared_ptr<CWallet>& wallet) : m_shared_wallet(wallet), m_wallet(*wallet.get()) {}
120+
explicit WalletImpl(const std::shared_ptr<CWallet>& wallet) : m_shared_wallet(wallet), m_wallet(*wallet.get()) {}
121121

122122
bool encryptWallet(const SecureString& wallet_passphrase) override
123123
{

src/key_io.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DestinationEncoder : public boost::static_visitor<std::string>
2424
const CChainParams& m_params;
2525

2626
public:
27-
DestinationEncoder(const CChainParams& params) : m_params(params) {}
27+
explicit DestinationEncoder(const CChainParams& params) : m_params(params) {}
2828

2929
std::string operator()(const CKeyID& id) const
3030
{

src/qt/addresstablemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class AddressTablePriv
7171
QList<AddressTableEntry> cachedAddressTable;
7272
AddressTableModel *parent;
7373

74-
AddressTablePriv(AddressTableModel *_parent):
74+
explicit AddressTablePriv(AddressTableModel *_parent):
7575
parent(_parent) {}
7676

7777
void refreshAddressTable(interfaces::Wallet& wallet)

src/qt/rpcconsole.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class RPCExecutor : public QObject
8282
{
8383
Q_OBJECT
8484
public:
85-
RPCExecutor(interfaces::Node& node) : m_node(node) {}
85+
explicit RPCExecutor(interfaces::Node& node) : m_node(node) {}
8686

8787
public Q_SLOTS:
8888
void request(const QString &command, const QString &walletID);

src/qt/transactiontablemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct TxLessThan
6060
class TransactionTablePriv
6161
{
6262
public:
63-
TransactionTablePriv(TransactionTableModel *_parent) :
63+
explicit TransactionTablePriv(TransactionTableModel *_parent) :
6464
parent(_parent)
6565
{
6666
}

src/test/miner_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ BOOST_FIXTURE_TEST_SUITE(miner_tests, TestingSetup)
2929
// BOOST_CHECK_EXCEPTION predicates to check the specific validation error
3030
class HasReason {
3131
public:
32-
HasReason(const std::string& reason) : m_reason(reason) {}
32+
explicit HasReason(const std::string& reason) : m_reason(reason) {}
3333
bool operator() (const std::runtime_error& e) const {
3434
return std::string(e.what()).find(m_reason) != std::string::npos;
3535
};

src/test/validation_block_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ BOOST_FIXTURE_TEST_SUITE(validation_block_tests, RegtestingSetup)
2323
struct TestSubscriber : public CValidationInterface {
2424
uint256 m_expected_tip;
2525

26-
TestSubscriber(uint256 tip) : m_expected_tip(tip) {}
26+
explicit TestSubscriber(uint256 tip) : m_expected_tip(tip) {}
2727

2828
void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override
2929
{

0 commit comments

Comments
 (0)