Skip to content

Commit

Permalink
Merge bitcoin#13769: Mark single-argument constructors "explicit"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MarcoFalke committed Aug 27, 2018
2 parents f180e81 + 1ac3c98 commit dd34204
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/interfaces/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace {
class HandlerImpl : public Handler
{
public:
HandlerImpl(boost::signals2::connection connection) : m_connection(std::move(connection)) {}
explicit HandlerImpl(boost::signals2::connection connection) : m_connection(std::move(connection)) {}

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

Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace {
class PendingWalletTxImpl : public PendingWalletTx
{
public:
PendingWalletTxImpl(CWallet& wallet) : m_wallet(wallet), m_key(&wallet) {}
explicit PendingWalletTxImpl(CWallet& wallet) : m_wallet(wallet), m_key(&wallet) {}

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

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

bool encryptWallet(const SecureString& wallet_passphrase) override
{
Expand Down
2 changes: 1 addition & 1 deletion src/key_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DestinationEncoder : public boost::static_visitor<std::string>
const CChainParams& m_params;

public:
DestinationEncoder(const CChainParams& params) : m_params(params) {}
explicit DestinationEncoder(const CChainParams& params) : m_params(params) {}

std::string operator()(const CKeyID& id) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class AddressTablePriv
QList<AddressTableEntry> cachedAddressTable;
AddressTableModel *parent;

AddressTablePriv(AddressTableModel *_parent):
explicit AddressTablePriv(AddressTableModel *_parent):
parent(_parent) {}

void refreshAddressTable(interfaces::Wallet& wallet)
Expand Down
2 changes: 1 addition & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class RPCExecutor : public QObject
{
Q_OBJECT
public:
RPCExecutor(interfaces::Node& node) : m_node(node) {}
explicit RPCExecutor(interfaces::Node& node) : m_node(node) {}

public Q_SLOTS:
void request(const QString &command, const QString &walletID);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct TxLessThan
class TransactionTablePriv
{
public:
TransactionTablePriv(TransactionTableModel *_parent) :
explicit TransactionTablePriv(TransactionTableModel *_parent) :
parent(_parent)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/miner_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BOOST_FIXTURE_TEST_SUITE(miner_tests, TestingSetup)
// BOOST_CHECK_EXCEPTION predicates to check the specific validation error
class HasReason {
public:
HasReason(const std::string& reason) : m_reason(reason) {}
explicit HasReason(const std::string& reason) : m_reason(reason) {}
bool operator() (const std::runtime_error& e) const {
return std::string(e.what()).find(m_reason) != std::string::npos;
};
Expand Down
2 changes: 1 addition & 1 deletion src/test/validation_block_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BOOST_FIXTURE_TEST_SUITE(validation_block_tests, RegtestingSetup)
struct TestSubscriber : public CValidationInterface {
uint256 m_expected_tip;

TestSubscriber(uint256 tip) : m_expected_tip(tip) {}
explicit TestSubscriber(uint256 tip) : m_expected_tip(tip) {}

void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override
{
Expand Down

0 comments on commit dd34204

Please sign in to comment.