summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
31d0b7f)
The C++17 variable templates are slightly more readable and allow us to
remove the typename keyword in a few cases.
closes https://github.com/official-stockfish/Stockfish/pull/4806
No functional change
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <cstdint>
#include <cstdlib>
#include <limits>
+#include <type_traits> // IWYU pragma: keep
#include "movegen.h"
#include "types.h"
#include "movegen.h"
#include "types.h"
void fill(const T& v) {
// For standard-layout 'this' points to first struct member
void fill(const T& v) {
// For standard-layout 'this' points to first struct member
- assert(std::is_standard_layout<stats>::value);
+ assert(std::is_standard_layout_v<stats>);
using entry = StatsEntry<T, D>;
entry* p = reinterpret_cast<entry*>(this);
using entry = StatsEntry<T, D>;
entry* p = reinterpret_cast<entry*>(this);
else
{
std::uint8_t u[sizeof(IntType)];
else
{
std::uint8_t u[sizeof(IntType)];
- typename std::make_unsigned<IntType>::type v = 0;
+ std::make_unsigned_t<IntType> v = 0;
stream.read(reinterpret_cast<char*>(u), sizeof(IntType));
for (std::size_t i = 0; i < sizeof(IntType); ++i)
stream.read(reinterpret_cast<char*>(u), sizeof(IntType));
for (std::size_t i = 0; i < sizeof(IntType); ++i)
else
{
std::uint8_t u[sizeof(IntType)];
else
{
std::uint8_t u[sizeof(IntType)];
- typename std::make_unsigned<IntType>::type v = value;
+ std::make_unsigned_t<IntType> v = value;
std::size_t i = 0;
// if constexpr to silence the warning about shift by 8
std::size_t i = 0;
// if constexpr to silence the warning about shift by 8
template<typename T, int Half = sizeof(T) / 2, int End = sizeof(T) - 1>
inline void swap_endian(T& x)
{
template<typename T, int Half = sizeof(T) / 2, int End = sizeof(T) - 1>
inline void swap_endian(T& x)
{
- static_assert(std::is_unsigned<T>::value, "Argument of swap_endian not unsigned");
+ static_assert(std::is_unsigned_v<T>, "Argument of swap_endian not unsigned");
uint8_t tmp, *c = (uint8_t*)&x;
for (int i = 0; i < Half; ++i)
uint8_t tmp, *c = (uint8_t*)&x;
for (int i = 0; i < Half; ++i)
// first access, when the corresponding file is memory mapped.
template<TBType Type>
struct TBTable {
// first access, when the corresponding file is memory mapped.
template<TBType Type>
struct TBTable {
- using Ret = typename std::conditional<Type == WDL, WDLScore, int>::type;
+ using Ret = std::conditional_t<Type == WDL, WDLScore, int>;
static constexpr int Sides = Type == WDL ? 2 : 1;
static constexpr int Sides = Type == WDL ? 2 : 1;
#include <cstddef>
#include <memory>
#include <string>
#include <cstddef>
#include <memory>
#include <string>
+#include <type_traits> // IWYU pragma: keep
#include <utility>
#include <vector>
#include <utility>
#include <vector>
template<typename T>
struct Entry : public EntryBase {
template<typename T>
struct Entry : public EntryBase {
- static_assert(!std::is_const<T>::value, "Parameter cannot be const!");
+ static_assert(!std::is_const_v<T>, "Parameter cannot be const!");
- static_assert( std::is_same<T, int>::value
- || std::is_same<T, Value>::value
- || std::is_same<T, PostUpdate>::value, "Parameter type not supported!");
+ static_assert( std::is_same_v<T, int>
+ || std::is_same_v<T, Value>
+ || std::is_same_v<T, PostUpdate>, "Parameter type not supported!");
Entry(const std::string& n, T& v, const SetRange& r) : name(n), value(v), range(r) {}
void operator=(const Entry&) = delete; // Because 'value' is a reference
Entry(const std::string& n, T& v, const SetRange& r) : name(n), value(v), range(r) {}
void operator=(const Entry&) = delete; // Because 'value' is a reference