From 89836a82eec63f93bbe6c3bd6a52be26e71ab54d Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 29 Sep 2020 12:13:10 +0200 Subject: style: minor improvements as a followup to #19845 Address suggestions: https://github.com/bitcoin/bitcoin/pull/19845#discussion_r495486760 https://github.com/bitcoin/bitcoin/pull/19845#discussion_r495488051 https://github.com/bitcoin/bitcoin/pull/19845#discussion_r495730125 --- src/netaddress.h | 2 +- src/test/util/setup_common.h | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/netaddress.h b/src/netaddress.h index 59f1b87ad3..708cbd2095 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -29,7 +29,7 @@ * Make sure that this does not collide with any of the values in `version.h` * or with `SERIALIZE_TRANSACTION_NO_WITNESS`. */ -static const int ADDRV2_FORMAT = 0x20000000; +static constexpr int ADDRV2_FORMAT = 0x20000000; /** * A network type. diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index a09c8c122d..1812ce1666 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -158,13 +159,15 @@ std::ostream& operator<<(std::ostream& os, const uint256& num); * Use as * BOOST_CHECK_EXCEPTION(code that throws, exception type, HasReason("foo")); */ -class HasReason { +class HasReason +{ public: explicit HasReason(const std::string& reason) : m_reason(reason) {} - template - bool operator() (const E& e) const { + bool operator()(const std::exception& e) const + { return std::string(e.what()).find(m_reason) != std::string::npos; }; + private: const std::string m_reason; }; -- cgit v1.2.3