Skip to content

Commit 4cd95a2

Browse files
committed
refactor: modernize remaining outdated trait patterns
1 parent ab2b67f commit 4cd95a2

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/random.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class RandomMixin
334334

335335
/** Generate a uniform random duration in the range [0..max). Precondition: max.count() > 0 */
336336
template <StdChronoDuration Dur>
337-
Dur randrange(typename std::common_type_t<Dur> range) noexcept
337+
Dur randrange(std::common_type_t<Dur> range) noexcept
338338
// Having the compiler infer the template argument from the function argument
339339
// is dangerous, because the desired return value generally has a different
340340
// type than the function argument. So std::common_type is used to force the

src/randomenv.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ namespace {
7070
*/
7171
template<typename T>
7272
CSHA512& operator<<(CSHA512& hasher, const T& data) {
73-
static_assert(!std::is_same<std::decay_t<T>, char*>::value, "Calling operator<<(CSHA512, char*) is probably not what you want");
74-
static_assert(!std::is_same<std::decay_t<T>, unsigned char*>::value, "Calling operator<<(CSHA512, unsigned char*) is probably not what you want");
75-
static_assert(!std::is_same<std::decay_t<T>, const char*>::value, "Calling operator<<(CSHA512, const char*) is probably not what you want");
76-
static_assert(!std::is_same<std::decay_t<T>, const unsigned char*>::value, "Calling operator<<(CSHA512, const unsigned char*) is probably not what you want");
73+
static_assert(!std::is_same_v<std::decay_t<T>, char*>, "Calling operator<<(CSHA512, char*) is probably not what you want");
74+
static_assert(!std::is_same_v<std::decay_t<T>, unsigned char*>, "Calling operator<<(CSHA512, unsigned char*) is probably not what you want");
75+
static_assert(!std::is_same_v<std::decay_t<T>, const char*>, "Calling operator<<(CSHA512, const char*) is probably not what you want");
76+
static_assert(!std::is_same_v<std::decay_t<T>, const unsigned char*>, "Calling operator<<(CSHA512, const unsigned char*) is probably not what you want");
7777
hasher.Write((const unsigned char*)&data, sizeof(data));
7878
return hasher;
7979
}

src/serialize.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,13 @@ const Out& AsBase(const In& x)
220220
template <typename Stream> \
221221
void Serialize(Stream& s) const \
222222
{ \
223-
static_assert(std::is_same_v<const cls&, decltype(*this)>, "Serialize type mismatch"); \
223+
static_assert(std::is_same_v<const cls&, decltype(*this)>, "Serialize type mismatch"); \
224224
Ser(s, *this); \
225225
} \
226226
template <typename Stream> \
227227
void Unserialize(Stream& s) \
228228
{ \
229-
static_assert(std::is_same_v<cls&, decltype(*this)>, "Unserialize type mismatch"); \
229+
static_assert(std::is_same_v<cls&, decltype(*this)>, "Unserialize type mismatch"); \
230230
Unser(s, *this); \
231231
}
232232

@@ -507,12 +507,12 @@ struct VarIntFormatter
507507
{
508508
template<typename Stream, typename I> void Ser(Stream &s, I v)
509509
{
510-
WriteVarInt<Stream,Mode,std::remove_cv_t<I>>(s, v);
510+
WriteVarInt<Stream,Mode, std::remove_cv_t<I>>(s, v);
511511
}
512512

513513
template<typename Stream, typename I> void Unser(Stream& s, I& v)
514514
{
515-
v = ReadVarInt<Stream,Mode,std::remove_cv_t<I>>(s);
515+
v = ReadVarInt<Stream,Mode, std::remove_cv_t<I>>(s);
516516
}
517517
};
518518

@@ -545,7 +545,7 @@ struct CustomUintFormatter
545545

546546
template <typename Stream, typename I> void Unser(Stream& s, I& v)
547547
{
548-
using U = typename std::conditional<std::is_enum_v<I>, std::underlying_type<I>, std::common_type<I>>::type::type;
548+
using U = typename std::conditional_t<std::is_enum_v<I>, std::underlying_type<I>, std::common_type<I>>::type;
549549
static_assert(std::numeric_limits<U>::max() >= MAX && std::numeric_limits<U>::min() <= 0, "Assigned type too small");
550550
uint64_t raw = 0;
551551
if (BigEndian) {

src/test/fuzz/FuzzedDataProvider.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ template <typename T> T FuzzedDataProvider::ConsumeProbability() {
277277
// Use different integral types for different floating point types in order
278278
// to provide better density of the resulting values.
279279
using IntegralType =
280-
typename std::conditional<(sizeof(T) <= sizeof(uint32_t)), uint32_t,
281-
uint64_t>::type;
280+
typename std::conditional_t<(sizeof(T) <= sizeof(uint32_t)), uint32_t,
281+
uint64_t>;
282282

283283
T result = static_cast<T>(ConsumeIntegral<IntegralType>());
284284
result /= static_cast<T>(std::numeric_limits<IntegralType>::max());

0 commit comments

Comments
 (0)