diff --git a/src/bench/prevector.cpp b/src/bench/prevector.cpp index adc3d18de00..60c43e86e1b 100644 --- a/src/bench/prevector.cpp +++ b/src/bench/prevector.cpp @@ -16,11 +16,11 @@ struct nontrivial_t { nontrivial_t() = default; SERIALIZE_METHODS(nontrivial_t, obj) { READWRITE(obj.x); } }; -static_assert(!std::is_trivially_default_constructible::value, +static_assert(!std::is_trivially_default_constructible_v, "expected nontrivial_t to not be trivially constructible"); typedef unsigned char trivial_t; -static_assert(std::is_trivially_default_constructible::value, +static_assert(std::is_trivially_default_constructible_v, "expected trivial_t to be trivially constructible"); template diff --git a/src/logging/timer.h b/src/logging/timer.h index 0a6813cdd53..bc0d265e93a 100644 --- a/src/logging/timer.h +++ b/src/logging/timer.h @@ -67,11 +67,11 @@ public: } const auto duration{end_time - *m_start_t}; - if constexpr (std::is_same::value) { + if constexpr (std::is_same_v) { return strprintf("%s: %s (%iμs)", m_prefix, msg, Ticks(duration)); - } else if constexpr (std::is_same::value) { + } else if constexpr (std::is_same_v) { return strprintf("%s: %s (%.2fms)", m_prefix, msg, Ticks(duration)); - } else if constexpr (std::is_same::value) { + } else if constexpr (std::is_same_v) { return strprintf("%s: %s (%.2fs)", m_prefix, msg, Ticks(duration)); } else { static_assert(ALWAYS_FALSE, "Error: unexpected time type"); diff --git a/src/serialize.h b/src/serialize.h index ea6b1907700..c2b63205e1b 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -220,13 +220,13 @@ const Out& AsBase(const In& x) template \ void Serialize(Stream& s) const \ { \ - static_assert(std::is_same::value, "Serialize type mismatch"); \ + static_assert(std::is_same_v, "Serialize type mismatch"); \ Ser(s, *this); \ } \ template \ void Unserialize(Stream& s) \ { \ - static_assert(std::is_same::value, "Unserialize type mismatch"); \ + static_assert(std::is_same_v, "Unserialize type mismatch"); \ Unser(s, *this); \ } @@ -408,8 +408,8 @@ template struct CheckVarIntMode { constexpr CheckVarIntMode() { - static_assert(Mode != VarIntMode::DEFAULT || std::is_unsigned::value, "Unsigned type required with mode DEFAULT."); - static_assert(Mode != VarIntMode::NONNEGATIVE_SIGNED || std::is_signed::value, "Signed type required with mode NONNEGATIVE_SIGNED."); + static_assert(Mode != VarIntMode::DEFAULT || std::is_unsigned_v, "Unsigned type required with mode DEFAULT."); + static_assert(Mode != VarIntMode::NONNEGATIVE_SIGNED || std::is_signed_v, "Signed type required with mode NONNEGATIVE_SIGNED."); } }; @@ -474,7 +474,7 @@ I ReadVarInt(Stream& is) template class Wrapper { - static_assert(std::is_lvalue_reference::value, "Wrapper needs an lvalue reference type T"); + static_assert(std::is_lvalue_reference_v, "Wrapper needs an lvalue reference type T"); protected: T m_object; public: @@ -545,7 +545,7 @@ struct CustomUintFormatter template void Unser(Stream& s, I& v) { - using U = typename std::conditional::value, std::underlying_type, std::common_type>::type::type; + using U = typename std::conditional, std::underlying_type, std::common_type>::type::type; static_assert(std::numeric_limits::max() >= MAX && std::numeric_limits::min() <= 0, "Assigned type too small"); uint64_t raw = 0; if (BigEndian) { @@ -577,7 +577,7 @@ struct CompactSizeFormatter template void Ser(Stream& s, I v) { - static_assert(std::is_unsigned::value, "CompactSize only supported for unsigned integers"); + static_assert(std::is_unsigned_v, "CompactSize only supported for unsigned integers"); static_assert(std::numeric_limits::max() <= std::numeric_limits::max(), "CompactSize only supports 64-bit integers and below"); WriteCompactSize(s, v); diff --git a/src/sync.cpp b/src/sync.cpp index 93c91945414..e5be6fd1156 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -148,8 +148,8 @@ template static void push_lock(MutexType* c, const CLockLocation& locklocation) { constexpr bool is_recursive_mutex = - std::is_base_of::value || - std::is_base_of::value; + std::is_base_of_v || + std::is_base_of_v; LockData& lockdata = GetLockData(); std::lock_guard lock(lockdata.dd_mutex); diff --git a/src/test/fuzz/FuzzedDataProvider.h b/src/test/fuzz/FuzzedDataProvider.h index e57b95b6304..42f45b4c818 100644 --- a/src/test/fuzz/FuzzedDataProvider.h +++ b/src/test/fuzz/FuzzedDataProvider.h @@ -203,7 +203,7 @@ template T FuzzedDataProvider::ConsumeIntegral() { // be less than or equal to |max|. template T FuzzedDataProvider::ConsumeIntegralInRange(T min, T max) { - static_assert(std::is_integral::value, "An integral type is required."); + static_assert(std::is_integral_v, "An integral type is required."); static_assert(sizeof(T) <= sizeof(uint64_t), "Unsupported integral type."); if (min > max) @@ -271,7 +271,7 @@ T FuzzedDataProvider::ConsumeFloatingPointInRange(T min, T max) { // Returns a floating point number in the range [0.0, 1.0]. If there's no // input data left, always returns 0. template T FuzzedDataProvider::ConsumeProbability() { - static_assert(std::is_floating_point::value, + static_assert(std::is_floating_point_v, "A floating point type is required."); // Use different integral types for different floating point types in order @@ -294,7 +294,7 @@ inline bool FuzzedDataProvider::ConsumeBool() { // also contain |kMaxValue| aliased to its largest (inclusive) value. Such as: // enum class Foo { SomeValue, OtherValue, kMaxValue = OtherValue }; template T FuzzedDataProvider::ConsumeEnum() { - static_assert(std::is_enum::value, "|T| must be an enum type."); + static_assert(std::is_enum_v, "|T| must be an enum type."); return static_cast( ConsumeIntegralInRange(0, static_cast(T::kMaxValue))); } diff --git a/src/test/fuzz/integer.cpp b/src/test/fuzz/integer.cpp index b9e3154106f..a6729155d1f 100644 --- a/src/test/fuzz/integer.cpp +++ b/src/test/fuzz/integer.cpp @@ -63,7 +63,7 @@ FUZZ_TARGET(integer, .init = initialize_integer) const int16_t i16 = fuzzed_data_provider.ConsumeIntegral(); const uint8_t u8 = fuzzed_data_provider.ConsumeIntegral(); const int8_t i8 = fuzzed_data_provider.ConsumeIntegral(); - // We cannot assume a specific value of std::is_signed::value: + // We cannot assume a specific value of std::is_signed_v: // ConsumeIntegral() instead of casting from {u,}int8_t. const char ch = fuzzed_data_provider.ConsumeIntegral(); const bool b = fuzzed_data_provider.ConsumeBool(); diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index ae301621fbd..28dd9805fed 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -207,7 +207,7 @@ template template [[nodiscard]] bool MultiplicationOverflow(const T i, const T j) noexcept { - static_assert(std::is_integral::value, "Integral required."); + static_assert(std::is_integral_v, "Integral required."); if (std::numeric_limits::is_signed) { if (i > 0) { if (j > 0) { diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h index da121575554..19a500d191a 100644 --- a/src/univalue/include/univalue.h +++ b/src/univalue/include/univalue.h @@ -137,7 +137,7 @@ void UniValue::push_backV(It first, It last) template Int UniValue::getInt() const { - static_assert(std::is_integral::value); + static_assert(std::is_integral_v); checkType(VNUM); Int result; const auto [first_nonmatching, error_condition] = std::from_chars(val.data(), val.data() + val.size(), result); diff --git a/src/util/fs.h b/src/util/fs.h index f841e0d76c5..ce17682497c 100644 --- a/src/util/fs.h +++ b/src/util/fs.h @@ -163,7 +163,7 @@ static inline std::string PathToString(const path& path) #ifdef WIN32 return path.utf8string(); #else - static_assert(std::is_same::value, "PathToString not implemented on this platform"); + static_assert(std::is_same_v, "PathToString not implemented on this platform"); return path.std::filesystem::path::string(); #endif } diff --git a/src/util/overflow.h b/src/util/overflow.h index 67711af0a5e..ab20faf8557 100644 --- a/src/util/overflow.h +++ b/src/util/overflow.h @@ -14,7 +14,7 @@ template [[nodiscard]] bool AdditionOverflow(const T i, const T j) noexcept { - static_assert(std::is_integral::value, "Integral required."); + static_assert(std::is_integral_v, "Integral required."); if constexpr (std::numeric_limits::is_signed) { return (i > 0 && j > std::numeric_limits::max() - i) || (i < 0 && j < std::numeric_limits::min() - i); diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp index 15cb40aba13..eed8bf81370 100644 --- a/src/util/strencodings.cpp +++ b/src/util/strencodings.cpp @@ -204,7 +204,7 @@ namespace { template bool ParseIntegral(std::string_view str, T* out) { - static_assert(std::is_integral::value); + static_assert(std::is_integral_v); // Replicate the exact behavior of strtol/strtoll/strtoul/strtoull when // handling leading +/- for backwards compatibility. if (str.length() >= 2 && str[0] == '+' && str[1] == '-') { diff --git a/src/util/strencodings.h b/src/util/strencodings.h index d0809162faf..75030983d21 100644 --- a/src/util/strencodings.h +++ b/src/util/strencodings.h @@ -117,7 +117,7 @@ bool SplitHostPort(std::string_view in, uint16_t& portOut, std::string& hostOut) template T LocaleIndependentAtoi(std::string_view str) { - static_assert(std::is_integral::value); + static_assert(std::is_integral_v); T result; // Emulate atoi(...) handling of white space and leading +/-. std::string_view s = util::TrimStringView(str); @@ -178,7 +178,7 @@ constexpr inline bool IsSpace(char c) noexcept { template std::optional ToIntegral(std::string_view str) { - static_assert(std::is_integral::value); + static_assert(std::is_integral_v); T result; const auto [first_nonmatching, error_condition] = std::from_chars(str.data(), str.data() + str.size(), result); if (first_nonmatching != str.data() + str.size() || error_condition != std::errc{}) {