[libc-commits] [libc] f722615 - [libc][NFC] Use STL case for type_traits
Guillaume Chatelet via libc-commits
libc-commits at lists.llvm.org
Fri Jul 29 02:57:31 PDT 2022
Author: Guillaume Chatelet
Date: 2022-07-29T09:57:03Z
New Revision: f72261508afa88e998521e54c46bdcd86fee1c24
URL: https://github.com/llvm/llvm-project/commit/f72261508afa88e998521e54c46bdcd86fee1c24
DIFF: https://github.com/llvm/llvm-project/commit/f72261508afa88e998521e54c46bdcd86fee1c24.diff
LOG: [libc][NFC] Use STL case for type_traits
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion. Starting with the type_traits header.
Differential Revision: https://reviews.llvm.org/D130727
Added:
libc/src/__support/CPP/type_traits.h
Modified:
libc/fuzzing/math/Compare.h
libc/src/__support/CPP/ArrayRef.h
libc/src/__support/CPP/CMakeLists.txt
libc/src/__support/CPP/Utility.h
libc/src/__support/CPP/atomic.h
libc/src/__support/CPP/stringstream.h
libc/src/__support/FPUtil/BasicOperations.h
libc/src/__support/FPUtil/DivisionAndRemainderOperations.h
libc/src/__support/FPUtil/FMA.h
libc/src/__support/FPUtil/FPBits.h
libc/src/__support/FPUtil/Hypot.h
libc/src/__support/FPUtil/ManipulationFunctions.h
libc/src/__support/FPUtil/NearestIntegerOperations.h
libc/src/__support/FPUtil/NormalFloat.h
libc/src/__support/FPUtil/aarch64/FMA.h
libc/src/__support/FPUtil/generic/FMA.h
libc/src/__support/FPUtil/generic/FMod.h
libc/src/__support/FPUtil/generic/sqrt.h
libc/src/__support/FPUtil/x86_64/FMA.h
libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
libc/src/__support/integer_operations.h
libc/src/__support/integer_to_string.h
libc/src/math/generic/math_utils.h
libc/src/string/memory_utils/address.h
libc/src/string/memory_utils/algorithm.h
libc/src/string/memory_utils/backend_aarch64.h
libc/src/string/memory_utils/backend_scalar.h
libc/src/string/memory_utils/backend_x86.h
libc/src/string/memory_utils/sized_op.h
libc/test/src/__support/CPP/integer_sequence_test.cpp
libc/test/src/math/NextAfterTest.h
libc/test/src/math/exhaustive/exhaustive_test.h
libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp
libc/test/src/string/memory_utils/address_test.cpp
libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp
libc/utils/MPFRWrapper/MPFRUtils.cpp
libc/utils/MPFRWrapper/MPFRUtils.h
libc/utils/UnitTest/FPMatcher.cpp
libc/utils/UnitTest/FPMatcher.h
libc/utils/UnitTest/LibcTest.cpp
libc/utils/UnitTest/LibcTest.h
libc/utils/UnitTest/StringUtils.h
utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Removed:
libc/src/__support/CPP/TypeTraits.h
################################################################################
diff --git a/libc/fuzzing/math/Compare.h b/libc/fuzzing/math/Compare.h
index 693f572a189d4..7a194383f4df8 100644
--- a/libc/fuzzing/math/Compare.h
+++ b/libc/fuzzing/math/Compare.h
@@ -9,12 +9,11 @@
#ifndef LLVM_LIBC_FUZZING_MATH_COMPARE_H
#define LLVM_LIBC_FUZZING_MATH_COMPARE_H
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FPBits.h"
template <typename T>
-__llvm_libc::cpp::EnableIfType<__llvm_libc::cpp::IsFloatingPointType<T>::Value,
- bool>
+__llvm_libc::cpp::enable_if_t<__llvm_libc::cpp::is_floating_point_v<T>, bool>
ValuesEqual(T x1, T x2) {
__llvm_libc::fputil::FPBits<T> bits1(x1);
__llvm_libc::fputil::FPBits<T> bits2(x2);
@@ -27,7 +26,7 @@ ValuesEqual(T x1, T x2) {
}
template <typename T>
-__llvm_libc::cpp::EnableIfType<__llvm_libc::cpp::IsIntegral<T>::Value, bool>
+__llvm_libc::cpp::enable_if_t<__llvm_libc::cpp::is_integral_v<T>, bool>
ValuesEqual(T x1, T x2) {
return x1 == x1;
}
diff --git a/libc/src/__support/CPP/ArrayRef.h b/libc/src/__support/CPP/ArrayRef.h
index 64e072fd60583..1219963a3a573 100644
--- a/libc/src/__support/CPP/ArrayRef.h
+++ b/libc/src/__support/CPP/ArrayRef.h
@@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_SUPPORT_CPP_ARRAYREF_H
#include "Array.h"
-#include "TypeTraits.h" //RemoveCVType
+#include "type_traits.h" // RemoveCVType
#include <stddef.h> // For size_t.
@@ -24,7 +24,7 @@ namespace cpp {
namespace internal {
template <typename QualifiedT> class ArrayRefBase {
public:
- using value_type = RemoveCVType<QualifiedT>;
+ using value_type = remove_cv_t<QualifiedT>;
using pointer = value_type *;
using const_pointer = const value_type *;
using reference = value_type &;
@@ -109,7 +109,7 @@ template <typename QualifiedT> class ArrayRefBase {
template <typename T> struct ArrayRef : public internal::ArrayRefBase<const T> {
private:
- static_assert(IsSameV<T, RemoveCVType<T>>,
+ static_assert(is_same_v<T, remove_cv_t<T>>,
"ArrayRef must have a non-const, non-volatile value_type");
using Impl = internal::ArrayRefBase<const T>;
using Impl::Impl;
@@ -128,7 +128,7 @@ template <typename T>
struct MutableArrayRef : public internal::ArrayRefBase<T> {
private:
static_assert(
- IsSameV<T, RemoveCVType<T>>,
+ is_same_v<T, remove_cv_t<T>>,
"MutableArrayRef must have a non-const, non-volatile value_type");
using Impl = internal::ArrayRefBase<T>;
using Impl::Impl;
diff --git a/libc/src/__support/CPP/CMakeLists.txt b/libc/src/__support/CPP/CMakeLists.txt
index e65a884e9745c..12cf7295cbb51 100644
--- a/libc/src/__support/CPP/CMakeLists.txt
+++ b/libc/src/__support/CPP/CMakeLists.txt
@@ -71,7 +71,7 @@ add_header_library(
add_header_library(
type_traits
HDRS
- TypeTraits.h
+ type_traits.h
DEPENDS
.uint
)
diff --git a/libc/src/__support/CPP/TypeTraits.h b/libc/src/__support/CPP/TypeTraits.h
deleted file mode 100644
index 0e50a7d61a024..0000000000000
--- a/libc/src/__support/CPP/TypeTraits.h
+++ /dev/null
@@ -1,157 +0,0 @@
-//===-- Self contained C++ type traits --------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_TYPETRAITS_H
-#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPETRAITS_H
-
-#include "UInt.h"
-
-namespace __llvm_libc {
-namespace cpp {
-
-template <bool B, typename T> struct EnableIf;
-template <typename T> struct EnableIf<true, T> {
- typedef T Type;
-};
-
-template <bool B, typename T>
-using EnableIfType = typename EnableIf<B, T>::Type;
-
-struct TrueValue {
- static constexpr bool Value = true;
-};
-
-struct FalseValue {
- static constexpr bool Value = false;
-};
-
-template <typename T> struct TypeIdentity {
- typedef T Type;
-};
-
-template <typename T1, typename T2> struct IsSame : public FalseValue {};
-template <typename T> struct IsSame<T, T> : public TrueValue {};
-template <typename T1, typename T2>
-static constexpr bool IsSameV = IsSame<T1, T2>::Value;
-
-template <typename T> struct RemoveCV : public TypeIdentity<T> {};
-template <typename T> struct RemoveCV<const T> : public TypeIdentity<T> {};
-template <typename T> struct RemoveCV<volatile T> : public TypeIdentity<T> {};
-template <typename T>
-struct RemoveCV<const volatile T> : public TypeIdentity<T> {};
-
-template <typename T> using RemoveCVType = typename RemoveCV<T>::Type;
-
-template <typename Type> struct IsIntegral {
- using TypeNoCV = RemoveCVType<Type>;
- static constexpr bool Value =
- IsSameV<char, TypeNoCV> || IsSameV<signed char, TypeNoCV> ||
- IsSameV<unsigned char, TypeNoCV> || IsSameV<short, TypeNoCV> ||
- IsSameV<unsigned short, TypeNoCV> || IsSameV<int, TypeNoCV> ||
- IsSameV<unsigned int, TypeNoCV> || IsSameV<long, TypeNoCV> ||
- IsSameV<unsigned long, TypeNoCV> || IsSameV<long long, TypeNoCV> ||
- IsSameV<unsigned long long, TypeNoCV> || IsSameV<bool, TypeNoCV> ||
- // We need to include UInt<128> and __uint128_t when available because
- // we want to unittest UInt<128>. If we include only UInt128, then on
- // platform where it resolves to __uint128_t, we cannot unittest
- // UInt<128>.
- IsSameV<__llvm_libc::cpp::UInt<128>, TypeNoCV>
-#ifdef __SIZEOF_INT128__
- || IsSameV<__int128_t, TypeNoCV> || IsSameV<__uint128_t, TypeNoCV>
-#endif
- ;
-};
-
-template <typename Type> struct IsEnum {
- static constexpr bool Value = __is_enum(Type);
-};
-
-template <typename T> struct IsPointerTypeNoCV : public FalseValue {};
-template <typename T> struct IsPointerTypeNoCV<T *> : public TrueValue {};
-template <typename T> struct IsPointerType {
- static constexpr bool Value = IsPointerTypeNoCV<RemoveCVType<T>>::Value;
-};
-
-template <typename Type> struct IsFloatingPointType {
- using TypeNoCV = RemoveCVType<Type>;
- static constexpr bool Value = IsSame<float, TypeNoCV>::Value ||
- IsSame<double, TypeNoCV>::Value ||
- IsSame<long double, TypeNoCV>::Value;
-};
-
-template <typename Type> struct IsArithmetic {
- static constexpr bool Value =
- IsIntegral<Type>::Value || IsFloatingPointType<Type>::Value;
-};
-
-template <typename Type> struct IsSigned {
- static constexpr bool Value =
- IsArithmetic<Type>::Value && (Type(-1) < Type(0));
- constexpr operator bool() const { return Value; }
- constexpr bool operator()() const { return Value; }
-};
-
-template <typename Type> struct MakeUnsigned;
-template <> struct MakeUnsigned<char> {
- using Type = unsigned char;
-};
-template <> struct MakeUnsigned<signed char> {
- using Type = unsigned char;
-};
-template <> struct MakeUnsigned<short> {
- using Type = unsigned short;
-};
-template <> struct MakeUnsigned<int> {
- using Type = unsigned int;
-};
-template <> struct MakeUnsigned<long> {
- using Type = unsigned long;
-};
-template <> struct MakeUnsigned<long long> {
- using Type = unsigned long long;
-};
-template <> struct MakeUnsigned<unsigned char> {
- using Type = unsigned char;
-};
-template <> struct MakeUnsigned<unsigned short> {
- using Type = unsigned short;
-};
-template <> struct MakeUnsigned<unsigned int> {
- using Type = unsigned int;
-};
-template <> struct MakeUnsigned<unsigned long> {
- using Type = unsigned long;
-};
-template <> struct MakeUnsigned<unsigned long long> {
- using Type = unsigned long long;
-};
-#ifdef __SIZEOF_INT128__
-template <> struct MakeUnsigned<__int128_t> {
- using Type = __uint128_t;
-};
-template <> struct MakeUnsigned<__uint128_t> {
- using Type = __uint128_t;
-};
-#endif
-
-template <typename T> using MakeUnsignedType = typename MakeUnsigned<T>::Type;
-
-// Compile time type selection.
-template <bool _, class TrueT, class FalseT> struct Conditional {
- using type = TrueT;
-};
-template <class TrueT, class FalseT> struct Conditional<false, TrueT, FalseT> {
- using type = FalseT;
-};
-template <bool Cond, typename TrueT, typename FalseT>
-using ConditionalType = typename Conditional<Cond, TrueT, FalseT>::type;
-
-} // namespace cpp
-} // namespace __llvm_libc
-
-#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPETRAITS_H
diff --git a/libc/src/__support/CPP/Utility.h b/libc/src/__support/CPP/Utility.h
index 8a997611c8fc8..00805c79ce7a0 100644
--- a/libc/src/__support/CPP/Utility.h
+++ b/libc/src/__support/CPP/Utility.h
@@ -9,12 +9,12 @@
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
namespace __llvm_libc::cpp {
template <typename T, T... Seq> struct IntegerSequence {
- static_assert(IsIntegral<T>::Value);
+ static_assert(is_integral_v<T>);
template <T Next> using append = IntegerSequence<T, Seq..., Next>;
};
diff --git a/libc/src/__support/CPP/atomic.h b/libc/src/__support/CPP/atomic.h
index 72addbc523938..5ef7f5e09eac2 100644
--- a/libc/src/__support/CPP/atomic.h
+++ b/libc/src/__support/CPP/atomic.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_ATOMIC_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_ATOMIC_H
-#include "TypeTraits.h"
+#include "type_traits.h"
namespace __llvm_libc {
namespace cpp {
@@ -25,7 +25,7 @@ enum class MemoryOrder : int {
template <typename T> struct Atomic {
// For now, we will restrict to only arithmetic types.
- static_assert(IsArithmetic<T>::Value, "Only arithmetic types can be atomic.");
+ static_assert(is_arithmetic_v<T>, "Only arithmetic types can be atomic.");
private:
// The value stored should be appropriately aligned so that
diff --git a/libc/src/__support/CPP/stringstream.h b/libc/src/__support/CPP/stringstream.h
index 414eef883bbfc..6b2ff881d96f3 100644
--- a/libc/src/__support/CPP/stringstream.h
+++ b/libc/src/__support/CPP/stringstream.h
@@ -11,7 +11,7 @@
#include "ArrayRef.h"
#include "StringView.h"
-#include "TypeTraits.h"
+#include "type_traits.h"
#include "src/__support/integer_to_string.h"
@@ -56,17 +56,17 @@ class StringStream {
}
// Write the |val| as string.
- template <typename T, EnableIfType<IsIntegral<T>::Value, int> = 0>
+ template <typename T, enable_if_t<is_integral_v<T>, int> = 0>
StringStream &operator<<(T val) {
const auto int_to_str = integer_to_string(val);
return operator<<(int_to_str.str());
}
- template <typename T, EnableIfType<IsFloatingPointType<T>::Value, int> = 0>
+ template <typename T, enable_if_t<is_floating_point_v<T>, int> = 0>
StringStream &operator<<(T val) {
// If this specialization gets activated, then the static_assert will
// trigger a compile error about missing floating point number support.
- static_assert(!IsFloatingPointType<T>::Value,
+ static_assert(!is_floating_point_v<T>,
"Writing floating point numbers is not yet supported");
return *this;
}
diff --git a/libc/src/__support/CPP/type_traits.h b/libc/src/__support/CPP/type_traits.h
new file mode 100644
index 0000000000000..bccd4eb76579e
--- /dev/null
+++ b/libc/src/__support/CPP/type_traits.h
@@ -0,0 +1,173 @@
+//===-- Self contained C++ type traits --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_TYPETRAITS_H
+#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPETRAITS_H
+
+#include "UInt.h"
+
+namespace __llvm_libc {
+namespace cpp {
+
+template <bool B, typename T> struct enable_if;
+template <typename T> struct enable_if<true, T> {
+ using type = T;
+};
+template <bool B, typename T = void>
+using enable_if_t = typename enable_if<B, T>::type;
+
+template <typename T, T v> struct integral_constant {
+ using value_type = T;
+ static constexpr T value = v;
+};
+using true_type = cpp::integral_constant<bool, true>;
+using false_type = cpp::integral_constant<bool, false>;
+
+template <typename T> struct type_identity {
+ using type = T;
+};
+
+template <typename T, typename U> struct is_same : cpp::false_type {};
+template <typename T> struct is_same<T, T> : cpp::true_type {};
+template <typename T, typename U>
+inline constexpr bool is_same_v = is_same<T, U>::value;
+
+template <typename T> struct remove_cv : public type_identity<T> {};
+template <typename T> struct remove_cv<const T> : public type_identity<T> {};
+template <typename T> struct remove_cv<volatile T> : public type_identity<T> {};
+template <typename T>
+struct remove_cv<const volatile T> : public type_identity<T> {};
+template <typename T> using remove_cv_t = typename remove_cv<T>::type;
+
+template <typename T> struct is_integral {
+private:
+ using unqualified_type = remove_cv_t<T>;
+
+public:
+ static constexpr bool value =
+ is_same_v<char, unqualified_type> ||
+ is_same_v<signed char, unqualified_type> ||
+ is_same_v<unsigned char, unqualified_type> ||
+ is_same_v<short, unqualified_type> ||
+ is_same_v<unsigned short, unqualified_type> ||
+ is_same_v<int, unqualified_type> ||
+ is_same_v<unsigned int, unqualified_type> ||
+ is_same_v<long, unqualified_type> ||
+ is_same_v<unsigned long, unqualified_type> ||
+ is_same_v<long long, unqualified_type> ||
+ is_same_v<unsigned long long, unqualified_type> ||
+ is_same_v<bool, unqualified_type> ||
+ // We need to include UInt<128> and __uint128_t when available because
+ // we want to unittest UInt<128>. If we include only UInt128, then on
+ // platform where it resolves to __uint128_t, we cannot unittest
+ // UInt<128>.
+ is_same_v<__llvm_libc::cpp::UInt<128>, unqualified_type>
+#ifdef __SIZEOF_INT128__
+ || is_same_v<__int128_t, unqualified_type> ||
+ is_same_v<__uint128_t, unqualified_type>
+#endif
+ ;
+};
+template <typename T>
+inline constexpr bool is_integral_v = is_integral<T>::value;
+
+template <typename T> struct is_enum {
+ static constexpr bool value = __is_enum(T);
+};
+
+template <typename T> struct is_pointer : cpp::false_type {};
+template <typename T> struct is_pointer<T *> : cpp::true_type {};
+template <typename T> struct is_pointer<T *const> : cpp::true_type {};
+template <typename T> struct is_pointer<T *volatile> : cpp::true_type {};
+template <typename T> struct is_pointer<T *const volatile> : cpp::true_type {};
+template <typename T> inline constexpr bool is_pointer_v = is_pointer<T>::value;
+
+template <typename T> struct is_floating_point {
+private:
+ using unqualified_type = remove_cv_t<T>;
+
+public:
+ static constexpr bool value = is_same_v<float, unqualified_type> ||
+ is_same_v<double, unqualified_type> ||
+ is_same_v<long double, unqualified_type>;
+};
+template <typename T>
+inline constexpr bool is_floating_point_v = is_floating_point<T>::value;
+
+template <typename T> struct is_arithmetic {
+ static constexpr bool value =
+ is_integral<T>::value || is_floating_point<T>::value;
+};
+template <typename T>
+inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
+
+template <typename T> struct is_signed {
+ static constexpr bool value = is_arithmetic<T>::value && (T(-1) < T(0));
+ constexpr operator bool() const { return value; }
+ constexpr bool operator()() const { return value; }
+};
+template <typename T> inline constexpr bool is_signed_v = is_signed<T>::value;
+
+template <typename T> struct make_unsigned;
+template <> struct make_unsigned<char> {
+ using type = unsigned char;
+};
+template <> struct make_unsigned<signed char> {
+ using type = unsigned char;
+};
+template <> struct make_unsigned<short> {
+ using type = unsigned short;
+};
+template <> struct make_unsigned<int> {
+ using type = unsigned int;
+};
+template <> struct make_unsigned<long> {
+ using type = unsigned long;
+};
+template <> struct make_unsigned<long long> {
+ using type = unsigned long long;
+};
+template <> struct make_unsigned<unsigned char> {
+ using type = unsigned char;
+};
+template <> struct make_unsigned<unsigned short> {
+ using type = unsigned short;
+};
+template <> struct make_unsigned<unsigned int> {
+ using type = unsigned int;
+};
+template <> struct make_unsigned<unsigned long> {
+ using type = unsigned long;
+};
+template <> struct make_unsigned<unsigned long long> {
+ using type = unsigned long long;
+};
+#ifdef __SIZEOF_INT128__
+template <> struct make_unsigned<__int128_t> {
+ using type = __uint128_t;
+};
+template <> struct make_unsigned<__uint128_t> {
+ using type = __uint128_t;
+};
+#endif
+template <typename T> using make_unsigned_t = typename make_unsigned<T>::type;
+
+// Compile time type selection.
+template <bool B, typename T, typename F> struct conditional {
+ using type = T;
+};
+template <typename T, typename F> struct conditional<false, T, F> {
+ using type = F;
+};
+template <bool B, typename T, typename F>
+using conditional_t = typename conditional<B, T, F>::type;
+
+} // namespace cpp
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPETRAITS_H
diff --git a/libc/src/__support/FPUtil/BasicOperations.h b/libc/src/__support/FPUtil/BasicOperations.h
index 8a66062ee1e9d..353a17e6e1e04 100644
--- a/libc/src/__support/FPUtil/BasicOperations.h
+++ b/libc/src/__support/FPUtil/BasicOperations.h
@@ -11,21 +11,19 @@
#include "FPBits.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
namespace __llvm_libc {
namespace fputil {
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T abs(T x) {
FPBits<T> bits(x);
bits.set_sign(0);
return T(bits);
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T fmin(T x, T y) {
FPBits<T> bitx(x), bity(y);
@@ -43,8 +41,7 @@ static inline T fmin(T x, T y) {
}
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T fmax(T x, T y) {
FPBits<T> bitx(x), bity(y);
@@ -62,8 +59,7 @@ static inline T fmax(T x, T y) {
}
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T fdim(T x, T y) {
FPBits<T> bitx(x), bity(y);
diff --git a/libc/src/__support/FPUtil/DivisionAndRemainderOperations.h b/libc/src/__support/FPUtil/DivisionAndRemainderOperations.h
index 44cab316c7d2e..6af682cc4cac3 100644
--- a/libc/src/__support/FPUtil/DivisionAndRemainderOperations.h
+++ b/libc/src/__support/FPUtil/DivisionAndRemainderOperations.h
@@ -13,7 +13,7 @@
#include "ManipulationFunctions.h"
#include "NormalFloat.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
namespace __llvm_libc {
namespace fputil {
@@ -22,8 +22,7 @@ static constexpr int QUOTIENT_LSB_BITS = 3;
// The implementation is a bit-by-bit algorithm which uses integer division
// to evaluate the quotient and remainder.
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T remquo(T x, T y, int &q) {
FPBits<T> xbits(x), ybits(y);
if (xbits.is_nan())
diff --git a/libc/src/__support/FPUtil/FMA.h b/libc/src/__support/FPUtil/FMA.h
index a3c1729dbe774..82db04e8f04ce 100644
--- a/libc/src/__support/FPUtil/FMA.h
+++ b/libc/src/__support/FPUtil/FMA.h
@@ -22,7 +22,7 @@
#else
// FMA instructions are not available
#include "generic/FMA.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
namespace __llvm_libc {
namespace fputil {
diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index 62befc1e53eb0..d2717e5792d40 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
@@ -12,7 +12,7 @@
#include "PlatformDefs.h"
#include "src/__support/CPP/Bit.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/builtin_wrappers.h"
#include "src/__support/common.h"
@@ -39,7 +39,7 @@ template <typename T> struct ExponentWidth {
// an x87 floating point format. This format is an IEEE 754 extension format.
// It is handled as an explicit specialization of this class.
template <typename T> struct FPBits {
- static_assert(cpp::IsFloatingPointType<T>::Value,
+ static_assert(cpp::is_floating_point_v<T>,
"FPBits instantiated with invalid type.");
// Reinterpreting bits as an integer value and interpreting the bits of an
@@ -103,13 +103,12 @@ template <typename T> struct FPBits {
// We don't want accidental type promotions/conversions, so we require exact
// type match.
- template <typename XType,
- cpp::EnableIfType<cpp::IsSame<T, XType>::Value, int> = 0>
+ template <typename XType, cpp::enable_if_t<cpp::is_same_v<T, XType>, int> = 0>
constexpr explicit FPBits(XType x)
: bits(__llvm_libc::bit_cast<UIntType>(x)) {}
template <typename XType,
- cpp::EnableIfType<cpp::IsSame<XType, UIntType>::Value, int> = 0>
+ cpp::enable_if_t<cpp::is_same_v<XType, UIntType>, int> = 0>
constexpr explicit FPBits(XType x) : bits(x) {}
FPBits() : bits(0) {}
diff --git a/libc/src/__support/FPUtil/Hypot.h b/libc/src/__support/FPUtil/Hypot.h
index c4eb0abe6de75..11cedea3d4e50 100644
--- a/libc/src/__support/FPUtil/Hypot.h
+++ b/libc/src/__support/FPUtil/Hypot.h
@@ -14,8 +14,8 @@
#include "FPBits.h"
#include "builtin_wrappers.h"
#include "src/__support/CPP/Bit.h"
-#include "src/__support/CPP/TypeTraits.h"
#include "src/__support/CPP/UInt128.h"
+#include "src/__support/CPP/type_traits.h"
namespace __llvm_libc {
namespace fputil {
@@ -97,8 +97,7 @@ template <> struct DoubleLength<uint64_t> {
// - HYPOT(x, y) is +Inf if x or y is +Inf or -Inf; else
// - HYPOT(x, y) is NaN if x or y is NaN.
//
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T hypot(T x, T y) {
using FPBits_t = FPBits<T>;
using UIntType = typename FPBits<T>::UIntType;
diff --git a/libc/src/__support/FPUtil/ManipulationFunctions.h b/libc/src/__support/FPUtil/ManipulationFunctions.h
index f922c0ca77b68..21bce00f2874b 100644
--- a/libc/src/__support/FPUtil/ManipulationFunctions.h
+++ b/libc/src/__support/FPUtil/ManipulationFunctions.h
@@ -15,7 +15,7 @@
#include "PlatformDefs.h"
#include "src/__support/CPP/Bit.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include <limits.h>
#include <math.h>
@@ -23,8 +23,7 @@
namespace __llvm_libc {
namespace fputil {
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T frexp(T x, int &exp) {
FPBits<T> bits(x);
if (bits.is_inf_or_nan())
@@ -40,8 +39,7 @@ static inline T frexp(T x, int &exp) {
return normal;
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T modf(T x, T &iptr) {
FPBits<T> bits(x);
if (bits.is_zero() || bits.is_nan()) {
@@ -62,16 +60,14 @@ static inline T modf(T x, T &iptr) {
}
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T copysign(T x, T y) {
FPBits<T> xbits(x);
xbits.set_sign(FPBits<T>(y).get_sign());
return T(xbits);
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline int ilogb(T x) {
// TODO: Raise appropriate floating point exceptions and set errno to the
// an appropriate error value wherever relevant.
@@ -99,8 +95,7 @@ static inline int ilogb(T x) {
return normal.exponent;
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T logb(T x) {
FPBits<T> bits(x);
if (bits.is_zero()) {
@@ -118,8 +113,7 @@ static inline T logb(T x) {
return normal.exponent;
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T ldexp(T x, int exp) {
FPBits<T> bits(x);
if (bits.is_zero() || bits.is_inf_or_nan() || exp == 0)
@@ -145,8 +139,7 @@ static inline T ldexp(T x, int exp) {
return normal;
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T nextafter(T from, T to) {
FPBits<T> from_bits(from);
if (from_bits.is_nan())
diff --git a/libc/src/__support/FPUtil/NearestIntegerOperations.h b/libc/src/__support/FPUtil/NearestIntegerOperations.h
index 19c833b4b68e3..3a9d0d121c6a9 100644
--- a/libc/src/__support/FPUtil/NearestIntegerOperations.h
+++ b/libc/src/__support/FPUtil/NearestIntegerOperations.h
@@ -12,7 +12,7 @@
#include "FEnvImpl.h"
#include "FPBits.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include <errno.h>
#include <math.h>
@@ -20,8 +20,7 @@
namespace __llvm_libc {
namespace fputil {
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T trunc(T x) {
FPBits<T> bits(x);
@@ -52,8 +51,7 @@ static inline T trunc(T x) {
return T(bits);
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T ceil(T x) {
FPBits<T> bits(x);
@@ -91,8 +89,7 @@ static inline T ceil(T x) {
return trunc_value + T(1.0);
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T floor(T x) {
FPBits<T> bits(x);
if (bits.get_sign()) {
@@ -102,8 +99,7 @@ static inline T floor(T x) {
}
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T round(T x) {
using UIntType = typename FPBits<T>::UIntType;
FPBits<T> bits(x);
@@ -154,8 +150,7 @@ static inline T round(T x) {
}
}
-template <typename T,
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, int> = 0>
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
static inline T round_using_current_rounding_mode(T x) {
using UIntType = typename FPBits<T>::UIntType;
FPBits<T> bits(x);
@@ -235,9 +230,8 @@ static inline T round_using_current_rounding_mode(T x) {
namespace internal {
template <typename F, typename I,
- cpp::EnableIfType<cpp::IsFloatingPointType<F>::Value &&
- cpp::IsIntegral<I>::Value,
- int> = 0>
+ cpp::enable_if_t<cpp::is_floating_point_v<F> && cpp::is_integral_v<I>,
+ int> = 0>
static inline I rounded_float_to_signed_integer(F x) {
constexpr I INTEGER_MIN = (I(1) << (sizeof(I) * 8 - 1));
constexpr I INTEGER_MAX = -(INTEGER_MIN + 1);
@@ -277,17 +271,15 @@ static inline I rounded_float_to_signed_integer(F x) {
} // namespace internal
template <typename F, typename I,
- cpp::EnableIfType<cpp::IsFloatingPointType<F>::Value &&
- cpp::IsIntegral<I>::Value,
- int> = 0>
+ cpp::enable_if_t<cpp::is_floating_point_v<F> && cpp::is_integral_v<I>,
+ int> = 0>
static inline I round_to_signed_integer(F x) {
return internal::rounded_float_to_signed_integer<F, I>(round(x));
}
template <typename F, typename I,
- cpp::EnableIfType<cpp::IsFloatingPointType<F>::Value &&
- cpp::IsIntegral<I>::Value,
- int> = 0>
+ cpp::enable_if_t<cpp::is_floating_point_v<F> && cpp::is_integral_v<I>,
+ int> = 0>
static inline I round_to_signed_integer_using_current_rounding_mode(F x) {
return internal::rounded_float_to_signed_integer<F, I>(
round_using_current_rounding_mode(x));
diff --git a/libc/src/__support/FPUtil/NormalFloat.h b/libc/src/__support/FPUtil/NormalFloat.h
index 939db0909d97c..9f21e733498b5 100644
--- a/libc/src/__support/FPUtil/NormalFloat.h
+++ b/libc/src/__support/FPUtil/NormalFloat.h
@@ -11,7 +11,7 @@
#include "FPBits.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include <stdint.h>
@@ -27,7 +27,7 @@ namespace fputil {
// where <mantissa> is of the form 1.<...>.
template <typename T> struct NormalFloat {
static_assert(
- cpp::IsFloatingPointType<T>::Value,
+ cpp::is_floating_point_v<T>,
"NormalFloat template parameter has to be a floating point type.");
using UIntType = typename FPBits<T>::UIntType;
diff --git a/libc/src/__support/FPUtil/aarch64/FMA.h b/libc/src/__support/FPUtil/aarch64/FMA.h
index ed637c848658e..118d312f017f9 100644
--- a/libc/src/__support/FPUtil/aarch64/FMA.h
+++ b/libc/src/__support/FPUtil/aarch64/FMA.h
@@ -19,13 +19,13 @@
#error "FMA instructions are not supported"
#endif
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
namespace __llvm_libc {
namespace fputil {
template <typename T>
-cpp::EnableIfType<cpp::IsSame<T, float>::Value, T> fma(T x, T y, T z) {
+cpp::enable_if_t<cpp::is_same_v<T, float>, T> fma(T x, T y, T z) {
float result;
__asm__ __volatile__("fmadd %s0, %s1, %s2, %s3\n\t"
: "=w"(result)
@@ -34,7 +34,7 @@ cpp::EnableIfType<cpp::IsSame<T, float>::Value, T> fma(T x, T y, T z) {
}
template <typename T>
-cpp::EnableIfType<cpp::IsSame<T, double>::Value, T> fma(T x, T y, T z) {
+cpp::enable_if_t<cpp::is_same_v<T, double> :, T> fma(T x, T y, T z) {
double result;
__asm__ __volatile__("fmadd %d0, %d1, %d2, %d3\n\t"
: "=w"(result)
diff --git a/libc/src/__support/FPUtil/generic/FMA.h b/libc/src/__support/FPUtil/generic/FMA.h
index b71f5bf64dc3d..2eb729ee6acca 100644
--- a/libc/src/__support/FPUtil/generic/FMA.h
+++ b/libc/src/__support/FPUtil/generic/FMA.h
@@ -10,8 +10,8 @@
#define LLVM_LIBC_SRC_SUPPORT_FPUTIL_GENERIC_FMA_H
#include "src/__support/CPP/Bit.h"
-#include "src/__support/CPP/TypeTraits.h"
#include "src/__support/CPP/UInt128.h"
+#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/FloatProperties.h"
diff --git a/libc/src/__support/FPUtil/generic/FMod.h b/libc/src/__support/FPUtil/generic/FMod.h
index d33acea8bafb1..ea52020153819 100644
--- a/libc/src/__support/FPUtil/generic/FMod.h
+++ b/libc/src/__support/FPUtil/generic/FMod.h
@@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_SUPPORT_FPUTIL_GENERIC_FMOD_H
#include "src/__support/CPP/Limits.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/builtin_wrappers.h"
@@ -119,7 +119,7 @@ namespace generic {
// https://www.open-std.org/JTC1/SC22/WG14/www/docs/n1011.htm
template <typename T> struct FModExceptionalInputHandler {
- static_assert(cpp::IsFloatingPointType<T>::Value,
+ static_assert(cpp::is_floating_point_v<T>,
"FModCStandardWrapper instantiated with invalid type.");
static bool PreCheck(T x, T y, T &out) {
@@ -157,7 +157,7 @@ template <typename T> struct FModExceptionalInputHandler {
template <typename T> struct FModFastMathWrapper {
- static_assert(cpp::IsFloatingPointType<T>::Value,
+ static_assert(cpp::is_floating_point_v<T>,
"FModFastMathWrapper instantiated with invalid type.");
static bool PreCheck(T, T, T &) { return false; }
@@ -216,7 +216,7 @@ template <typename T> class FModDivisionInvMultHelper {
template <typename T, class Wrapper = FModExceptionalInputHandler<T>,
class DivisionHelper = FModDivisionSimpleHelper<T>>
class FMod {
- static_assert(cpp::IsFloatingPointType<T>::Value,
+ static_assert(cpp::is_floating_point_v<T>,
"FMod instantiated with invalid type.");
private:
diff --git a/libc/src/__support/FPUtil/generic/sqrt.h b/libc/src/__support/FPUtil/generic/sqrt.h
index 5f5d9bb00cde7..8763ac7a624e4 100644
--- a/libc/src/__support/FPUtil/generic/sqrt.h
+++ b/libc/src/__support/FPUtil/generic/sqrt.h
@@ -11,8 +11,8 @@
#include "sqrt_80_bit_long_double.h"
#include "src/__support/CPP/Bit.h"
-#include "src/__support/CPP/TypeTraits.h"
#include "src/__support/CPP/UInt128.h"
+#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/PlatformDefs.h"
@@ -64,8 +64,7 @@ inline void normalize<long double>(int &exponent, UInt128 &mantissa) {
// Correctly rounded IEEE 754 SQRT for all rounding modes.
// Shift-and-add algorithm.
template <typename T>
-static inline cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, T>
-sqrt(T x) {
+static inline cpp::enable_if_t<cpp::is_floating_point_v<T>, T> sqrt(T x) {
if constexpr (internal::SpecialLongDouble<T>::VALUE) {
// Special 80-bit long double.
diff --git a/libc/src/__support/FPUtil/x86_64/FMA.h b/libc/src/__support/FPUtil/x86_64/FMA.h
index f48af3393e910..d335585ef3015 100644
--- a/libc/src/__support/FPUtil/x86_64/FMA.h
+++ b/libc/src/__support/FPUtil/x86_64/FMA.h
@@ -19,15 +19,14 @@
#error "FMA instructions are not supported"
#endif
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include <immintrin.h>
namespace __llvm_libc {
namespace fputil {
template <typename T>
-static inline cpp::EnableIfType<cpp::IsSame<T, float>::Value, T> fma(T x, T y,
- T z) {
+static inline cpp::enable_if_t<cpp::is_same_v<T, float>, T> fma(T x, T y, T z) {
float result;
__m128 xmm = _mm_load_ss(&x); // NOLINT
__m128 ymm = _mm_load_ss(&y); // NOLINT
@@ -38,8 +37,8 @@ static inline cpp::EnableIfType<cpp::IsSame<T, float>::Value, T> fma(T x, T y,
}
template <typename T>
-static inline cpp::EnableIfType<cpp::IsSame<T, double>::Value, T> fma(T x, T y,
- T z) {
+static inline cpp::enable_if_t<cpp::is_same_v<T, double>, T> fma(T x, T y,
+ T z) {
double result;
__m128d xmm = _mm_load_sd(&x); // NOLINT
__m128d ymm = _mm_load_sd(&y); // NOLINT
diff --git a/libc/src/__support/FPUtil/x86_64/LongDoubleBits.h b/libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
index a3584c9d38851..edae1534be7e4 100644
--- a/libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
+++ b/libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
@@ -100,7 +100,7 @@ template <> struct FPBits<long double> {
FPBits() : bits(0) {}
template <typename XType,
- cpp::EnableIfType<cpp::IsSame<long double, XType>::Value, int> = 0>
+ cpp::enable_if_t<cpp::is_same_v<long double, XType>, int> = 0>
explicit FPBits(XType x) : bits(__llvm_libc::bit_cast<UIntType>(x)) {
// bits starts uninitialized, and setting it to a long double only
// overwrites the first 80 bits. This clears those upper bits.
@@ -108,7 +108,7 @@ template <> struct FPBits<long double> {
}
template <typename XType,
- cpp::EnableIfType<cpp::IsSame<XType, UIntType>::Value, int> = 0>
+ cpp::enable_if_t<cpp::is_same_v<XType, UIntType>, int> = 0>
explicit FPBits(XType x) : bits(x) {}
operator long double() { return __llvm_libc::bit_cast<long double>(bits); }
diff --git a/libc/src/__support/integer_operations.h b/libc/src/__support/integer_operations.h
index ffb4ec5c1091a..22c1683684464 100644
--- a/libc/src/__support/integer_operations.h
+++ b/libc/src/__support/integer_operations.h
@@ -9,18 +9,17 @@
#ifndef LLVM_LIBC_SRC_STDLIB_ABS_UTILS_H
#define LLVM_LIBC_SRC_STDLIB_ABS_UTILS_H
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
namespace __llvm_libc {
template <typename T>
-static constexpr cpp::EnableIfType<cpp::IsIntegral<T>::Value, T>
-integer_abs(T n) {
+static constexpr cpp::enable_if_t<cpp::is_integral_v<T>, T> integer_abs(T n) {
return (n < 0) ? -n : n;
}
template <typename T>
-static constexpr cpp::EnableIfType<cpp::IsIntegral<T>::Value, void>
+static constexpr cpp::enable_if_t<cpp::is_integral_v<T>, void>
integer_rem_quo(T x, T y, T ", T &rem) {
quot = x / y;
rem = x % y;
diff --git a/libc/src/__support/integer_to_string.h b/libc/src/__support/integer_to_string.h
index d1d04d3c11e24..b90e36b1c44b6 100644
--- a/libc/src/__support/integer_to_string.h
+++ b/libc/src/__support/integer_to_string.h
@@ -10,15 +10,15 @@
#define LLVM_LIBC_SRC_SUPPORT_INTEGER_TO_STRING_H
#include "src/__support/CPP/StringView.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
namespace __llvm_libc {
template <typename T> class IntegerToString {
- static_assert(cpp::IsIntegral<T>::Value,
+ static_assert(cpp::is_integral_v<T>,
"IntegerToString can only be used with integral types.");
- using UnsignedType = cpp::MakeUnsignedType<T>;
+ using UnsignedType = cpp::make_unsigned_t<T>;
// We size the string buffer using an approximation algorithm:
//
@@ -39,7 +39,7 @@ template <typename T> class IntegerToString {
// add an additional byte to accommodate the '-' sign in case of signed
// integers.
static constexpr size_t BUFSIZE =
- (sizeof(T) * 5 + 1) / 2 + (cpp::IsSigned<T>() ? 1 : 0);
+ (sizeof(T) * 5 + 1) / 2 + (cpp::is_signed<T>() ? 1 : 0);
char strbuf[BUFSIZE] = {'\0'};
size_t len = 0;
diff --git a/libc/src/math/generic/math_utils.h b/libc/src/math/generic/math_utils.h
index e705f8c0f534b..d8cf6fd7cb380 100644
--- a/libc/src/math/generic/math_utils.h
+++ b/libc/src/math/generic/math_utils.h
@@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_MATH_MATH_UTILS_H
#include "src/__support/CPP/Bit.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include "src/__support/common.h"
#include <errno.h>
#include <math.h>
@@ -72,11 +72,11 @@ template <typename T> static inline T opt_barrier(T x) {
template <typename T> struct IsFloatOrDouble {
static constexpr bool
Value = // NOLINT so that this Value can match the ones for IsSame
- cpp::IsSame<T, float>::Value || cpp::IsSame<T, double>::Value;
+ cpp::is_same_v<T, float> || cpp::is_same_v<T, double>;
};
template <typename T>
-using EnableIfFloatOrDouble = cpp::EnableIfType<IsFloatOrDouble<T>::Value, int>;
+using EnableIfFloatOrDouble = cpp::enable_if_t<IsFloatOrDouble<T>::Value, int>;
template <typename T, EnableIfFloatOrDouble<T> = 0>
T xflow(uint32_t sign, T y) {
diff --git a/libc/src/string/memory_utils/address.h b/libc/src/string/memory_utils/address.h
index 476c3dd8d5e76..caa71be5b1da9 100644
--- a/libc/src/string/memory_utils/address.h
+++ b/libc/src/string/memory_utils/address.h
@@ -12,7 +12,7 @@
#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_COMMON_H
#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_COMMON_H
-#include "src/__support/CPP/TypeTraits.h" // cpp::ConditionalType
+#include "src/__support/CPP/type_traits.h" // cpp::ConditionalType
#include "src/string/memory_utils/utils.h" // is_power2
#include <stddef.h> // size_t
#include <stdint.h> // uint8_t, uint16_t, uint32_t, uint64_t
@@ -48,8 +48,8 @@ template <size_t Alignment, Permission P, Temporality TS> struct Address {
static constexpr Temporality TEMPORALITY = TS;
static constexpr bool IS_READ = P == Permission::Read;
static constexpr bool IS_WRITE = P == Permission::Write;
- using PointeeType = cpp::ConditionalType<!IS_WRITE, const ubyte, ubyte>;
- using VoidType = cpp::ConditionalType<!IS_WRITE, const void, void>;
+ using PointeeType = cpp::conditional_t<!IS_WRITE, const ubyte, ubyte>;
+ using VoidType = cpp::conditional_t<!IS_WRITE, const void, void>;
Address(VoidType *ptr) : ptr_(reinterpret_cast<PointeeType *>(ptr)) {}
@@ -79,15 +79,15 @@ template <size_t Alignment, Permission P, Temporality TS> struct Address {
}
};
-template <typename T> struct IsAddressType : public cpp::FalseValue {};
+template <typename T> struct IsAddressType : public cpp::false_type {};
template <size_t Alignment, Permission P, Temporality TS>
-struct IsAddressType<Address<Alignment, P, TS>> : public cpp::TrueValue {};
+struct IsAddressType<Address<Alignment, P, TS>> : public cpp::true_type {};
// Reinterpret the address as a pointer to T.
// This is not UB since the underlying pointer always refers to a `char` in a
// buffer of raw data.
template <typename T, typename AddrT> static T *as(AddrT addr) {
- static_assert(IsAddressType<AddrT>::Value);
+ static_assert(IsAddressType<AddrT>::value);
return reinterpret_cast<T *>(addr.ptr());
}
@@ -95,7 +95,7 @@ template <typename T, typename AddrT> static T *as(AddrT addr) {
// alignment whenever possible.
template <size_t ByteOffset, typename AddrT>
static auto offsetAddr(AddrT addr) {
- static_assert(IsAddressType<AddrT>::Value);
+ static_assert(IsAddressType<AddrT>::value);
return addr.template offset<ByteOffset>(ByteOffset);
}
@@ -103,7 +103,7 @@ static auto offsetAddr(AddrT addr) {
// address will be Alignment aligned.
template <size_t Alignment, typename AddrT>
static auto offsetAddrAssumeAligned(AddrT addr, size_t byte_offset) {
- static_assert(IsAddressType<AddrT>::Value);
+ static_assert(IsAddressType<AddrT>::value);
return Address<Alignment, AddrT::PERMISSION, AddrT::TEMPORALITY>(addr.ptr_ +
byte_offset);
}
@@ -112,7 +112,7 @@ static auto offsetAddrAssumeAligned(AddrT addr, size_t byte_offset) {
// ByteOffset. This allows to propagate the address alignment whenever possible.
template <size_t ByteOffset, typename AddrT>
static auto offsetAddrMultiplesOf(AddrT addr, ptr
diff _t byte_offset) {
- static_assert(IsAddressType<AddrT>::Value);
+ static_assert(IsAddressType<AddrT>::value);
return addr.template offset<ByteOffset>(byte_offset);
}
diff --git a/libc/src/string/memory_utils/algorithm.h b/libc/src/string/memory_utils/algorithm.h
index 82c09fc7ea16b..6355ffe04562f 100644
--- a/libc/src/string/memory_utils/algorithm.h
+++ b/libc/src/string/memory_utils/algorithm.h
@@ -71,7 +71,7 @@ template <ptr
diff _t Bytes> struct Skip {
// Because of the runtime size, we loose the alignment information.
template <size_t Size, typename AddrT>
static auto tailAddr(AddrT addr, size_t runtime_size) {
- static_assert(IsAddressType<AddrT>::Value);
+ static_assert(IsAddressType<AddrT>::value);
return offsetAddrAssumeAligned<1>(addr, runtime_size - Size);
}
@@ -440,8 +440,8 @@ template <typename SizedOpT, Arg AlignOn = Arg::_1> struct Align {
template <typename Arg1AddrT, typename Arg2AddrT>
static auto align(Arg1AddrT arg1, Arg2AddrT arg2, size_t runtime_size) {
- static_assert(IsAddressType<Arg1AddrT>::Value);
- static_assert(IsAddressType<Arg2AddrT>::Value);
+ static_assert(IsAddressType<Arg1AddrT>::value);
+ static_assert(IsAddressType<Arg2AddrT>::value);
if constexpr (AlignOn == Arg::_1) {
auto offset = offset_to_next_aligned<ALIGN_OP_SIZE>(arg1.ptr_);
return makeAligned(offsetAddrAssumeAligned<ALIGN_OP_SIZE>(arg1, offset),
diff --git a/libc/src/string/memory_utils/backend_aarch64.h b/libc/src/string/memory_utils/backend_aarch64.h
index 7dc9b33c17b47..8077a098ff9c0 100644
--- a/libc/src/string/memory_utils/backend_aarch64.h
+++ b/libc/src/string/memory_utils/backend_aarch64.h
@@ -22,7 +22,7 @@ struct Aarch64Backend : public Scalar64BitBackend {
static constexpr bool IS_BACKEND_TYPE = true;
template <typename T, Temporality TS, Aligned AS,
- cpp::EnableIfType<Scalar64BitBackend::IsScalarType<T>, bool> = true>
+ cpp::enable_if_t<Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline T load(const T *src) {
return Scalar64BitBackend::template load<T, TS, AS>(src);
}
diff --git a/libc/src/string/memory_utils/backend_scalar.h b/libc/src/string/memory_utils/backend_scalar.h
index 00b8ed66d9cf1..dba36b159baa6 100644
--- a/libc/src/string/memory_utils/backend_scalar.h
+++ b/libc/src/string/memory_utils/backend_scalar.h
@@ -8,7 +8,7 @@
#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_BACKEND_SCALAR_H
#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_BACKEND_SCALAR_H
-#include "src/__support/CPP/TypeTraits.h" // ConditionalType, EnableIfType
+#include "src/__support/CPP/type_traits.h" // ConditionalType, enable_if_t
#include "src/__support/endian.h"
namespace __llvm_libc {
@@ -18,8 +18,8 @@ struct Scalar64BitBackend {
template <typename T>
static constexpr bool IsScalarType =
- cpp::IsSameV<T, uint8_t> || cpp::IsSameV<T, uint16_t> ||
- cpp::IsSameV<T, uint32_t> || cpp::IsSameV<T, uint64_t>;
+ cpp::is_same_v<T, uint8_t> || cpp::is_same_v<T, uint16_t> ||
+ cpp::is_same_v<T, uint32_t> || cpp::is_same_v<T, uint64_t>;
template <typename T, Temporality TS, Aligned AS>
static inline T load(const T *src) {
@@ -53,10 +53,10 @@ struct Scalar64BitBackend {
// Returns the type to use to consume Size bytes.
template <size_t Size>
- using getNextType = cpp::ConditionalType<
+ using getNextType = cpp::conditional_t<
Size >= 8, uint64_t,
- cpp::ConditionalType<Size >= 4, uint32_t,
- cpp::ConditionalType<Size >= 2, uint16_t, uint8_t>>>;
+ cpp::conditional_t<Size >= 4, uint32_t,
+ cpp::conditional_t<Size >= 2, uint16_t, uint8_t>>>;
};
template <>
diff --git a/libc/src/string/memory_utils/backend_x86.h b/libc/src/string/memory_utils/backend_x86.h
index aee1d2275e0ba..cfdfcdf90131c 100644
--- a/libc/src/string/memory_utils/backend_x86.h
+++ b/libc/src/string/memory_utils/backend_x86.h
@@ -9,7 +9,7 @@
#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_BACKEND_X86_H
#if defined(LLVM_LIBC_ARCH_X86)
-#include "src/__support/CPP/TypeTraits.h" // ConditionalType, EnableIfType
+#include "src/__support/CPP/type_traits.h" // ConditionalType, enable_if_t
#include "src/string/memory_utils/backend_scalar.h"
#ifdef __SSE2__
@@ -40,63 +40,61 @@ struct X86Backend : public Scalar64BitBackend {
// Scalar types use base class implementations.
template <typename T, Temporality TS, Aligned AS,
- cpp::EnableIfType<Scalar64BitBackend::IsScalarType<T>, bool> = true>
+ cpp::enable_if_t<Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline T load(const T *src) {
return Scalar64BitBackend::template load<T, TS, AS>(src);
}
// Scalar types use base class implementations.
template <typename T, Temporality TS, Aligned AS,
- cpp::EnableIfType<Scalar64BitBackend::IsScalarType<T>, bool> = true>
+ cpp::enable_if_t<Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline void store(T *dst, T value) {
Scalar64BitBackend::template store<T, TS, AS>(dst, value);
}
// Scalar types use base class implementations.
template <typename T,
- cpp::EnableIfType<Scalar64BitBackend::IsScalarType<T>, bool> = true>
+ cpp::enable_if_t<Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline uint64_t notEquals(T v1, T v2) {
return Scalar64BitBackend::template notEquals<T>(v1, v2);
}
// Scalar types use base class implementations.
template <typename T,
- cpp::EnableIfType<Scalar64BitBackend::IsScalarType<T>, bool> = true>
+ cpp::enable_if_t<Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline T splat(ubyte value) {
return Scalar64BitBackend::template splat<T>(value);
}
// Scalar types use base class implementations.
template <typename T,
- cpp::EnableIfType<Scalar64BitBackend::IsScalarType<T>, bool> = true>
+ cpp::enable_if_t<Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline int32_t threeWayCmp(T v1, T v2) {
return Scalar64BitBackend::template threeWayCmp<T>(v1, v2);
}
// X86 types are specialized below.
- template <
- typename T, Temporality TS, Aligned AS,
- cpp::EnableIfType<!Scalar64BitBackend::IsScalarType<T>, bool> = true>
+ template <typename T, Temporality TS, Aligned AS,
+ cpp::enable_if_t<!Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline T load(const T *src);
// X86 types are specialized below.
- template <
- typename T, Temporality TS, Aligned AS,
- cpp::EnableIfType<!Scalar64BitBackend::IsScalarType<T>, bool> = true>
+ template <typename T, Temporality TS, Aligned AS,
+ cpp::enable_if_t<!Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline void store(T *dst, T value);
// X86 types are specialized below.
- template <typename T, cpp::EnableIfType<!Scalar64BitBackend::IsScalarType<T>,
- bool> = true>
+ template <typename T,
+ cpp::enable_if_t<!Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline T splat(ubyte value);
// X86 types are specialized below.
- template <typename T, cpp::EnableIfType<!Scalar64BitBackend::IsScalarType<T>,
- bool> = true>
+ template <typename T,
+ cpp::enable_if_t<!Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline uint64_t notEquals(T v1, T v2);
- template <typename T, cpp::EnableIfType<!Scalar64BitBackend::IsScalarType<T>,
- bool> = true>
+ template <typename T,
+ cpp::enable_if_t<!Scalar64BitBackend::IsScalarType<T>, bool> = true>
static inline int32_t threeWayCmp(T v1, T v2) {
return char_
diff (reinterpret_cast<char *>(&v1),
reinterpret_cast<char *>(&v2), notEquals(v1, v2));
@@ -104,12 +102,12 @@ struct X86Backend : public Scalar64BitBackend {
// Returns the type to use to consume Size bytes.
template <size_t Size>
- using getNextType = cpp::ConditionalType<
+ using getNextType = cpp::conditional_t<
(HAS_M512 && Size >= 64), __m512i,
- cpp::ConditionalType<
+ cpp::conditional_t<
(HAS_M256 && Size >= 32), __m256i,
- cpp::ConditionalType<(HAS_M128 && Size >= 16), __m128i,
- Scalar64BitBackend::getNextType<Size>>>>;
+ cpp::conditional_t<(HAS_M128 && Size >= 16), __m128i,
+ Scalar64BitBackend::getNextType<Size>>>>;
private:
static inline int32_t char_
diff (const char *a, const char *b, uint64_t mask) {
diff --git a/libc/src/string/memory_utils/sized_op.h b/libc/src/string/memory_utils/sized_op.h
index 17b963a36776e..2bca50d6c56d1 100644
--- a/libc/src/string/memory_utils/sized_op.h
+++ b/libc/src/string/memory_utils/sized_op.h
@@ -50,7 +50,7 @@ template <typename Backend, size_t Size> struct SizedOp {
// This is possible because the address type carries known compile-time
// alignment informations.
template <typename T, typename AddrT> static constexpr Aligned isAligned() {
- static_assert(IsAddressType<AddrT>::Value);
+ static_assert(IsAddressType<AddrT>::value);
return AddrT::ALIGNMENT > 1 && AddrT::ALIGNMENT >= sizeof(T) ? Aligned::YES
: Aligned::NO;
}
@@ -59,7 +59,7 @@ template <typename Backend, size_t Size> struct SizedOp {
// This function is responsible for extracting Temporality and Alignment from
// the Address type.
template <typename SrcAddrT> static inline auto nativeLoad(SrcAddrT src) {
- static_assert(IsAddressType<SrcAddrT>::Value && SrcAddrT::IS_READ);
+ static_assert(IsAddressType<SrcAddrT>::value && SrcAddrT::IS_READ);
constexpr auto AS = isAligned<type, SrcAddrT>();
constexpr auto TS = SrcAddrT::TEMPORALITY;
return Backend::template load<type, TS, AS>(as<const type>(src));
@@ -70,7 +70,7 @@ template <typename Backend, size_t Size> struct SizedOp {
// the Address type.
template <typename DstAddrT>
static inline void nativeStore(type value, DstAddrT dst) {
- static_assert(IsAddressType<DstAddrT>::Value && DstAddrT::IS_WRITE);
+ static_assert(IsAddressType<DstAddrT>::value && DstAddrT::IS_WRITE);
constexpr auto AS = isAligned<type, DstAddrT>();
constexpr auto TS = DstAddrT::TEMPORALITY;
return Backend::template store<type, TS, AS>(as<type>(dst), value);
@@ -85,8 +85,8 @@ template <typename Backend, size_t Size> struct SizedOp {
public:
template <typename DstAddrT, typename SrcAddrT>
static inline void copy(DstAddrT dst, SrcAddrT src) {
- static_assert(IsAddressType<DstAddrT>::Value && DstAddrT::IS_WRITE);
- static_assert(IsAddressType<SrcAddrT>::Value && SrcAddrT::IS_READ);
+ static_assert(IsAddressType<DstAddrT>::value && DstAddrT::IS_WRITE);
+ static_assert(IsAddressType<SrcAddrT>::value && SrcAddrT::IS_READ);
if constexpr (LLVM_LIBC_USE_BUILTIN_MEMCPY_INLINE &&
DstAddrT::TEMPORALITY == Temporality::TEMPORAL &&
SrcAddrT::TEMPORALITY == Temporality::TEMPORAL) {
diff --git a/libc/test/src/__support/CPP/integer_sequence_test.cpp b/libc/test/src/__support/CPP/integer_sequence_test.cpp
index c2c0a9c00ef28..6cee9dd9aa135 100644
--- a/libc/test/src/__support/CPP/integer_sequence_test.cpp
+++ b/libc/test/src/__support/CPP/integer_sequence_test.cpp
@@ -12,13 +12,13 @@
using namespace __llvm_libc::cpp;
TEST(LlvmLibcIntegerSequencetTest, Basic) {
- EXPECT_TRUE((IsSameV<IntegerSequence<int>, MakeIntegerSequence<int, 0>>));
+ EXPECT_TRUE((is_same_v<IntegerSequence<int>, MakeIntegerSequence<int, 0>>));
using ISeq = IntegerSequence<int, 0, 1, 2, 3>;
- EXPECT_TRUE((IsSameV<ISeq, MakeIntegerSequence<int, 4>>));
+ EXPECT_TRUE((is_same_v<ISeq, MakeIntegerSequence<int, 4>>));
using LSeq = IntegerSequence<long, 0, 1, 2, 3>;
- EXPECT_TRUE((IsSameV<LSeq, MakeIntegerSequence<long, 4>>));
+ EXPECT_TRUE((is_same_v<LSeq, MakeIntegerSequence<long, 4>>));
using ULLSeq = IntegerSequence<unsigned long long, 0ull, 1ull, 2ull, 3ull>;
- EXPECT_TRUE((IsSameV<ULLSeq, MakeIntegerSequence<unsigned long long, 4>>));
+ EXPECT_TRUE((is_same_v<ULLSeq, MakeIntegerSequence<unsigned long long, 4>>));
}
template <typename T, T... Ts>
diff --git a/libc/test/src/math/NextAfterTest.h b/libc/test/src/math/NextAfterTest.h
index 1554dcb905d4e..3ec698311909f 100644
--- a/libc/test/src/math/NextAfterTest.h
+++ b/libc/test/src/math/NextAfterTest.h
@@ -10,7 +10,7 @@
#define LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
#include "src/__support/CPP/Bit.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "utils/UnitTest/FPMatcher.h"
diff --git a/libc/test/src/math/exhaustive/exhaustive_test.h b/libc/test/src/math/exhaustive/exhaustive_test.h
index 6c2d207f7feb1..7e371e87db184 100644
--- a/libc/test/src/math/exhaustive/exhaustive_test.h
+++ b/libc/test/src/math/exhaustive/exhaustive_test.h
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FPBits.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include "utils/UnitTest/Test.h"
@@ -21,7 +21,7 @@ template <typename T, typename FloatType = float>
struct LlvmLibcExhaustiveTest : public __llvm_libc::testing::Test {
static constexpr T increment = (1 << 20);
static_assert(
- __llvm_libc::cpp::IsSameV<
+ __llvm_libc::cpp::is_same_v<
T, typename __llvm_libc::fputil::FPBits<FloatType>::UIntType>,
"Types are not consistent");
// Break [start, stop) into `nthreads` subintervals and apply *check to each
diff --git a/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp b/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp
index 9af7e87ec8f07..f990d64a69ac1 100644
--- a/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp
+++ b/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp
@@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/generic/FMod.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include "utils/UnitTest/FPMatcher.h"
@@ -19,7 +19,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
template <typename T, bool InverseMultiplication>
class LlvmLibcFModTest : public __llvm_libc::testing::Test {
- using DivisionHelper = __llvm_libc::cpp::ConditionalType<
+ using DivisionHelper = __llvm_libc::cpp::conditional_t<
InverseMultiplication,
__llvm_libc::fputil::generic::FModDivisionInvMultHelper<T>,
__llvm_libc::fputil::generic::FModDivisionSimpleHelper<T>>;
diff --git a/libc/test/src/string/memory_utils/address_test.cpp b/libc/test/src/string/memory_utils/address_test.cpp
index 12d7b3c0d2ddb..fe9361ba573e5 100644
--- a/libc/test/src/string/memory_utils/address_test.cpp
+++ b/libc/test/src/string/memory_utils/address_test.cpp
@@ -4,10 +4,10 @@
namespace __llvm_libc {
TEST(LlvmLibcAddress, AliasAreAddresses) {
- ASSERT_TRUE(IsAddressType<SrcAddr<1>>::Value);
- ASSERT_TRUE(IsAddressType<DstAddr<1>>::Value);
- ASSERT_TRUE(IsAddressType<NtSrcAddr<1>>::Value);
- ASSERT_TRUE(IsAddressType<NtDstAddr<1>>::Value);
+ ASSERT_TRUE(IsAddressType<SrcAddr<1>>::value);
+ ASSERT_TRUE(IsAddressType<DstAddr<1>>::value);
+ ASSERT_TRUE(IsAddressType<NtSrcAddr<1>>::value);
+ ASSERT_TRUE(IsAddressType<NtDstAddr<1>>::value);
}
TEST(LlvmLibcAddress, AliasHaveRightPermissions) {
diff --git a/libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp b/libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp
index ca35dde7237d1..2400c5a5bf8a1 100644
--- a/libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp
+++ b/libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp
@@ -73,7 +73,7 @@ bool TestGeneratorMain(llvm::raw_ostream &OS, llvm::RecordKeeper &records) {
if (llvm::StringRef(returnType).contains("_Noreturn"))
returnType = "void";
- OS << " static_assert(__llvm_libc::cpp::IsSame<" << returnType << '(';
+ OS << " static_assert(__llvm_libc::cpp::is_same_v<" << returnType << '(';
auto args = functionSpec->getValueAsListOfDefs("Args");
for (size_t i = 0, size = args.size(); i < size; ++i) {
llvm::Record *argType = args[i]->getValueAsDef("ArgType");
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 695aed8f36198..906784a894aff 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -121,7 +121,7 @@ class MPFRNumber {
// conversions. Implicit conversions can potentially lead to loss of
// precision.
template <typename XType,
- cpp::EnableIfType<cpp::IsSame<float, XType>::Value, int> = 0>
+ cpp::enable_if_t<cpp::is_same_v<float, XType>, int> = 0>
explicit MPFRNumber(XType x, int precision = ExtraPrecision<XType>::VALUE,
RoundingMode rounding = RoundingMode::Nearest)
: mpfr_precision(precision),
@@ -131,7 +131,7 @@ class MPFRNumber {
}
template <typename XType,
- cpp::EnableIfType<cpp::IsSame<double, XType>::Value, int> = 0>
+ cpp::enable_if_t<cpp::is_same_v<double, XType>, int> = 0>
explicit MPFRNumber(XType x, int precision = ExtraPrecision<XType>::VALUE,
RoundingMode rounding = RoundingMode::Nearest)
: mpfr_precision(precision),
@@ -141,7 +141,7 @@ class MPFRNumber {
}
template <typename XType,
- cpp::EnableIfType<cpp::IsSame<long double, XType>::Value, int> = 0>
+ cpp::enable_if_t<cpp::is_same_v<long double, XType>, int> = 0>
explicit MPFRNumber(XType x, int precision = ExtraPrecision<XType>::VALUE,
RoundingMode rounding = RoundingMode::Nearest)
: mpfr_precision(precision),
@@ -151,7 +151,7 @@ class MPFRNumber {
}
template <typename XType,
- cpp::EnableIfType<cpp::IsIntegral<XType>::Value, int> = 0>
+ cpp::enable_if_t<cpp::is_integral_v<XType>, int> = 0>
explicit MPFRNumber(XType x, int precision = ExtraPrecision<float>::VALUE,
RoundingMode rounding = RoundingMode::Nearest)
: mpfr_precision(precision),
@@ -396,7 +396,7 @@ class MPFRNumber {
// of N between this number and [input].
// 4. A values of +0.0 and -0.0 are treated as equal.
template <typename T>
- cpp::EnableIfType<cpp::IsFloatingPointType<T>::Value, double> ulp(T input) {
+ cpp::enable_if_t<cpp::is_floating_point_v<T>, double> ulp(T input) {
T thisAsT = as<T>();
if (thisAsT == input)
return T(0.0);
@@ -470,7 +470,7 @@ template <> long double MPFRNumber::as<long double>() const {
namespace internal {
template <typename InputType>
-cpp::EnableIfType<cpp::IsFloatingPointType<InputType>::Value, MPFRNumber>
+cpp::enable_if_t<cpp::is_floating_point_v<InputType>, MPFRNumber>
unary_operation(Operation op, InputType input, unsigned int precision,
RoundingMode rounding) {
MPFRNumber mpfrInput(input, precision, rounding);
@@ -519,7 +519,7 @@ unary_operation(Operation op, InputType input, unsigned int precision,
}
template <typename InputType>
-cpp::EnableIfType<cpp::IsFloatingPointType<InputType>::Value, MPFRNumber>
+cpp::enable_if_t<cpp::is_floating_point_v<InputType>, MPFRNumber>
unary_operation_two_outputs(Operation op, InputType input, int &output,
unsigned int precision, RoundingMode rounding) {
MPFRNumber mpfrInput(input, precision, rounding);
@@ -532,7 +532,7 @@ unary_operation_two_outputs(Operation op, InputType input, int &output,
}
template <typename InputType>
-cpp::EnableIfType<cpp::IsFloatingPointType<InputType>::Value, MPFRNumber>
+cpp::enable_if_t<cpp::is_floating_point_v<InputType>, MPFRNumber>
binary_operation_one_output(Operation op, InputType x, InputType y,
unsigned int precision, RoundingMode rounding) {
MPFRNumber inputX(x, precision, rounding);
@@ -548,7 +548,7 @@ binary_operation_one_output(Operation op, InputType x, InputType y,
}
template <typename InputType>
-cpp::EnableIfType<cpp::IsFloatingPointType<InputType>::Value, MPFRNumber>
+cpp::enable_if_t<cpp::is_floating_point_v<InputType>, MPFRNumber>
binary_operation_two_outputs(Operation op, InputType x, InputType y,
int &output, unsigned int precision,
RoundingMode rounding) {
@@ -563,7 +563,7 @@ binary_operation_two_outputs(Operation op, InputType x, InputType y,
}
template <typename InputType>
-cpp::EnableIfType<cpp::IsFloatingPointType<InputType>::Value, MPFRNumber>
+cpp::enable_if_t<cpp::is_floating_point_v<InputType>, MPFRNumber>
ternary_operation_one_output(Operation op, InputType x, InputType y,
InputType z, unsigned int precision,
RoundingMode rounding) {
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.h b/libc/utils/MPFRWrapper/MPFRUtils.h
index 1c80ea9a5c23a..fa98bc1951213 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.h
+++ b/libc/utils/MPFRWrapper/MPFRUtils.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_UTILS_TESTUTILS_MPFRUTILS_H
#define LLVM_LIBC_UTILS_TESTUTILS_MPFRUTILS_H
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include "utils/UnitTest/Test.h"
#include "utils/testutils/RoundingModeUtils.h"
@@ -81,7 +81,7 @@ using __llvm_libc::testutils::RoundingMode;
template <typename T> struct BinaryInput {
static_assert(
- __llvm_libc::cpp::IsFloatingPointType<T>::Value,
+ __llvm_libc::cpp::is_floating_point_v<T>,
"Template parameter of BinaryInput must be a floating point type.");
using Type = T;
@@ -90,7 +90,7 @@ template <typename T> struct BinaryInput {
template <typename T> struct TernaryInput {
static_assert(
- __llvm_libc::cpp::IsFloatingPointType<T>::Value,
+ __llvm_libc::cpp::is_floating_point_v<T>,
"Template parameter of TernaryInput must be a floating point type.");
using Type = T;
@@ -111,7 +111,7 @@ struct AreMatchingBinaryInputAndBinaryOutput {
template <typename T>
struct AreMatchingBinaryInputAndBinaryOutput<BinaryInput<T>, BinaryOutput<T>> {
- static constexpr bool VALUE = cpp::IsFloatingPointType<T>::Value;
+ static constexpr bool VALUE = cpp::is_floating_point_v<T>;
};
template <typename T>
@@ -260,30 +260,30 @@ template <Operation op, typename InputType, typename OutputType>
constexpr bool is_valid_operation() {
return (Operation::BeginUnaryOperationsSingleOutput < op &&
op < Operation::EndUnaryOperationsSingleOutput &&
- cpp::IsSame<InputType, OutputType>::Value &&
- cpp::IsFloatingPointType<InputType>::Value) ||
+ cpp::is_same_v<InputType, OutputType> &&
+ cpp::is_floating_point_v<InputType>) ||
(Operation::BeginUnaryOperationsTwoOutputs < op &&
op < Operation::EndUnaryOperationsTwoOutputs &&
- cpp::IsFloatingPointType<InputType>::Value &&
- cpp::IsSame<OutputType, BinaryOutput<InputType>>::Value) ||
+ cpp::is_floating_point_v<InputType> &&
+ cpp::is_same_v<OutputType, BinaryOutput<InputType>>) ||
(Operation::BeginBinaryOperationsSingleOutput < op &&
op < Operation::EndBinaryOperationsSingleOutput &&
- cpp::IsFloatingPointType<OutputType>::Value &&
- cpp::IsSame<InputType, BinaryInput<OutputType>>::Value) ||
+ cpp::is_floating_point_v<OutputType> &&
+ cpp::is_same_v<InputType, BinaryInput<OutputType>>) ||
(Operation::BeginBinaryOperationsTwoOutputs < op &&
op < Operation::EndBinaryOperationsTwoOutputs &&
internal::AreMatchingBinaryInputAndBinaryOutput<InputType,
OutputType>::VALUE) ||
(Operation::BeginTernaryOperationsSingleOuput < op &&
op < Operation::EndTernaryOperationsSingleOutput &&
- cpp::IsFloatingPointType<OutputType>::Value &&
- cpp::IsSame<InputType, TernaryInput<OutputType>>::Value);
+ cpp::is_floating_point_v<OutputType> &&
+ cpp::is_same_v<InputType, TernaryInput<OutputType>>);
}
template <Operation op, typename InputType, typename OutputType>
__attribute__((no_sanitize("address")))
-cpp::EnableIfType<is_valid_operation<op, InputType, OutputType>(),
- internal::MPFRMatcher<op, InputType, OutputType>>
+cpp::enable_if_t<is_valid_operation<op, InputType, OutputType>(),
+ internal::MPFRMatcher<op, InputType, OutputType>>
get_mpfr_matcher(InputType input, OutputType output_unused,
double ulp_tolerance, RoundingMode rounding) {
return internal::MPFRMatcher<op, InputType, OutputType>(input, ulp_tolerance,
diff --git a/libc/utils/UnitTest/FPMatcher.cpp b/libc/utils/UnitTest/FPMatcher.cpp
index d13cfa041b1dc..d6ce67e96cd47 100644
--- a/libc/utils/UnitTest/FPMatcher.cpp
+++ b/libc/utils/UnitTest/FPMatcher.cpp
@@ -20,7 +20,7 @@ namespace fputil {
namespace testing {
template <typename ValType, typename StreamType>
-cpp::EnableIfType<cpp::IsFloatingPointType<ValType>::Value, void>
+cpp::enable_if_t<cpp::is_floating_point_v<ValType>, void>
describeValue(const char *label, ValType value, StreamType &stream) {
stream << label;
diff --git a/libc/utils/UnitTest/FPMatcher.h b/libc/utils/UnitTest/FPMatcher.h
index 06d0af2d1eaf8..0dd9754035e33 100644
--- a/libc/utils/UnitTest/FPMatcher.h
+++ b/libc/utils/UnitTest/FPMatcher.h
@@ -21,12 +21,12 @@ namespace fputil {
namespace testing {
template <typename ValType, typename StreamType>
-cpp::EnableIfType<cpp::IsFloatingPointType<ValType>::Value, void>
+cpp::enable_if_t<cpp::is_floating_point_v<ValType>, void>
describeValue(const char *label, ValType value, StreamType &stream);
template <typename T, __llvm_libc::testing::TestCondition Condition>
class FPMatcher : public __llvm_libc::testing::Matcher<T> {
- static_assert(__llvm_libc::cpp::IsFloatingPointType<T>::Value,
+ static_assert(__llvm_libc::cpp::is_floating_point_v<T>,
"FPMatcher can only be used with floating point values.");
static_assert(Condition == __llvm_libc::testing::Cond_EQ ||
Condition == __llvm_libc::testing::Cond_NE,
diff --git a/libc/utils/UnitTest/LibcTest.cpp b/libc/utils/UnitTest/LibcTest.cpp
index 42b99a2b951c0..1153084065399 100644
--- a/libc/utils/UnitTest/LibcTest.cpp
+++ b/libc/utils/UnitTest/LibcTest.cpp
@@ -36,7 +36,7 @@ namespace internal {
// When the value is of integral type, just display it as normal.
template <typename ValType>
-cpp::EnableIfType<cpp::IsIntegral<ValType>::Value, std::string>
+cpp::enable_if_t<cpp::is_integral_v<ValType>, std::string>
describeValue(ValType Value) {
return std::to_string(Value);
}
diff --git a/libc/utils/UnitTest/LibcTest.h b/libc/utils/UnitTest/LibcTest.h
index c5bb4296ddc94..27a2c2380eb00 100644
--- a/libc/utils/UnitTest/LibcTest.h
+++ b/libc/utils/UnitTest/LibcTest.h
@@ -14,7 +14,7 @@
#include "PlatformDefs.h"
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include "utils/testutils/ExecuteFunction.h"
#include "utils/testutils/StreamWrapper.h"
@@ -83,23 +83,22 @@ class Test {
// |Cond| on mismatched |LHS| and |RHS| types can potentially succeed because
// of type promotion.
template <typename ValType,
- cpp::EnableIfType<cpp::IsIntegral<ValType>::Value, int> = 0>
+ cpp::enable_if_t<cpp::is_integral_v<ValType>, int> = 0>
bool test(TestCondition Cond, ValType LHS, ValType RHS, const char *LHSStr,
const char *RHSStr, const char *File, unsigned long Line) {
return internal::test(Ctx, Cond, LHS, RHS, LHSStr, RHSStr, File, Line);
}
template <typename ValType,
- cpp::EnableIfType<cpp::IsEnum<ValType>::Value, int> = 0>
+ cpp::enable_if_t<cpp::is_enum<ValType>::value, int> = 0>
bool test(TestCondition Cond, ValType LHS, ValType RHS, const char *LHSStr,
const char *RHSStr, const char *File, unsigned long Line) {
return internal::test(Ctx, Cond, (long long)LHS, (long long)RHS, LHSStr,
RHSStr, File, Line);
}
- template <
- typename ValType,
- cpp::EnableIfType<cpp::IsPointerType<ValType>::Value, ValType> = nullptr>
+ template <typename ValType,
+ cpp::enable_if_t<cpp::is_pointer_v<ValType>, ValType> = nullptr>
bool test(TestCondition Cond, ValType LHS, ValType RHS, const char *LHSStr,
const char *RHSStr, const char *File, unsigned long Line) {
return internal::test(Ctx, Cond, (unsigned long long)LHS,
diff --git a/libc/utils/UnitTest/StringUtils.h b/libc/utils/UnitTest/StringUtils.h
index 3d5577c8077ec..d9398c9fbc159 100644
--- a/libc/utils/UnitTest/StringUtils.h
+++ b/libc/utils/UnitTest/StringUtils.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_UTILS_UNITTEST_SIMPLE_STRING_CONV_H
#define LLVM_LIBC_UTILS_UNITTEST_SIMPLE_STRING_CONV_H
-#include "src/__support/CPP/TypeTraits.h"
+#include "src/__support/CPP/type_traits.h"
#include <string>
@@ -17,7 +17,7 @@ namespace __llvm_libc {
// Return the first N hex digits of an integer as a string in upper case.
template <typename T>
-cpp::EnableIfType<cpp::IsIntegral<T>::Value, std::string>
+cpp::enable_if_t<cpp::is_integral_v<T>, std::string>
int_to_hex(T X, size_t Length = sizeof(T) * 2) {
std::string s(Length, '0');
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 77a5dfc8eaba0..0f1ad32927774 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -100,7 +100,7 @@ cc_library(
cc_library(
name = "__support_cpp_type_traits",
hdrs = [
- "src/__support/CPP/TypeTraits.h",
+ "src/__support/CPP/type_traits.h",
],
deps = [":libc_root","__support_cpp_uint"],
)
More information about the libc-commits
mailing list