Skip to content

Commit c160448

Browse files
author
MarcoFalke
committed
Merge #20566: refactor: Use C++17 std::array where possible
fac7ab1 refactor: Use C++17 std::array where possible (MarcoFalke) Pull request description: Using the C++11 std::array with explicit template parameters is problematic because overshooting the size will fill the memory with default constructed types. For example, ```cpp #include <array> #include <iostream> int main() { std::array<int, 3> a{1, 2}; for (const auto& i : a) { std::cout << i << std::endl; // prints "1 2 0" } } ``` ACKs for top commit: jonasschnelli: Code Review ACK fac7ab1 practicalswift: cr ACK fac7ab1 vasild: ACK fac7ab1 promag: Code review ACK fac7ab1. Tree-SHA512: ef7e872340226e0d6160e6fd66c6ca78b2ef9c245fa0ab27fe4777aac9fba8d5aaa154da3d27b65dec39a6a63d07f1063c3a8ffb667a98ab137756a1a0af2656
2 parents 9601c0d + fac7ab1 commit c160448

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/qt/sendcoinsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <QSettings>
3636
#include <QTextDocument>
3737

38-
static const std::array<int, 9> confTargets = { {2, 4, 6, 12, 24, 48, 144, 504, 1008} };
38+
static constexpr std::array confTargets{2, 4, 6, 12, 24, 48, 144, 504, 1008};
3939
int getConfTargetForIndex(int index) {
4040
if (index+1 > static_cast<int>(confTargets.size())) {
4141
return confTargets.back();

src/wallet/walletutil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bool IsFeatureSupported(int wallet_version, int feature_version)
9191

9292
WalletFeature GetClosestWalletFeature(int version)
9393
{
94-
const std::array<WalletFeature, 8> wallet_features{{FEATURE_LATEST, FEATURE_PRE_SPLIT_KEYPOOL, FEATURE_NO_DEFAULT_KEY, FEATURE_HD_SPLIT, FEATURE_HD, FEATURE_COMPRPUBKEY, FEATURE_WALLETCRYPT, FEATURE_BASE}};
94+
static constexpr std::array wallet_features{FEATURE_LATEST, FEATURE_PRE_SPLIT_KEYPOOL, FEATURE_NO_DEFAULT_KEY, FEATURE_HD_SPLIT, FEATURE_HD, FEATURE_COMPRPUBKEY, FEATURE_WALLETCRYPT, FEATURE_BASE};
9595
for (const WalletFeature& wf : wallet_features) {
9696
if (version >= wf) return wf;
9797
}

0 commit comments

Comments
 (0)