mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-03 20:35:17 +02:00
scripted-diff: modernize outdated trait patterns - values
See https://en.cppreference.com/w/cpp/types/is_enum for more details. -BEGIN VERIFY SCRIPT- sed -i -E 's/(std::[a-z_]+)(<[^<>]+>)::value\b/\1_v\2/g' $(git grep -l '::value' ./src ':(exclude)src/bench/nanobench.h' ':(exclude)src/minisketch' ':(exclude)src/span.h') -END VERIFY SCRIPT-
This commit is contained in:
@@ -203,7 +203,7 @@ template <typename T> T FuzzedDataProvider::ConsumeIntegral() {
|
||||
// be less than or equal to |max|.
|
||||
template <typename T>
|
||||
T FuzzedDataProvider::ConsumeIntegralInRange(T min, T max) {
|
||||
static_assert(std::is_integral<T>::value, "An integral type is required.");
|
||||
static_assert(std::is_integral_v<T>, "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 <typename T> T FuzzedDataProvider::ConsumeProbability() {
|
||||
static_assert(std::is_floating_point<T>::value,
|
||||
static_assert(std::is_floating_point_v<T>,
|
||||
"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 <typename T> T FuzzedDataProvider::ConsumeEnum() {
|
||||
static_assert(std::is_enum<T>::value, "|T| must be an enum type.");
|
||||
static_assert(std::is_enum_v<T>, "|T| must be an enum type.");
|
||||
return static_cast<T>(
|
||||
ConsumeIntegralInRange<uint32_t>(0, static_cast<uint32_t>(T::kMaxValue)));
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ FUZZ_TARGET(integer, .init = initialize_integer)
|
||||
const int16_t i16 = fuzzed_data_provider.ConsumeIntegral<int16_t>();
|
||||
const uint8_t u8 = fuzzed_data_provider.ConsumeIntegral<uint8_t>();
|
||||
const int8_t i8 = fuzzed_data_provider.ConsumeIntegral<int8_t>();
|
||||
// We cannot assume a specific value of std::is_signed<char>::value:
|
||||
// We cannot assume a specific value of std::is_signed_v<char>:
|
||||
// ConsumeIntegral<char>() instead of casting from {u,}int8_t.
|
||||
const char ch = fuzzed_data_provider.ConsumeIntegral<char>();
|
||||
const bool b = fuzzed_data_provider.ConsumeBool();
|
||||
|
||||
@@ -207,7 +207,7 @@ template <typename WeakEnumType, size_t size>
|
||||
template <typename T>
|
||||
[[nodiscard]] bool MultiplicationOverflow(const T i, const T j) noexcept
|
||||
{
|
||||
static_assert(std::is_integral<T>::value, "Integral required.");
|
||||
static_assert(std::is_integral_v<T>, "Integral required.");
|
||||
if (std::numeric_limits<T>::is_signed) {
|
||||
if (i > 0) {
|
||||
if (j > 0) {
|
||||
|
||||
Reference in New Issue
Block a user