Skip to content

Commit f0487c4

Browse files
authored
Merge pull request #39 from rustaceanrob/26-6-3-constexpr
Cleanups for removing `Boost.Test`
2 parents 71a1eee + 729dbc5 commit f0487c4

9 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/addrman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct AddressPosition {
6969
const int bucket;
7070
const int position;
7171

72-
bool operator==(AddressPosition other) {
72+
bool operator==(AddressPosition other) const {
7373
return std::tie(tried, multiplicity, bucket, position) ==
7474
std::tie(other.tried, other.multiplicity, other.bucket, other.position);
7575
}

src/crypto/hmac_sha256.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CHMAC_SHA256
1717
CSHA256 inner;
1818

1919
public:
20-
static const size_t OUTPUT_SIZE = 32;
20+
static constexpr size_t OUTPUT_SIZE = 32;
2121

2222
CHMAC_SHA256(const unsigned char* key, size_t keylen);
2323
CHMAC_SHA256& Write(const unsigned char* data, size_t len)

src/crypto/hmac_sha512.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CHMAC_SHA512
1717
CSHA512 inner;
1818

1919
public:
20-
static const size_t OUTPUT_SIZE = 64;
20+
static constexpr size_t OUTPUT_SIZE = 64;
2121

2222
CHMAC_SHA512(const unsigned char* key, size_t keylen);
2323
CHMAC_SHA512& Write(const unsigned char* data, size_t len)

src/crypto/ripemd160.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CRIPEMD160
1717
uint64_t bytes{0};
1818

1919
public:
20-
static const size_t OUTPUT_SIZE = 20;
20+
static constexpr size_t OUTPUT_SIZE = 20;
2121

2222
CRIPEMD160();
2323
CRIPEMD160& Write(const unsigned char* data, size_t len);

src/crypto/sha1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CSHA1
1717
uint64_t bytes{0};
1818

1919
public:
20-
static const size_t OUTPUT_SIZE = 20;
20+
static constexpr size_t OUTPUT_SIZE = 20;
2121

2222
CSHA1();
2323
CSHA1& Write(const unsigned char* data, size_t len);

src/crypto/sha256.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CSHA256
1818
uint64_t bytes{0};
1919

2020
public:
21-
static const size_t OUTPUT_SIZE = 32;
21+
static constexpr size_t OUTPUT_SIZE = 32;
2222

2323
CSHA256();
2424
CSHA256& Write(const unsigned char* data, size_t len);

src/ipc/test/ipc_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ static_assert(ipc::capnp::messages::DEFAULT_BLOCK_RESERVED_WEIGHT == DEFAULT_BLO
3131
static_assert(ipc::capnp::messages::DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS == DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS);
3232

3333
//! Remote init class.
34+
namespace {
3435
class TestInit : public interfaces::Init
3536
{
3637
public:
3738
std::atomic<bool> stop_called{false};
3839
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
3940
void stop() override { stop_called.store(true); }
4041
};
42+
} // namespace
4143

4244
//! Generate a temporary path with temp_directory_path and mkstemp
4345
static std::string TempPath(std::string_view pattern)

src/support/lockedpool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ class LockedPool
131131
* allocation and deallocation overhead. Setting it too high allocates
132132
* more locked memory from the OS than strictly necessary.
133133
*/
134-
static const size_t ARENA_SIZE = 256*1024;
134+
static constexpr size_t ARENA_SIZE = 256*1024;
135135
/** Chunk alignment. Another compromise. Setting this too high will waste
136136
* memory, setting it too low will facilitate fragmentation.
137137
*/
138-
static const size_t ARENA_ALIGN = 16;
138+
static constexpr size_t ARENA_ALIGN = 16;
139139

140140
/** Callback when allocation succeeds but locking fails.
141141
*/

src/test/util/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ inline std::ostream& operator<<(std::ostream& os, const T& e)
4141
}
4242

4343
template <typename T>
44+
requires requires(std::ostream& os, const T& t) { os << t; }
4445
inline std::ostream& operator<<(std::ostream& os, const std::optional<T>& v)
4546
{
4647
return v ? os << *v

0 commit comments

Comments
 (0)