misc: Replace type_traits.hh XX::value with XX_v.

Now that we're using c++17, the type_traits with a ::value member have
a _v alias which reduces verbosity. Or on other words

std::is_integral<T>::value

can be replaced with

std::is_integral_v<T>

Make this substitution throughout the code base. In places where gem5
introduced it's own similar templates, add a V alias, spelled
differently to match gem5's internal style.

gem5: :IsVarArgs<T>::value => gem5::IsVarArgsV<T>
Change-Id: I1d84ffc4a236ad699471569e7916ec17fe5f109a
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48604
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2021-07-26 17:03:30 -07:00
parent 8b53b8bcdf
commit b3b81196aa
45 changed files with 256 additions and 237 deletions

View File

@@ -57,7 +57,7 @@ namespace Gcn3ISA
template<typename T> T
readConstVal(int opIdx) const
{
panic_if(!std::is_integral<T>::value, "Constant values must "
panic_if(!std::is_integral_v<T>, "Constant values must "
"be an integer.\n");
T val(0);

View File

@@ -247,7 +247,7 @@ namespace Gcn3ISA
inline T
median(T val_0, T val_1, T val_2)
{
if (std::is_floating_point<T>::value) {
if (std::is_floating_point_v<T>) {
return std::fmax(std::fmin(val_0, val_1),
std::fmin(std::fmax(val_0, val_1), val_2));
} else {

View File

@@ -274,12 +274,12 @@ namespace Gcn3ISA
DataType ret_val = scRegData.rawData();
if (absMod) {
assert(std::is_floating_point<DataType>::value);
assert(std::is_floating_point_v<DataType>);
ret_val = std::fabs(ret_val);
}
if (negMod) {
assert(std::is_floating_point<DataType>::value);
assert(std::is_floating_point_v<DataType>);
ret_val = -ret_val;
}
@@ -289,12 +289,12 @@ namespace Gcn3ISA
DataType ret_val = vgpr[idx];
if (absMod) {
assert(std::is_floating_point<DataType>::value);
assert(std::is_floating_point_v<DataType>);
ret_val = std::fabs(ret_val);
}
if (negMod) {
assert(std::is_floating_point<DataType>::value);
assert(std::is_floating_point_v<DataType>);
ret_val = -ret_val;
}

View File

@@ -57,8 +57,8 @@ namespace VegaISA
template<typename T> T
readConstVal(int opIdx) const
{
panic_if(!std::is_integral<T>::value, "Constant values must "
"be an integer.\n");
panic_if(!std::is_integral_v<T>,
"Constant values must be an integer.");
T val(0);
if (isPosConstVal(opIdx)) {

View File

@@ -247,7 +247,7 @@ namespace VegaISA
inline T
median(T val_0, T val_1, T val_2)
{
if (std::is_floating_point<T>::value) {
if (std::is_floating_point_v<T>) {
return std::fmax(std::fmin(val_0, val_1),
std::fmin(std::fmax(val_0, val_1), val_2));
} else {

View File

@@ -274,12 +274,12 @@ namespace VegaISA
DataType ret_val = scRegData.rawData();
if (absMod) {
assert(std::is_floating_point<DataType>::value);
assert(std::is_floating_point_v<DataType>);
ret_val = std::fabs(ret_val);
}
if (negMod) {
assert(std::is_floating_point<DataType>::value);
assert(std::is_floating_point_v<DataType>);
ret_val = -ret_val;
}
@@ -289,12 +289,12 @@ namespace VegaISA
DataType ret_val = vgpr[idx];
if (absMod) {
assert(std::is_floating_point<DataType>::value);
assert(std::is_floating_point_v<DataType>);
ret_val = std::fabs(ret_val);
}
if (negMod) {
assert(std::is_floating_point<DataType>::value);
assert(std::is_floating_point_v<DataType>);
ret_val = -ret_val;
}

View File

@@ -82,14 +82,15 @@ struct IsAapcs32Composite : public std::false_type {};
template <typename T>
struct IsAapcs32Composite<T, typename std::enable_if_t<
(std::is_array<T>::value ||
std::is_class<T>::value ||
std::is_union<T>::value) &&
(std::is_array_v<T> || std::is_class_v<T> || std::is_union_v<T>) &&
// VarArgs is technically a composite type, but it's not a normal argument.
!IsVarArgs<T>::value
!IsVarArgsV<T>
>> : public std::true_type
{};
template <typename T>
constexpr bool IsAapcs32CompositeV = IsAapcs32Composite<T>::value;
// Homogeneous Aggregates
// These *should* be any aggregate type which has only one type of member, but
// we can't actually detect that or manipulate that with templates. Instead,
@@ -104,6 +105,10 @@ struct IsAapcs32HomogeneousAggregate : public std::false_type {};
template <typename E, size_t N>
struct IsAapcs32HomogeneousAggregate<E[N]> : public std::true_type {};
template <typename T>
constexpr bool IsAapcs32HomogeneousAggregateV =
IsAapcs32HomogeneousAggregate<T>::value;
struct Aapcs32ArgumentBase
{
template <typename T>
@@ -138,12 +143,12 @@ struct Aapcs32ArgumentBase
template <typename Integer>
struct Result<Aapcs32, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value && (sizeof(Integer) < sizeof(uint32_t))>>
std::is_integral_v<Integer> && (sizeof(Integer) < sizeof(uint32_t))>>
{
static void
store(ThreadContext *tc, const Integer &i)
{
uint32_t val = std::is_signed<Integer>::value ?
uint32_t val = std::is_signed_v<Integer> ?
sext<sizeof(Integer) * 8>(i) : i;
tc->setIntReg(ArmISA::INTREG_R0, val);
}
@@ -151,7 +156,7 @@ struct Result<Aapcs32, Integer, typename std::enable_if_t<
template <typename Integer>
struct Result<Aapcs32, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value && (sizeof(Integer) == sizeof(uint32_t))>>
std::is_integral_v<Integer> && (sizeof(Integer) == sizeof(uint32_t))>>
{
static void
store(ThreadContext *tc, const Integer &i)
@@ -162,7 +167,7 @@ struct Result<Aapcs32, Integer, typename std::enable_if_t<
template <typename Integer>
struct Result<Aapcs32, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value && (sizeof(Integer) == sizeof(uint64_t))>>
std::is_integral_v<Integer> && (sizeof(Integer) == sizeof(uint64_t))>>
{
static void
store(ThreadContext *tc, const Integer &i)
@@ -179,7 +184,7 @@ struct Result<Aapcs32, Integer, typename std::enable_if_t<
template <typename Integer>
struct Argument<Aapcs32, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value && (sizeof(Integer) <= sizeof(uint32_t))
std::is_integral_v<Integer> && (sizeof(Integer) <= sizeof(uint32_t))
>> : public Aapcs32ArgumentBase
{
static Integer
@@ -198,7 +203,7 @@ struct Argument<Aapcs32, Integer, typename std::enable_if_t<
template <typename Integer>
struct Argument<Aapcs32, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value && (sizeof(Integer) > sizeof(uint32_t))
std::is_integral_v<Integer> && (sizeof(Integer) > sizeof(uint32_t))
>> : public Aapcs32ArgumentBase
{
static Integer
@@ -234,7 +239,7 @@ struct Argument<Aapcs32, Integer, typename std::enable_if_t<
template <typename Float>
struct Result<Aapcs32, Float, typename std::enable_if_t<
std::is_floating_point<Float>::value>>
std::is_floating_point_v<Float>>>
{
static void
store(ThreadContext *tc, const Float &f, Aapcs32::State &state)
@@ -246,7 +251,7 @@ struct Result<Aapcs32, Float, typename std::enable_if_t<
template <typename Float>
struct Argument<Aapcs32, Float, typename std::enable_if_t<
std::is_floating_point<Float>::value>> : public Aapcs32ArgumentBase
std::is_floating_point_v<Float>>> : public Aapcs32ArgumentBase
{
static Float
get(ThreadContext *tc, Aapcs32::State &state)
@@ -268,7 +273,7 @@ struct Argument<Aapcs32, Float, typename std::enable_if_t<
template <typename Composite>
struct Result<Aapcs32, Composite, typename std::enable_if_t<
IsAapcs32Composite<Composite>::value>>
IsAapcs32CompositeV<Composite>>>
{
static void
store(ThreadContext *tc, const Composite &composite,
@@ -296,7 +301,7 @@ struct Result<Aapcs32, Composite, typename std::enable_if_t<
template <typename Composite>
struct Argument<Aapcs32, Composite, typename std::enable_if_t<
IsAapcs32Composite<Composite>::value>> :
IsAapcs32CompositeV<Composite>>> :
public Aapcs32ArgumentBase
{
static Composite
@@ -445,13 +450,12 @@ namespace guest_abi
template <typename Integer>
struct Result<Aapcs32Vfp, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value>> : public Result<Aapcs32, Integer>
std::is_integral_v<Integer>>> : public Result<Aapcs32, Integer>
{};
template <typename Integer>
struct Argument<Aapcs32Vfp, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value>> :
public Argument<Aapcs32, Integer>
std::is_integral_v<Integer>>> : public Argument<Aapcs32, Integer>
{};
@@ -461,7 +465,7 @@ struct Argument<Aapcs32Vfp, Integer, typename std::enable_if_t<
template <typename Float>
struct Result<Aapcs32Vfp, Float, typename std::enable_if_t<
std::is_floating_point<Float>::value>>
std::is_floating_point_v<Float>>>
{
static void
store(ThreadContext *tc, const Float &f, Aapcs32Vfp::State &state)
@@ -480,7 +484,7 @@ struct Result<Aapcs32Vfp, Float, typename std::enable_if_t<
template <typename Float>
struct Argument<Aapcs32Vfp, Float, typename std::enable_if_t<
std::is_floating_point<Float>::value>> : public Aapcs32ArgumentBase
std::is_floating_point_v<Float>>> : public Aapcs32ArgumentBase
{
static Float
get(ThreadContext *tc, Aapcs32Vfp::State &state)
@@ -511,15 +515,15 @@ struct Argument<Aapcs32Vfp, Float, typename std::enable_if_t<
template <typename Composite>
struct Result<Aapcs32Vfp, Composite, typename std::enable_if_t<
IsAapcs32Composite<Composite>::value &&
!IsAapcs32HomogeneousAggregate<Composite>::value>> :
IsAapcs32CompositeV<Composite> &&
!IsAapcs32HomogeneousAggregateV<Composite>>> :
public Result<Aapcs32, Composite>
{};
template <typename Composite>
struct Argument<Aapcs32Vfp, Composite, typename std::enable_if_t<
IsAapcs32Composite<Composite>::value &&
!IsAapcs32HomogeneousAggregate<Composite>::value>> :
IsAapcs32CompositeV<Composite> &&
!IsAapcs32HomogeneousAggregateV<Composite>>> :
public Argument<Aapcs32, Composite>
{};
@@ -536,7 +540,7 @@ struct Aapcs32ArrayType<E[N]> { using Type = E; };
template <typename HA>
struct Argument<Aapcs32Vfp, HA, typename std::enable_if_t<
IsAapcs32HomogeneousAggregate<HA>::value>> :
IsAapcs32HomogeneousAggregateV<HA>>> :
public Aapcs32ArgumentBase
{
static bool
@@ -544,7 +548,7 @@ struct Argument<Aapcs32Vfp, HA, typename std::enable_if_t<
{
using Elem = typename Aapcs32ArrayType<HA>::Type;
constexpr size_t Count = sizeof(HA) / sizeof(Elem);
return state.variadic || !std::is_floating_point<Elem>::value ||
return state.variadic || !std::is_floating_point_v<Elem> ||
Count > 4;
}
@@ -586,14 +590,14 @@ struct Argument<Aapcs32Vfp, HA, typename std::enable_if_t<
template <typename HA>
struct Result<Aapcs32Vfp, HA,
typename std::enable_if_t<IsAapcs32HomogeneousAggregate<HA>::value>>
typename std::enable_if_t<IsAapcs32HomogeneousAggregateV<HA>>>
{
static bool
useBaseABI(Aapcs32Vfp::State &state)
{
using Elem = typename Aapcs32ArrayType<HA>::Type;
constexpr size_t Count = sizeof(HA) / sizeof(Elem);
return state.variadic || !std::is_floating_point<Elem>::value ||
return state.variadic || !std::is_floating_point_v<Elem> ||
Count > 4;
}

View File

@@ -84,11 +84,14 @@ struct IsAapcs64ShortVector : public std::false_type {};
template <typename E, size_t N>
struct IsAapcs64ShortVector<E[N],
typename std::enable_if_t<
(std::is_integral<E>::value || std::is_floating_point<E>::value) &&
(std::is_integral_v<E> || std::is_floating_point_v<E>) &&
(sizeof(E) * N == 8 || sizeof(E) * N == 16)>> :
public std::true_type
{};
template <typename T>
constexpr bool IsAapcs64ShortVectorV = IsAapcs64ShortVector<T>::value;
/*
* Composite Types
*/
@@ -98,16 +101,17 @@ struct IsAapcs64Composite : public std::false_type {};
template <typename T>
struct IsAapcs64Composite<T, typename std::enable_if_t<
(std::is_array<T>::value ||
std::is_class<T>::value ||
std::is_union<T>::value) &&
(std::is_array_v<T> || std::is_class_v<T> || std::is_union_v<T>) &&
// VarArgs is technically a composite type, but it's not a normal argument.
!IsVarArgs<T>::value &&
!IsVarArgsV<T> &&
// Short vectors are also composite types, but don't treat them as one.
!IsAapcs64ShortVector<T>::value
!IsAapcs64ShortVectorV<T>
>> : public std::true_type
{};
template <typename T>
constexpr bool IsAapcs64CompositeV = IsAapcs64Composite<T>::value;
// Homogeneous Aggregates
// These *should* be any aggregate type which has only one type of member, but
// we can't actually detect that or manipulate that with templates. Instead,
@@ -122,10 +126,13 @@ struct IsAapcs64Hfa : public std::false_type {};
template <typename E, size_t N>
struct IsAapcs64Hfa<E[N],
typename std::enable_if_t<std::is_floating_point<E>::value && N <= 4>> :
typename std::enable_if_t<std::is_floating_point_v<E> && N <= 4>> :
public std::true_type
{};
template <typename T>
constexpr bool IsAapcs64HfaV = IsAapcs64Hfa<T>::value;
// An Homogeneous Short-Vector Aggregate (HVA) is an Homogeneous Aggregate with
// a Fundamental Data Type that is a Short-Vector type and at most four
// uniquely addressable members.
@@ -135,20 +142,26 @@ struct IsAapcs64Hva : public std::false_type {};
template <typename E, size_t N>
struct IsAapcs64Hva<E[N],
typename std::enable_if_t<IsAapcs64ShortVector<E>::value && N <= 4>> :
typename std::enable_if_t<IsAapcs64ShortVectorV<E> && N <= 4>> :
public std::true_type
{};
template <typename T>
constexpr bool IsAapcs64HvaV = IsAapcs64Hva<T>::value;
// A shorthand to test if a type is an HVA or an HFA.
template <typename T, typename Enabled=void>
struct IsAapcs64Hxa : public std::false_type {};
template <typename T>
struct IsAapcs64Hxa<T, typename std::enable_if_t<
IsAapcs64Hfa<T>::value || IsAapcs64Hva<T>::value>> :
IsAapcs64HfaV<T> || IsAapcs64HvaV<T>>> :
public std::true_type
{};
template <typename T>
constexpr bool IsAapcs64HxaV = IsAapcs64Hxa<T>::value;
struct Aapcs64ArgumentBase
{
template <typename T>
@@ -181,8 +194,7 @@ struct Aapcs64ArgumentBase
template <typename Float>
struct Argument<Aapcs64, Float, typename std::enable_if_t<
std::is_floating_point<Float>::value ||
IsAapcs64ShortVector<Float>::value>> :
std::is_floating_point_v<Float> || IsAapcs64ShortVectorV<Float>>> :
public Aapcs64ArgumentBase
{
static Float
@@ -199,8 +211,7 @@ struct Argument<Aapcs64, Float, typename std::enable_if_t<
template <typename Float>
struct Result<Aapcs64, Float, typename std::enable_if_t<
std::is_floating_point<Float>::value ||
IsAapcs64ShortVector<Float>::value>>
std::is_floating_point_v<Float> || IsAapcs64ShortVectorV<Float>>>
{
static void
store(ThreadContext *tc, const Float &f)
@@ -220,7 +231,7 @@ struct Result<Aapcs64, Float, typename std::enable_if_t<
// This will pick up Addr as well, which should be used for guest pointers.
template <typename Integer>
struct Argument<Aapcs64, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value && (sizeof(Integer) <= 8)>> :
std::is_integral_v<Integer> && (sizeof(Integer) <= 8)>> :
public Aapcs64ArgumentBase
{
static Integer
@@ -238,7 +249,7 @@ struct Argument<Aapcs64, Integer, typename std::enable_if_t<
template <typename Integer>
struct Argument<Aapcs64, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value && (sizeof(Integer) > 8)>> :
std::is_integral_v<Integer> && (sizeof(Integer) > 8)>> :
public Aapcs64ArgumentBase
{
static Integer
@@ -263,7 +274,7 @@ struct Argument<Aapcs64, Integer, typename std::enable_if_t<
template <typename Integer>
struct Result<Aapcs64, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value && (sizeof(Integer) <= 8)>>
std::is_integral_v<Integer> && (sizeof(Integer) <= 8)>>
{
static void
store(ThreadContext *tc, const Integer &i)
@@ -274,7 +285,7 @@ struct Result<Aapcs64, Integer, typename std::enable_if_t<
template <typename Integer>
struct Result<Aapcs64, Integer, typename std::enable_if_t<
std::is_integral<Integer>::value && (sizeof(Integer) > 8)>>
std::is_integral_v<Integer> && (sizeof(Integer) > 8)>>
{
static void
store(ThreadContext *tc, const Integer &i)
@@ -298,7 +309,7 @@ struct Aapcs64ArrayType<E[N]> { using Type = E; };
template <typename HA>
struct Argument<Aapcs64, HA, typename std::enable_if_t<
IsAapcs64Hxa<HA>::value>> : public Aapcs64ArgumentBase
IsAapcs64HxaV<HA>>> : public Aapcs64ArgumentBase
{
static HA
get(ThreadContext *tc, Aapcs64::State &state)
@@ -321,8 +332,7 @@ struct Argument<Aapcs64, HA, typename std::enable_if_t<
};
template <typename HA>
struct Result<Aapcs64, HA,
typename std::enable_if_t<IsAapcs64Hxa<HA>::value>>
struct Result<Aapcs64, HA, typename std::enable_if_t<IsAapcs64HxaV<HA>>>
{
static HA
store(ThreadContext *tc, const HA &ha)
@@ -342,7 +352,7 @@ struct Result<Aapcs64, HA,
template <typename Composite>
struct Argument<Aapcs64, Composite, typename std::enable_if_t<
IsAapcs64Composite<Composite>::value && !IsAapcs64Hxa<Composite>::value>> :
IsAapcs64CompositeV<Composite> && !IsAapcs64HxaV<Composite>>> :
public Aapcs64ArgumentBase
{
static Composite
@@ -387,7 +397,7 @@ struct Argument<Aapcs64, Composite, typename std::enable_if_t<
template <typename Composite>
struct Result<Aapcs64, Composite, typename std::enable_if_t<
IsAapcs64Composite<Composite>::value && !IsAapcs64Hxa<Composite>::value>>
IsAapcs64CompositeV<Composite> && !IsAapcs64HxaV<Composite>>>
{
static void
store(ThreadContext *tc, const Composite &c)

View File

@@ -42,41 +42,41 @@ TEST(Aapcs64, IsAapcs64ShortVector)
using EightLongFloat = float[2];
using SixteenLongFloat = double[2];
EXPECT_FALSE(guest_abi::IsAapcs64ShortVector<Scalar>::value);
EXPECT_FALSE(guest_abi::IsAapcs64ShortVector<TooShort>::value);
EXPECT_FALSE(guest_abi::IsAapcs64ShortVector<TooLong>::value);
EXPECT_FALSE(guest_abi::IsAapcs64ShortVector<TooLongFloat>::value);
EXPECT_FALSE(guest_abi::IsAapcs64ShortVector<void>::value);
EXPECT_FALSE(guest_abi::IsAapcs64ShortVectorV<Scalar>);
EXPECT_FALSE(guest_abi::IsAapcs64ShortVectorV<TooShort>);
EXPECT_FALSE(guest_abi::IsAapcs64ShortVectorV<TooLong>);
EXPECT_FALSE(guest_abi::IsAapcs64ShortVectorV<TooLongFloat>);
EXPECT_FALSE(guest_abi::IsAapcs64ShortVectorV<void>);
EXPECT_TRUE(guest_abi::IsAapcs64ShortVector<EightLong>::value);
EXPECT_TRUE(guest_abi::IsAapcs64ShortVector<SixteenLong>::value);
EXPECT_TRUE(guest_abi::IsAapcs64ShortVector<EightLongFloat>::value);
EXPECT_TRUE(guest_abi::IsAapcs64ShortVector<SixteenLongFloat>::value);
EXPECT_TRUE(guest_abi::IsAapcs64ShortVectorV<EightLong>);
EXPECT_TRUE(guest_abi::IsAapcs64ShortVectorV<SixteenLong>);
EXPECT_TRUE(guest_abi::IsAapcs64ShortVectorV<EightLongFloat>);
EXPECT_TRUE(guest_abi::IsAapcs64ShortVectorV<SixteenLongFloat>);
}
TEST(Aapcs64, IsAapcs64Hfa)
{
// Accept floating point arrays with up to 4 members.
EXPECT_TRUE(guest_abi::IsAapcs64Hfa<float[1]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64Hfa<float[2]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64Hfa<float[3]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64Hfa<float[4]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64HfaV<float[1]>);
EXPECT_TRUE(guest_abi::IsAapcs64HfaV<float[2]>);
EXPECT_TRUE(guest_abi::IsAapcs64HfaV<float[3]>);
EXPECT_TRUE(guest_abi::IsAapcs64HfaV<float[4]>);
EXPECT_TRUE(guest_abi::IsAapcs64Hfa<double[1]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64Hfa<double[2]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64Hfa<double[3]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64Hfa<double[4]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64HfaV<double[1]>);
EXPECT_TRUE(guest_abi::IsAapcs64HfaV<double[2]>);
EXPECT_TRUE(guest_abi::IsAapcs64HfaV<double[3]>);
EXPECT_TRUE(guest_abi::IsAapcs64HfaV<double[4]>);
// Too many members.
EXPECT_FALSE(guest_abi::IsAapcs64Hfa<float[5]>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hfa<double[5]>::value);
EXPECT_FALSE(guest_abi::IsAapcs64HfaV<float[5]>);
EXPECT_FALSE(guest_abi::IsAapcs64HfaV<double[5]>);
// Wrong type of members, or not arrays.
EXPECT_FALSE(guest_abi::IsAapcs64Hfa<int32_t[3]>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hfa<float>::value);
EXPECT_FALSE(guest_abi::IsAapcs64HfaV<int32_t[3]>);
EXPECT_FALSE(guest_abi::IsAapcs64HfaV<float>);
struct Struct {};
EXPECT_FALSE(guest_abi::IsAapcs64Hfa<Struct>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hfa<void>::value);
EXPECT_FALSE(guest_abi::IsAapcs64HfaV<Struct>);
EXPECT_FALSE(guest_abi::IsAapcs64HfaV<void>);
}
TEST(Aapcs64, IsAapcs64Hva)
@@ -85,36 +85,36 @@ TEST(Aapcs64, IsAapcs64Hva)
using SvaTiny = uint8_t[16];
using SvaFloat = float[2];
EXPECT_TRUE(guest_abi::IsAapcs64Hva<SvaInt[3]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64Hva<SvaInt[4]>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hva<SvaInt[5]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64HvaV<SvaInt[3]>);
EXPECT_TRUE(guest_abi::IsAapcs64HvaV<SvaInt[4]>);
EXPECT_FALSE(guest_abi::IsAapcs64HvaV<SvaInt[5]>);
EXPECT_TRUE(guest_abi::IsAapcs64Hva<SvaFloat[3]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64Hva<SvaFloat[4]>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hva<SvaFloat[5]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64HvaV<SvaFloat[3]>);
EXPECT_TRUE(guest_abi::IsAapcs64HvaV<SvaFloat[4]>);
EXPECT_FALSE(guest_abi::IsAapcs64HvaV<SvaFloat[5]>);
EXPECT_TRUE(guest_abi::IsAapcs64Hva<SvaTiny[3]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64Hva<SvaTiny[4]>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hva<SvaTiny[5]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64HvaV<SvaTiny[3]>);
EXPECT_TRUE(guest_abi::IsAapcs64HvaV<SvaTiny[4]>);
EXPECT_FALSE(guest_abi::IsAapcs64HvaV<SvaTiny[5]>);
EXPECT_FALSE(guest_abi::IsAapcs64Hva<uint64_t>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hva<uint64_t[1]>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hva<SvaTiny>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hva<void>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hva<float>::value);
EXPECT_FALSE(guest_abi::IsAapcs64HvaV<uint64_t>);
EXPECT_FALSE(guest_abi::IsAapcs64HvaV<uint64_t[1]>);
EXPECT_FALSE(guest_abi::IsAapcs64HvaV<SvaTiny>);
EXPECT_FALSE(guest_abi::IsAapcs64HvaV<void>);
EXPECT_FALSE(guest_abi::IsAapcs64HvaV<float>);
}
TEST(Aapcs64, IsAapcs64Hxa)
{
using SvaInt = uint32_t[2];
EXPECT_TRUE(guest_abi::IsAapcs64Hxa<SvaInt[4]>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hxa<SvaInt[5]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64HxaV<SvaInt[4]>);
EXPECT_FALSE(guest_abi::IsAapcs64HxaV<SvaInt[5]>);
EXPECT_TRUE(guest_abi::IsAapcs64Hxa<float[4]>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hxa<float[5]>::value);
EXPECT_TRUE(guest_abi::IsAapcs64HxaV<float[4]>);
EXPECT_FALSE(guest_abi::IsAapcs64HxaV<float[5]>);
EXPECT_FALSE(guest_abi::IsAapcs64Hxa<SvaInt>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hxa<uint64_t>::value);
EXPECT_FALSE(guest_abi::IsAapcs64Hxa<void>::value);
EXPECT_FALSE(guest_abi::IsAapcs64HxaV<SvaInt>);
EXPECT_FALSE(guest_abi::IsAapcs64HxaV<uint64_t>);
EXPECT_FALSE(guest_abi::IsAapcs64HxaV<void>);
}

View File

@@ -73,8 +73,8 @@ namespace guest_abi
template <typename ABI>
struct Result<ABI, SyscallReturn,
typename std::enable_if_t<std::is_base_of<
ArmISA::EmuFreebsd::BaseSyscallABI, ABI>::value>>
typename std::enable_if_t<std::is_base_of_v<
ArmISA::EmuFreebsd::BaseSyscallABI, ABI>>>
{
static void
store(ThreadContext *tc, const SyscallReturn &ret)

View File

@@ -66,8 +66,8 @@ namespace guest_abi
template <typename ABI>
struct Result<ABI, SyscallReturn,
typename std::enable_if_t<std::is_base_of<
ArmISA::EmuLinux::BaseSyscallABI, ABI>::value>>
typename std::enable_if_t<std::is_base_of_v<
ArmISA::EmuLinux::BaseSyscallABI, ABI>>>
{
static void
store(ThreadContext *tc, const SyscallReturn &ret)

View File

@@ -58,9 +58,9 @@ namespace guest_abi
template <typename ABI, typename Arg>
struct Argument<ABI, Arg,
typename std::enable_if_t<
std::is_base_of<ArmISA::RegABI32, ABI>::value &&
std::is_integral<Arg>::value &&
ABI::template IsWide<Arg>::value>>
std::is_base_of_v<ArmISA::RegABI32, ABI> &&
std::is_integral_v<Arg> &&
ABI::template IsWideV<Arg>>>
{
static Arg
get(ThreadContext *tc, typename ABI::State &state)

View File

@@ -605,7 +605,7 @@ namespace guest_abi
template <typename Arg>
struct Argument<ArmSemihosting::Abi64, Arg,
typename std::enable_if_t<std::is_integral<Arg>::value>>
typename std::enable_if_t<std::is_integral_v<Arg>>>
{
static Arg
get(ThreadContext *tc, ArmSemihosting::Abi64::State &state)
@@ -616,12 +616,12 @@ struct Argument<ArmSemihosting::Abi64, Arg,
template <typename Arg>
struct Argument<ArmSemihosting::Abi32, Arg,
typename std::enable_if_t<std::is_integral<Arg>::value>>
typename std::enable_if_t<std::is_integral_v<Arg>>>
{
static Arg
get(ThreadContext *tc, ArmSemihosting::Abi32::State &state)
{
if (std::is_signed<Arg>::value)
if (std::is_signed_v<Arg>)
return sext<32>(state.get(tc));
else
return state.get(tc);
@@ -630,7 +630,7 @@ struct Argument<ArmSemihosting::Abi32, Arg,
template <typename Abi>
struct Argument<Abi, ArmSemihosting::InPlaceArg, typename std::enable_if_t<
std::is_base_of<ArmSemihosting::AbiBase, Abi>::value>>
std::is_base_of_v<ArmSemihosting::AbiBase, Abi>>>
{
static ArmSemihosting::InPlaceArg
get(ThreadContext *tc, typename Abi::State &state)

View File

@@ -83,8 +83,8 @@ namespace guest_abi
template <typename ABI>
struct Result<ABI, SyscallReturn,
typename std::enable_if_t<std::is_base_of<
SparcISA::SEWorkload::BaseSyscallABI, ABI>::value>>
typename std::enable_if_t<std::is_base_of_v<
SparcISA::SEWorkload::BaseSyscallABI, ABI>>>
{
static void
store(ThreadContext *tc, const SyscallReturn &ret)
@@ -118,8 +118,8 @@ struct Result<ABI, SyscallReturn,
template <typename Arg>
struct Argument<SparcISA::SEWorkload::SyscallABI32, Arg,
typename std::enable_if_t<
std::is_integral<Arg>::value &&
SparcISA::SEWorkload::SyscallABI32::IsWide<Arg>::value>>
std::is_integral_v<Arg> &&
SparcISA::SEWorkload::SyscallABI32::IsWideV<Arg>>>
{
using ABI = SparcISA::SEWorkload::SyscallABI32;

View File

@@ -107,7 +107,7 @@ class RSDP : public SimObject
uint8_t revision = 0;
uint32_t rsdtAddress = 0;
};
static_assert(std::is_trivially_copyable<MemR0>::value,
static_assert(std::is_trivially_copyable_v<MemR0>,
"Type not suitable for memcpy.");
struct GEM5_PACKED Mem : public MemR0
@@ -118,7 +118,7 @@ class RSDP : public SimObject
uint8_t extendedChecksum = 0;
uint8_t _reserved[3] = {};
};
static_assert(std::is_trivially_copyable<Mem>::value,
static_assert(std::is_trivially_copyable_v<Mem>,
"Type not suitable for memcpy,");
RSDT* rsdt;
@@ -148,7 +148,7 @@ class SysDescTable : public SimObject
uint32_t creatorID = 0;
uint32_t creatorRevision = 0;
};
static_assert(std::is_trivially_copyable<Mem>::value,
static_assert(std::is_trivially_copyable_v<Mem>,
"Type not suitable for memcpy.");
virtual Addr writeBuf(PortProxy& phys_proxy, Allocator& alloc,
@@ -215,7 +215,7 @@ class Record : public SimObject
uint8_t type = 0;
uint8_t length = 0;
};
static_assert(std::is_trivially_copyable<Mem>::value,
static_assert(std::is_trivially_copyable_v<Mem>,
"Type not suitable for memcpy.");
uint8_t type;
@@ -245,7 +245,7 @@ class LAPIC : public Record
uint8_t apicId = 0;
uint32_t flags = 0;
};
static_assert(std::is_trivially_copyable<Mem>::value,
static_assert(std::is_trivially_copyable_v<Mem>,
"Type not suitable for memcpy.");
void prepareBuf(std::vector<uint8_t>& mem) const override;
@@ -266,7 +266,7 @@ class IOAPIC : public Record
uint32_t ioApicAddress = 0;
uint32_t intBase = 0;
};
static_assert(std::is_trivially_copyable<Mem>::value,
static_assert(std::is_trivially_copyable_v<Mem>,
"Type not suitable for memcpy.");
void prepareBuf(std::vector<uint8_t>& mem) const override;
@@ -287,7 +287,7 @@ class IntSourceOverride : public Record
uint32_t globalSystemInterrupt = 0;
uint16_t flags = 0;
};
static_assert(std::is_trivially_copyable<Mem>::value,
static_assert(std::is_trivially_copyable_v<Mem>,
"Type not suitable for memcpy.");
void prepareBuf(std::vector<uint8_t>& mem) const override;
@@ -307,7 +307,7 @@ class NMI : public Record
uint16_t flags = 0;
uint8_t lintNo = 0;
};
static_assert(std::is_trivially_copyable<Mem>::value,
static_assert(std::is_trivially_copyable_v<Mem>,
"Type not suitable for memcpy.");
void prepareBuf(std::vector<uint8_t>& mem) const override;
@@ -326,7 +326,7 @@ class LAPICOverride : public Record
uint16_t _reserved = 0;
uint64_t localAPICAddress = 0;
};
static_assert(std::is_trivially_copyable<Mem>::value,
static_assert(std::is_trivially_copyable_v<Mem>,
"Type not suitable for memcpy.");
void prepareBuf(std::vector<uint8_t>& mem) const override;
@@ -345,7 +345,7 @@ class MADT : public SysDescTable
uint32_t localAPICAddress = 0;
uint32_t flags = 0;
};
static_assert(std::is_trivially_copyable<Mem>::value,
static_assert(std::is_trivially_copyable_v<Mem>,
"Type not suitable for memcpy.");
std::vector<Record *> records;

View File

@@ -81,8 +81,7 @@ namespace guest_abi
template <typename ABI>
struct Result<ABI, SyscallReturn,
typename std::enable_if_t<std::is_base_of<
X86Linux::SyscallABI, ABI>::value>>
typename std::enable_if_t<std::is_base_of_v<X86Linux::SyscallABI, ABI>>>
{
static void
store(ThreadContext *tc, const SyscallReturn &ret)

View File

@@ -99,8 +99,8 @@ namespace guest_abi
template <typename Arg>
struct Argument<X86ISA::EmuLinux::SyscallABI32, Arg,
typename std::enable_if_t<std::is_integral<Arg>::value &&
X86ISA::EmuLinux::SyscallABI32::IsWide<Arg>::value>>
typename std::enable_if_t<std::is_integral_v<Arg> &&
X86ISA::EmuLinux::SyscallABI32::IsWideV<Arg>>>
{
using ABI = X86ISA::EmuLinux::SyscallABI32;

View File

@@ -56,8 +56,7 @@ namespace gem5
template<class Base>
class BitfieldTypeImpl : public Base
{
static_assert(std::is_empty<Base>::value,
"Bitfield base class must be empty.");
static_assert(std::is_empty_v<Base>, "Bitfield base class must be empty.");
private:

View File

@@ -264,9 +264,9 @@ TEST_F(BitUnionData, Templating)
EndBitUnion(Dummy32);
bool is64;
is64 = std::is_same<BitUnionBaseType<Dummy64>, uint64_t>::value;
is64 = std::is_same_v<BitUnionBaseType<Dummy64>, uint64_t>;
EXPECT_TRUE(is64);
is64 = std::is_same<BitUnionBaseType<Dummy32>, uint64_t>::value;
is64 = std::is_same_v<BitUnionBaseType<Dummy32>, uint64_t>;
EXPECT_FALSE(is64);
}

View File

@@ -112,7 +112,7 @@ class CircularQueue
/** Trait reference type
* iterator satisfies OutputIterator, therefore reference
* must be T& */
static_assert(std::is_same<reference, T&>::value,
static_assert(std::is_same_v<reference, T&>,
"reference type is not assignable as required");
/**
@@ -348,7 +348,7 @@ class CircularQueue
* @ingroup api_base_utils
*/
template<typename Idx>
typename std::enable_if_t<std::is_integral<Idx>::value, reference>
typename std::enable_if_t<std::is_integral_v<Idx>, reference>
operator[](const Idx& index)
{
return *(*this + index);
@@ -391,7 +391,7 @@ class CircularQueue
* @ingroup api_base_utils
*/
template <typename Idx>
typename std::enable_if_t<std::is_integral<Idx>::value, reference>
typename std::enable_if_t<std::is_integral_v<Idx>, reference>
operator[](const Idx& index)
{
assert(index >= 0);
@@ -399,7 +399,7 @@ class CircularQueue
}
template <typename Idx>
typename std::enable_if_t<std::is_integral<Idx>::value, const_reference>
typename std::enable_if_t<std::is_integral_v<Idx>, const_reference>
operator[](const Idx& index) const
{
assert(index >= 0);

View File

@@ -69,10 +69,10 @@ class Coroutine : public Fiber
// are void. (See following ArgChannel, RetChannel typedef)
struct Empty {};
using ArgChannel = typename std::conditional_t<
std::is_same<Arg, void>::value, Empty, std::stack<Arg>>;
std::is_same_v<Arg, void>, Empty, std::stack<Arg>>;
using RetChannel = typename std::conditional_t<
std::is_same<Ret, void>::value, Empty, std::stack<Ret>>;
std::is_same_v<Ret, void>, Empty, std::stack<Ret>>;
public:
/**
@@ -101,7 +101,7 @@ class Coroutine : public Fiber
template <typename T = Ret>
CallerType&
operator()(typename std::enable_if_t<
!std::is_same<T, void>::value, T> param)
!std::is_same_v<T, void>, T> param)
{
retChannel.push(param);
callerFiber->run();
@@ -117,7 +117,7 @@ class Coroutine : public Fiber
* @ingroup api_coroutine
*/
template <typename T = Ret>
typename std::enable_if_t<std::is_same<T, void>::value,
typename std::enable_if_t<std::is_same_v<T, void>,
CallerType> &
operator()()
{
@@ -138,7 +138,7 @@ class Coroutine : public Fiber
* @ingroup api_coroutine
*/
template <typename T = Arg>
typename std::enable_if_t<!std::is_same<T, void>::value, T>
typename std::enable_if_t<!std::is_same_v<T, void>, T>
get()
{
auto& args_channel = coro.argsChannel;
@@ -210,8 +210,7 @@ class Coroutine : public Fiber
*/
template <typename T = Arg>
Coroutine&
operator()(typename std::enable_if_t<
!std::is_same<T, void>::value, T> param)
operator()(typename std::enable_if_t<!std::is_same_v<T, void>, T> param)
{
argsChannel.push(param);
this->call();
@@ -227,7 +226,7 @@ class Coroutine : public Fiber
* @ingroup api_coroutine
*/
template <typename T = Arg>
typename std::enable_if_t<std::is_same<T, void>::value, Coroutine> &
typename std::enable_if_t<std::is_same_v<T, void>, Coroutine> &
operator()()
{
this->call();
@@ -247,7 +246,7 @@ class Coroutine : public Fiber
* @ingroup api_coroutine
*/
template <typename T = Ret>
typename std::enable_if_t<!std::is_same<T, void>::value, T>
typename std::enable_if_t<!std::is_same_v<T, void>, T>
get()
{
auto& ret_channel = caller.retChannel;

View File

@@ -44,7 +44,7 @@ template <typename T>
class Flags
{
private:
static_assert(std::is_unsigned<T>::value, "Flag type must be unsigned");
static_assert(std::is_unsigned_v<T>, "Flag type must be unsigned");
/** The undelying container of the flags' bits. */
T _flags;

View File

@@ -55,7 +55,7 @@ namespace gem5
* @ingroup api_base_utils
*/
template <class T>
static constexpr std::enable_if_t<std::is_integral<T>::value, int>
static constexpr std::enable_if_t<std::is_integral_v<T>, int>
floorLog2(T x)
{
assert(x > 0);

View File

@@ -86,7 +86,7 @@ class Random : public Serializable
* @ingroup api_base_utils
*/
template <typename T>
typename std::enable_if_t<std::is_integral<T>::value, T>
typename std::enable_if_t<std::is_integral_v<T>, T>
random()
{
// [0, max_value] for integer types
@@ -98,7 +98,7 @@ class Random : public Serializable
* @ingroup api_base_utils
*/
template <typename T>
typename std::enable_if_t<std::is_floating_point<T>::value, T>
typename std::enable_if_t<std::is_floating_point_v<T>, T>
random()
{
// [0, 1) for real types
@@ -109,7 +109,7 @@ class Random : public Serializable
* @ingroup api_base_utils
*/
template <typename T>
typename std::enable_if_t<std::is_integral<T>::value, T>
typename std::enable_if_t<std::is_integral_v<T>, T>
random(T min, T max)
{
std::uniform_int_distribution<T> dist(min, max);

View File

@@ -131,7 +131,7 @@ class RefCountingPtr
protected:
/** Convenience aliases for const/non-const versions of T w/ friendship. */
/** @{ */
static constexpr auto TisConst = std::is_const<T>::value;
static constexpr auto TisConst = std::is_const_v<T>;
using ConstT = typename std::conditional_t<TisConst,
RefCountingPtr<T>,
RefCountingPtr<typename std::add_const<T>::type>>;

View File

@@ -675,8 +675,8 @@ class FunctorProxy : public ProxyInfo
*/
template <class T>
class FunctorProxy<T,
typename std::enable_if_t<std::is_constructible<std::function<Result()>,
const T &>::value>> : public ProxyInfo
typename std::enable_if_t<std::is_constructible_v<std::function<Result()>,
const T &>>> : public ProxyInfo
{
private:
std::function<Result()> functor;

View File

@@ -342,12 +342,12 @@ class Unspecified : public Base
template <typename T1, typename T2>
class Rate : public Base
{
static_assert(std::is_base_of<Base, T1>::value, "Rate(T1,T2) must have "
static_assert(std::is_base_of_v<Base, T1>, "Rate(T1,T2) must have "
"T1 and T2 derived from statistics::units::Base");
static_assert(std::is_base_of<Base, T2>::value, "Rate(T1,T2) must have "
static_assert(std::is_base_of_v<Base, T2>, "Rate(T1,T2) must have "
"T1 and T2 derived from statistics::units::Base");
static_assert(!std::is_same<T1, T2>::value ||
std::is_same<T1, Count>::value || std::is_same<T1, Unspecified>::value,
static_assert(!std::is_same_v<T1, T2> || std::is_same_v<T1, Count> ||
std::is_same_v<T1, Unspecified>,
"Rate(T1,T2) must have T1 and T2 of different types; "
"otherwise, it would be a Ratio");

View File

@@ -49,6 +49,9 @@ struct IsHelpedContainer : public std::false_type {};
template <typename ...Types>
struct IsHelpedContainer<std::vector<Types...>> : public std::true_type {};
template <typename ...Types>
constexpr bool IsHelpedContainerV = IsHelpedContainer<Types...>::value;
/**
* Write out all elements in an stl container as a space separated
* list enclosed in square brackets
@@ -57,7 +60,7 @@ struct IsHelpedContainer<std::vector<Types...>> : public std::true_type {};
*/
template <typename T>
std::enable_if_t<IsHelpedContainer<T>::value, std::ostream &>
std::enable_if_t<IsHelpedContainerV<T>, std::ostream &>
operator<<(std::ostream& out, const T &t)
{
out << "[ ";

View File

@@ -136,7 +136,7 @@ __to_number(const std::string &value)
}
template <class T>
typename std::enable_if_t<std::is_enum<T>::value, T>
typename std::enable_if_t<std::is_enum_v<T>, T>
__to_number(const std::string &value)
{
auto r = __to_number<typename std::underlying_type_t<T>>(value);
@@ -144,7 +144,7 @@ __to_number(const std::string &value)
}
template <class T>
typename std::enable_if_t<std::is_floating_point<T>::value, T>
typename std::enable_if_t<std::is_floating_point_v<T>, T>
__to_number(const std::string &value)
{
// start big and narrow it down if needed
@@ -166,10 +166,10 @@ __to_number(const std::string &value)
* @return True if the parsing was successful
*/
template <class T>
inline std::enable_if_t<(std::is_integral<T>::value ||
std::is_floating_point<T>::value ||
std::is_enum<T>::value) &&
!std::is_same<bool, T>::value, bool>
inline std::enable_if_t<(std::is_integral_v<T> ||
std::is_floating_point_v<T> ||
std::is_enum_v<T>) &&
!std::is_same_v<bool, T>, bool>
to_number(const std::string &value, T &retval)
{
try {

View File

@@ -54,8 +54,7 @@ template <class Key, class Value>
class Trie
{
protected:
static_assert(std::is_integral<Key>::value,
"Key has to be an integral type");
static_assert(std::is_integral_v<Key>, "Key has to be an integral type");
struct Node
{

View File

@@ -80,12 +80,11 @@ class InstResult
/** Scalar result from scalar. */
template<typename T>
explicit InstResult(T i, const ResultType& t) : type(t) {
static_assert(std::is_integral<T>::value ^
std::is_floating_point<T>::value,
static_assert(std::is_integral_v<T> ^ std::is_floating_point_v<T>,
"Parameter type is neither integral nor fp, or it is both");
if (std::is_integral<T>::value) {
if (std::is_integral_v<T>) {
result.integer = i;
} else if (std::is_floating_point<T>::value) {
} else if (std::is_floating_point_v<T>) {
result.dbl = i;
}
}

View File

@@ -943,8 +943,8 @@ using RegisterBankBE = RegisterBank<ByteOrder::big>;
// Delegate serialization to the individual RegisterBase subclasses.
template <class T>
struct ParseParam<T, std::enable_if_t<std::is_base_of<
typename RegisterBankBase::RegisterBaseBase, T>::value>>
struct ParseParam<T, std::enable_if_t<std::is_base_of_v<
typename RegisterBankBase::RegisterBaseBase, T>>>
{
static bool
parse(const std::string &s, T &value)
@@ -954,8 +954,8 @@ struct ParseParam<T, std::enable_if_t<std::is_base_of<
};
template <class T>
struct ShowParam<T, std::enable_if_t<std::is_base_of<
typename RegisterBankBase::RegisterBaseBase, T>::value>>
struct ShowParam<T, std::enable_if_t<std::is_base_of_v<
typename RegisterBankBase::RegisterBaseBase, T>>>
{
static void
show(std::ostream &os, const T &value)

View File

@@ -72,7 +72,7 @@ class VirtQueue;
*/
template <typename T>
inline std::enable_if_t<std::is_same<T, vring_used_elem>::value, T>
inline std::enable_if_t<std::is_same_v<T, vring_used_elem>, T>
swap_byte(T v)
{
v.id = swap_byte(v.id);
@@ -81,7 +81,7 @@ swap_byte(T v)
}
template <typename T>
inline std::enable_if_t<std::is_same<T, vring_desc>::value, T>
inline std::enable_if_t<std::is_same_v<T, vring_desc>, T>
swap_byte(T v)
{
v.addr = swap_byte(v.addr);

View File

@@ -179,7 +179,7 @@ class DictionaryCompressor : public BaseDictionaryCompressor
template <class Head>
struct Factory<Head>
{
static_assert(std::is_base_of<UncompressedPattern, Head>::value,
static_assert(std::is_base_of_v<UncompressedPattern, Head>,
"The last pattern must always be derived from the uncompressed "
"pattern.");

View File

@@ -44,7 +44,7 @@ namespace gem5
template<class Entry>
class AssociativeSet
{
static_assert(std::is_base_of<TaggedEntry, Entry>::value,
static_assert(std::is_base_of_v<TaggedEntry, Entry>,
"Entry must derive from TaggedEntry");
/** Associativity of the container */

View File

@@ -69,7 +69,7 @@ namespace gem5
template<class Entry>
class Queue : public Drainable, public Named
{
static_assert(std::is_base_of<QueueEntry, Entry>::value,
static_assert(std::is_base_of_v<QueueEntry, Entry>,
"Entry must be derived from QueueEntry");
protected:

View File

@@ -854,8 +854,8 @@ module_init(py::module_ &m_internal)
# constructor.
code('template <class CxxClass>')
code('class Dummy${cls}Shunt<CxxClass, std::enable_if_t<')
code(' std::is_constructible<CxxClass,')
code(' const ${cls}Params &>::value>>')
code(' std::is_constructible_v<CxxClass,')
code(' const ${cls}Params &>>>')
code('{')
code(' public:')
code(' using Params = ${cls}Params;')
@@ -871,8 +871,8 @@ module_init(py::module_ &m_internal)
# not exist.
code('template <class CxxClass>')
code('class Dummy${cls}Shunt<CxxClass, std::enable_if_t<')
code(' !std::is_constructible<CxxClass,')
code(' const ${cls}Params &>::value>>')
code(' !std::is_constructible_v<CxxClass,')
code(' const ${cls}Params &>>>')
code('{')
code(' public:')
code(' using Params = Dummy${cls}ParamsClass;')

View File

@@ -112,7 +112,7 @@ swap_byte16(uint16_t x)
template <typename T>
inline std::enable_if_t<
sizeof(T) == 8 && std::is_convertible<T, uint64_t>::value, T>
sizeof(T) == 8 && std::is_convertible_v<T, uint64_t>, T>
swap_byte(T x)
{
return swap_byte64((uint64_t)x);
@@ -120,7 +120,7 @@ swap_byte(T x)
template <typename T>
inline std::enable_if_t<
sizeof(T) == 4 && std::is_convertible<T, uint32_t>::value, T>
sizeof(T) == 4 && std::is_convertible_v<T, uint32_t>, T>
swap_byte(T x)
{
return swap_byte32((uint32_t)x);
@@ -128,7 +128,7 @@ swap_byte(T x)
template <typename T>
inline std::enable_if_t<
sizeof(T) == 2 && std::is_convertible<T, uint16_t>::value, T>
sizeof(T) == 2 && std::is_convertible_v<T, uint16_t>, T>
swap_byte(T x)
{
return swap_byte16((uint16_t)x);
@@ -136,7 +136,7 @@ swap_byte(T x)
template <typename T>
inline std::enable_if_t<
sizeof(T) == 1 && std::is_convertible<T, uint8_t>::value, T>
sizeof(T) == 1 && std::is_convertible_v<T, uint8_t>, T>
swap_byte(T x)
{
return x;
@@ -145,10 +145,10 @@ swap_byte(T x)
// Make the function visible in case we need to declare a version of it for
// other types
template <typename T>
std::enable_if_t<std::is_same<T, vring_used_elem>::value, T>
std::enable_if_t<std::is_same_v<T, vring_used_elem>, T>
swap_byte(T v);
template <typename T>
std::enable_if_t<std::is_same<T, vring_desc>::value, T>
std::enable_if_t<std::is_same_v<T, vring_desc>, T>
swap_byte(T v);
template <typename T, size_t N>

View File

@@ -116,7 +116,7 @@ struct Argument<TestABI_1D, int>
template <typename Arg>
struct Argument<TestABI_1D, Arg,
typename std::enable_if_t<std::is_floating_point<Arg>::value>>
typename std::enable_if_t<std::is_floating_point_v<Arg>>>
{
static Arg
get(ThreadContext *tc, TestABI_1D::State &state)
@@ -137,7 +137,7 @@ struct Result<TestABI_1D, int>
template <typename Ret>
struct Result<TestABI_1D, Ret,
typename std::enable_if_t<std::is_floating_point<Ret>::value>>
typename std::enable_if_t<std::is_floating_point_v<Ret>>>
{
static void
store(ThreadContext *tc, const Ret &ret)
@@ -191,7 +191,7 @@ struct Argument<TestABI_2D, int>
template <typename Arg>
struct Argument<TestABI_2D, Arg,
typename std::enable_if_t<std::is_floating_point<Arg>::value>>
typename std::enable_if_t<std::is_floating_point_v<Arg>>>
{
static Arg
get(ThreadContext *tc, TestABI_2D::State &state)
@@ -212,7 +212,7 @@ struct Result<TestABI_2D, int>
template <typename Ret>
struct Result<TestABI_2D, Ret,
typename std::enable_if_t<std::is_floating_point<Ret>::value>>
typename std::enable_if_t<std::is_floating_point_v<Ret>>>
{
static void
store(ThreadContext *tc, const Ret &ret)
@@ -399,11 +399,11 @@ TEST(GuestABITest, dumpSimcall)
TEST(GuestABITest, isVarArgs)
{
EXPECT_TRUE(guest_abi::IsVarArgs<guest_abi::VarArgs<int>>::value);
EXPECT_FALSE(guest_abi::IsVarArgs<int>::value);
EXPECT_FALSE(guest_abi::IsVarArgs<double>::value);
EXPECT_TRUE(guest_abi::IsVarArgsV<guest_abi::VarArgs<int>>);
EXPECT_FALSE(guest_abi::IsVarArgsV<int>);
EXPECT_FALSE(guest_abi::IsVarArgsV<double>);
struct FooStruct {};
EXPECT_FALSE(guest_abi::IsVarArgs<FooStruct>::value);
EXPECT_FALSE(guest_abi::IsVarArgsV<FooStruct>);
union FooUnion {};
EXPECT_FALSE(guest_abi::IsVarArgs<FooUnion>::value);
EXPECT_FALSE(guest_abi::IsVarArgsV<FooUnion>);
}

View File

@@ -58,7 +58,7 @@ struct StateInitializer
template <typename ABI>
struct StateInitializer<ABI, typename std::enable_if_t<
std::is_constructible<typename ABI::State, const ThreadContext *>::value>>
std::is_constructible_v<typename ABI::State, const ThreadContext *>>>
{
static typename ABI::State
init(const ThreadContext *tc)
@@ -144,8 +144,9 @@ struct ResultStorer
template <typename ABI, typename Ret>
struct ResultStorer<ABI, Ret, typename std::enable_if_t<
std::is_same<void (*)(ThreadContext *, const Ret &, typename ABI::State &),
decltype(&Result<ABI, Ret>::store)>::value>>
std::is_same_v<void (*)(ThreadContext *, const Ret &,
typename ABI::State &),
decltype(&Result<ABI, Ret>::store)>>>
{
static void
store(ThreadContext *tc, const Ret &ret, typename ABI::State &state)

View File

@@ -176,6 +176,9 @@ struct IsVarArgs : public std::false_type {};
template <typename ...Types>
struct IsVarArgs<VarArgs<Types...>> : public std::true_type {};
template <typename T>
constexpr bool IsVarArgsV = IsVarArgs<T>::value;
template <typename ...Types>
std::ostream &
operator << (std::ostream &os, const VarArgs<Types...> &va)

View File

@@ -137,16 +137,16 @@ class ConstProxyPtr
using Type = T;
template <typename ...Args,
typename std::enable_if_t<std::is_constructible<
Proxy, Args&&...>::value, int> = 0>
typename std::enable_if_t<std::is_constructible_v<
Proxy, Args&&...>, int> = 0>
explicit ConstProxyPtr(Addr _ptr, Args&&... args) :
proxy(std::make_shared<Proxy>(args...))
{
setAddr(_ptr);
}
template <typename ...Args,
typename std::enable_if_t<std::is_constructible<
Proxy, Args&&...>::value, int> = 0>
typename std::enable_if_t<std::is_constructible_v<
Proxy, Args&&...>, int> = 0>
explicit ConstProxyPtr(Args&&... args) :
proxy(std::make_shared<Proxy>(args...))
{
@@ -154,7 +154,7 @@ class ConstProxyPtr
}
template <typename O, typename Enabled=
typename std::enable_if_t<std::is_assignable<T *, O *>::value>>
typename std::enable_if_t<std::is_assignable_v<T *, O *>>>
ConstProxyPtr(const ConstProxyPtr<O, Proxy> &other) :
proxy(other.proxy), buffer(other.buffer)
{}
@@ -174,14 +174,14 @@ class ConstProxyPtr
operator bool() const { return (bool)buffer; }
template <typename A>
typename std::enable_if_t<std::is_integral<A>::value, CPP>
typename std::enable_if_t<std::is_integral_v<A>, CPP>
operator + (A a) const
{
return CPP(addr() + a * sizeof(T), proxy);
}
template <typename A>
typename std::enable_if_t<std::is_integral<A>::value, CPP>
typename std::enable_if_t<std::is_integral_v<A>, CPP>
operator - (A a) const
{
return CPP(addr() - a * sizeof(T), proxy);
@@ -228,7 +228,7 @@ class ConstProxyPtr
};
template <typename T, typename Proxy, typename A>
typename std::enable_if_t<std::is_integral<A>::value, ConstProxyPtr<T, Proxy>>
typename std::enable_if_t<std::is_integral_v<A>, ConstProxyPtr<T, Proxy>>
operator + (A a, const ConstProxyPtr<T, Proxy> &other)
{
return other + a;
@@ -245,17 +245,17 @@ class ProxyPtr : public ConstProxyPtr<T, Proxy>
public:
template <typename ...Args,
typename std::enable_if_t<std::is_constructible<
Proxy, Args&&...>::value, int> = 0>
typename std::enable_if_t<std::is_constructible_v<
Proxy, Args&&...>, int> = 0>
explicit ProxyPtr(Addr _ptr, Args&&... args) : CPP(_ptr, args...) {}
template <typename ...Args,
typename std::enable_if_t<std::is_constructible<
Proxy, Args&&...>::value, int> = 0>
typename std::enable_if_t<std::is_constructible_v<
Proxy, Args&&...>, int> = 0>
explicit ProxyPtr(Args&&... args) : CPP(0, args...) {}
template <typename O, typename Enabled=
typename std::enable_if_t<std::is_assignable<T *, O *>::value &&
!std::is_same<O, void>::value>>
typename std::enable_if_t<std::is_assignable_v<T *, O *> &&
!std::is_same_v<O, void>>>
ProxyPtr(const ProxyPtr<O, Proxy> &other) : CPP(other) {}
ProxyPtr(const PP &other) : CPP(other) {}
@@ -269,14 +269,14 @@ class ProxyPtr : public ConstProxyPtr<T, Proxy>
}
template <typename A>
typename std::enable_if_t<std::is_integral<A>::value, PP>
typename std::enable_if_t<std::is_integral_v<A>, PP>
operator + (A a) const
{
return PP(this->addr() + a * sizeof(T), this->proxy);
}
template <typename A>
typename std::enable_if_t<std::is_integral<A>::value, PP>
typename std::enable_if_t<std::is_integral_v<A>, PP>
operator - (A a) const
{
return PP(this->addr() - a * sizeof(T), this->proxy);
@@ -351,7 +351,7 @@ class ProxyPtr<void, Proxy>
};
template <typename T, typename Proxy, typename A>
typename std::enable_if_t<std::is_integral<A>::value, ProxyPtr<T, Proxy>>
typename std::enable_if_t<std::is_integral_v<A>, ProxyPtr<T, Proxy>>
operator + (A a, const ProxyPtr<T, Proxy> &other)
{
return other + a;

View File

@@ -341,7 +341,7 @@ TEST(ProxyPtr, ConstOperators)
EXPECT_EQ((const PtrType *)null, nullptr);
// Dereferences.
is_same = std::is_same<decltype(*test_ptr1), const PtrType &>::value;
is_same = std::is_same_v<decltype(*test_ptr1), const PtrType &>;
EXPECT_TRUE(is_same);
store.store[0x100] = 0x55;
@@ -373,7 +373,7 @@ TEST(ProxyPtr, ConstOperators)
EXPECT_EQ(struct_ptr->c, 0x33);
EXPECT_EQ(struct_ptr->d, 0x44);
is_same = std::is_same<decltype((struct_ptr->a)), const uint8_t &>::value;
is_same = std::is_same_v<decltype((struct_ptr->a)), const uint8_t &>;
EXPECT_TRUE(is_same);
}
@@ -426,7 +426,7 @@ TEST(ProxyPtr, NonConstOperators)
EXPECT_EQ((const PtrType *)null, nullptr);
// Dereferences.
is_same = std::is_same<decltype(*test_ptr1), PtrType &>::value;
is_same = std::is_same_v<decltype(*test_ptr1), PtrType &>;
EXPECT_TRUE(is_same);
// Flush test_ptr1, which has been conservatively marked as dirty.
@@ -461,7 +461,7 @@ TEST(ProxyPtr, NonConstOperators)
EXPECT_EQ(struct_ptr->c, 0x33);
EXPECT_EQ(struct_ptr->d, 0x44);
is_same = std::is_same<decltype((struct_ptr->a)), uint8_t &>::value;
is_same = std::is_same_v<decltype((struct_ptr->a)), uint8_t &>;
EXPECT_TRUE(is_same);
}

View File

@@ -130,14 +130,14 @@ struct ShowParam
// Handle characters specially so that we print their value, not the character
// they encode.
template <class T>
struct ShowParam<T, std::enable_if_t<std::is_same<char, T>::value ||
std::is_same<unsigned char, T>::value ||
std::is_same<signed char, T>::value>>
struct ShowParam<T, std::enable_if_t<std::is_same_v<char, T> ||
std::is_same_v<unsigned char, T> ||
std::is_same_v<signed char, T>>>
{
static void
show(std::ostream &os, const T &value)
{
if (std::is_signed<T>::value)
if (std::is_signed_v<T>)
os << (int)value;
else
os << (unsigned int)value;

View File

@@ -62,6 +62,9 @@ struct GenericSyscallABI32 : public GenericSyscallABI
public std::true_type
{};
template <typename T>
static constexpr bool IsWideV = IsWide<T>::value;
// Read two registers and merge them into one value.
static uint64_t
mergeRegs(ThreadContext *tc, RegIndex low_idx, RegIndex high_idx)
@@ -80,8 +83,8 @@ namespace guest_abi
template <typename ABI, typename Arg>
struct Argument<ABI, Arg,
typename std::enable_if_t<
std::is_base_of<GenericSyscallABI64, ABI>::value &&
std::is_integral<Arg>::value>>
std::is_base_of_v<GenericSyscallABI64, ABI> &&
std::is_integral_v<Arg>>>
{
static Arg
get(ThreadContext *tc, typename ABI::State &state)
@@ -96,8 +99,8 @@ struct Argument<ABI, Arg,
// arguments aren't handled generically.
template <typename ABI, typename Arg>
struct Argument<ABI, Arg,
typename std::enable_if_t<std::is_integral<Arg>::value &&
!ABI::template IsWide<Arg>::value>>
typename std::enable_if_t<std::is_integral_v<Arg> &&
!ABI::template IsWideV<Arg>>>
{
static Arg
get(ThreadContext *tc, typename ABI::State &state)