From 147d391c74c6ec15ab8b3f50cc6b6bae34638cc3 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 4 Dec 2020 15:18:44 +0100 Subject: [PATCH] Merge #20566: refactor: Use C++17 std::array where possible fac7ab1d5b58fb9cfd80d5cf74ac4d2e5cb8eff2 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 #include int main() { std::array 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 fac7ab1d5b58fb9cfd80d5cf74ac4d2e5cb8eff2 practicalswift: cr ACK fac7ab1d5b58fb9cfd80d5cf74ac4d2e5cb8eff2 vasild: ACK fac7ab1d promag: Code review ACK fac7ab1d5b58fb9cfd80d5cf74ac4d2e5cb8eff2. Tree-SHA512: ef7e872340226e0d6160e6fd66c6ca78b2ef9c245fa0ab27fe4777aac9fba8d5aaa154da3d27b65dec39a6a63d07f1063c3a8ffb667a98ab137756a1a0af2656 --- src/wallet/walletutil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp index 68bae737a8..862794c62c 100644 --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -36,7 +36,7 @@ bool IsFeatureSupported(int wallet_version, int feature_version) WalletFeature GetClosestWalletFeature(int version) { - const std::array wallet_features{{FEATURE_LATEST, FEATURE_HD, FEATURE_COMPRPUBKEY, FEATURE_WALLETCRYPT, FEATURE_BASE}}; + static constexpr std::array wallet_features{FEATURE_LATEST, FEATURE_HD, FEATURE_COMPRPUBKEY, FEATURE_WALLETCRYPT, FEATURE_BASE}; for (const WalletFeature& wf : wallet_features) { if (version >= wf) return wf; }