mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
Merge #20566: refactor: Use C++17 std::array where possible
fac7ab1d5b
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 ACKfac7ab1d5b
practicalswift: cr ACKfac7ab1d5b
vasild: ACKfac7ab1d
promag: Code review ACKfac7ab1d5b
. Tree-SHA512: ef7e872340226e0d6160e6fd66c6ca78b2ef9c245fa0ab27fe4777aac9fba8d5aaa154da3d27b65dec39a6a63d07f1063c3a8ffb667a98ab137756a1a0af2656
This commit is contained in:
commit
c1604483d3
@ -35,7 +35,7 @@
|
||||
#include <QSettings>
|
||||
#include <QTextDocument>
|
||||
|
||||
static const std::array<int, 9> confTargets = { {2, 4, 6, 12, 24, 48, 144, 504, 1008} };
|
||||
static constexpr std::array confTargets{2, 4, 6, 12, 24, 48, 144, 504, 1008};
|
||||
int getConfTargetForIndex(int index) {
|
||||
if (index+1 > static_cast<int>(confTargets.size())) {
|
||||
return confTargets.back();
|
||||
|
@ -91,7 +91,7 @@ bool IsFeatureSupported(int wallet_version, int feature_version)
|
||||
|
||||
WalletFeature GetClosestWalletFeature(int version)
|
||||
{
|
||||
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}};
|
||||
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};
|
||||
for (const WalletFeature& wf : wallet_features) {
|
||||
if (version >= wf) return wf;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user