391 changes: 49 additions & 342 deletions libc/src/__support/CPP/type_traits.h

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions libc/src/__support/CPP/type_traits/add_lvalue_reference.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===-- add_lvalue_reference 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_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H

#include "src/__support/CPP/type_traits/type_identity.h"

namespace __llvm_libc::cpp {

// add_lvalue_reference
namespace detail {
template <class T> // Note that `cv void&` is a substitution failure
auto try_add_lvalue_reference(int) -> cpp::type_identity<T &>;
template <class T> // Handle T = cv void case
auto try_add_lvalue_reference(...) -> cpp::type_identity<T>;
} // namespace detail
template <class T>
struct add_lvalue_reference : decltype(detail::try_add_lvalue_reference<T>(0)) {
};

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
28 changes: 28 additions & 0 deletions libc/src/__support/CPP/type_traits/add_pointer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===-- add_pointer 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_TYPE_TRAITS_ADD_POINTER_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H

#include "src/__support/CPP/type_traits/remove_reference.h"
#include "src/__support/CPP/type_traits/type_identity.h"
#include "src/__support/macros/config.h"

namespace __llvm_libc::cpp {

// add_pointer
namespace detail {
template <class T>
auto try_add_pointer(int) -> cpp::type_identity<cpp::remove_reference_t<T> *>;
template <class T> auto try_add_pointer(...) -> cpp::type_identity<T>;
} // namespace detail
template <class T>
struct add_pointer : decltype(detail::try_add_pointer<T>(0)) {};
template <class T> using add_pointer_t = typename add_pointer<T>::type;
} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H
29 changes: 29 additions & 0 deletions libc/src/__support/CPP/type_traits/add_rvalue_reference.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//===-- add_rvalue_reference 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_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H

#include "src/__support/CPP/type_traits/type_identity.h"

namespace __llvm_libc::cpp {

// add_rvalue_reference
namespace detail {
template <class T>
auto try_add_rvalue_reference(int) -> cpp::type_identity<T &&>;
template <class T> auto try_add_rvalue_reference(...) -> cpp::type_identity<T>;
} // namespace detail
template <class T>
struct add_rvalue_reference : decltype(detail::try_add_rvalue_reference<T>(0)) {
};
template <class T>
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
20 changes: 20 additions & 0 deletions libc/src/__support/CPP/type_traits/bool_constant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- bool_constant 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_TYPE_TRAITS_BOOL_CONSTANT_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H

#include "src/__support/CPP/type_traits/integral_constant.h"

namespace __llvm_libc::cpp {

// bool_constant
template <bool V> using bool_constant = cpp::integral_constant<bool, V>;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H
25 changes: 25 additions & 0 deletions libc/src/__support/CPP/type_traits/conditional.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===-- conditional 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_TYPE_TRAITS_CONDITIONAL_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H

#include "src/__support/CPP/type_traits/type_identity.h"

namespace __llvm_libc::cpp {

// conditional
template <bool B, typename T, typename F>
struct conditional : type_identity<T> {};
template <typename T, typename F>
struct conditional<false, T, F> : type_identity<F> {};
template <bool B, typename T, typename F>
using conditional_t = typename conditional<B, T, F>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H
38 changes: 38 additions & 0 deletions libc/src/__support/CPP/type_traits/decay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//===-- decay 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_TYPE_TRAITS_DECAY_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_DECAY_H

#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

#include "src/__support/CPP/type_traits/add_pointer.h"
#include "src/__support/CPP/type_traits/conditional.h"
#include "src/__support/CPP/type_traits/is_array.h"
#include "src/__support/CPP/type_traits/is_function.h"
#include "src/__support/CPP/type_traits/remove_cv.h"
#include "src/__support/CPP/type_traits/remove_extent.h"
#include "src/__support/CPP/type_traits/remove_reference.h"

namespace __llvm_libc::cpp {

// decay
template <class T> class decay {
using U = cpp::remove_reference_t<T>;

public:
using type = conditional_t<
cpp::is_array_v<U>, cpp::add_pointer_t<cpp::remove_extent_t<U>>,
cpp::conditional_t<cpp::is_function_v<U>, cpp::add_pointer_t<U>,
cpp::remove_cv_t<U>>>;
};
template <class T> using decay_t = typename decay<T>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_DECAY_H
23 changes: 23 additions & 0 deletions libc/src/__support/CPP/type_traits/enable_if.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===-- enable_if 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_TYPE_TRAITS_ENABLE_IF_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H

#include "src/__support/CPP/type_traits/type_identity.h"

namespace __llvm_libc::cpp {

// enable_if
template <bool B, typename T> struct enable_if;
template <typename T> struct enable_if<true, T> : type_identity<T> {};
template <bool B, typename T = void>
using enable_if_t = typename enable_if<B, T>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H
20 changes: 20 additions & 0 deletions libc/src/__support/CPP/type_traits/false_type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- false_type 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_TYPE_TRAITS_FALSE_TYPE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H

#include "src/__support/CPP/type_traits/bool_constant.h"

namespace __llvm_libc::cpp {

// false_type
using false_type = cpp::bool_constant<false>;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H
23 changes: 23 additions & 0 deletions libc/src/__support/CPP/type_traits/integral_constant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===-- integral_constant 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_TYPE_TRAITS_INTEGRAL_CONSTANT_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H

#include "src/__support/macros/attributes.h" // LIBC_INLINE_VAR

namespace __llvm_libc::cpp {

// integral_constant
template <typename T, T v> struct integral_constant {
using value_type = T;
LIBC_INLINE_VAR static constexpr T value = v;
};

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H
27 changes: 27 additions & 0 deletions libc/src/__support/CPP/type_traits/is_arithmetic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//===-- is_arithmetic 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_TYPE_TRAITS_IS_ARITHMETIC_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/CPP/type_traits/is_floating_point.h"
#include "src/__support/CPP/type_traits/is_integral.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_arithmetic
template <typename T>
struct is_arithmetic : cpp::bool_constant<(cpp::is_integral_v<T> ||
cpp::is_floating_point_v<T>)> {};
template <typename T>
LIBC_INLINE_VAR constexpr bool is_arithmetic_v = is_arithmetic<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H
28 changes: 28 additions & 0 deletions libc/src/__support/CPP/type_traits/is_array.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===-- is_array 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_TYPE_TRAITS_IS_ARRAY_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H

#include "src/__support/CPP/type_traits/false_type.h"
#include "src/__support/CPP/type_traits/true_type.h"
#include "src/__support/macros/attributes.h"

#include <stddef.h> // For size_t

namespace __llvm_libc::cpp {

// is_array
template <class T> struct is_array : false_type {};
template <class T> struct is_array<T[]> : true_type {};
template <class T, size_t N> struct is_array<T[N]> : true_type {};
template <class T>
LIBC_INLINE_VAR constexpr bool is_array_v = is_array<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H
44 changes: 44 additions & 0 deletions libc/src/__support/CPP/type_traits/is_base_of.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//===-- is_base_of 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_TYPE_TRAITS_IS_BASE_OF_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H

#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
#include "src/__support/CPP/type_traits/false_type.h"
#include "src/__support/CPP/type_traits/is_class.h"
#include "src/__support/CPP/type_traits/remove_all_extents.h"
#include "src/__support/CPP/type_traits/true_type.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_base_of
namespace detail {
template <typename B> cpp::true_type __test_ptr_conv(const volatile B *);
template <typename> cpp::false_type __test_ptr_conv(const volatile void *);

template <typename B, typename D>
auto is_base_of(int) -> decltype(__test_ptr_conv<B>(static_cast<D *>(nullptr)));

template <typename, typename>
auto is_base_of(...) -> cpp::true_type; // private or ambiguous base

} // namespace detail

template <typename Base, typename Derived>
struct is_base_of
: cpp::bool_constant<
cpp::is_class_v<Base> &&
cpp::is_class_v<Derived> &&decltype(detail::is_base_of<Base, Derived>(
0))::value> {};
template <typename Base, typename Derived>
LIBC_INLINE_VAR constexpr bool is_base_of_v = is_base_of<Base, Derived>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H
29 changes: 29 additions & 0 deletions libc/src/__support/CPP/type_traits/is_class.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//===-- is_class 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_TYPE_TRAITS_IS_CLASS_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/CPP/type_traits/false_type.h"
#include "src/__support/CPP/type_traits/is_union.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_class
namespace detail {
template <class T> cpp::bool_constant<!cpp::is_union_v<T>> test(int T::*);
template <class> cpp::false_type test(...);
} // namespace detail
template <class T> struct is_class : decltype(detail::test<T>(nullptr)) {};
template <typename T>
LIBC_INLINE_VAR constexpr bool is_class_v = is_class<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H
25 changes: 25 additions & 0 deletions libc/src/__support/CPP/type_traits/is_const.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===-- is_const 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_TYPE_TRAITS_IS_CONST_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H

#include "src/__support/CPP/type_traits/false_type.h"
#include "src/__support/CPP/type_traits/true_type.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_const
template <class T> struct is_const : cpp::false_type {};
template <class T> struct is_const<const T> : cpp::true_type {};
template <class T>
LIBC_INLINE_VAR constexpr bool is_const_v = is_const<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H
45 changes: 45 additions & 0 deletions libc/src/__support/CPP/type_traits/is_convertible.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//===-- is_convertible 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_TYPE_TRAITS_IS_CONVERTIBLE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H

#include "src/__support/CPP/type_traits/is_void.h"
#include "src/__support/CPP/utility/declval.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_convertible
namespace detail {
template <class T>
auto test_returnable(int)
-> decltype(void(static_cast<T (*)()>(nullptr)), cpp::true_type{});
template <class> auto test_returnable(...) -> cpp::false_type;

template <class From, class To>
auto test_implicitly_convertible(int)
-> decltype(void(cpp::declval<void (&)(To)>()(cpp::declval<From>())),
cpp::true_type{});
template <class, class>
auto test_implicitly_convertible(...) -> cpp::false_type;
} // namespace detail

template <class From, class To>
struct is_convertible
: cpp::bool_constant<
(decltype(detail::test_returnable<To>(0))::value &&
decltype(detail::test_implicitly_convertible<From, To>(0))::value) ||
(cpp::is_void_v<From> && cpp::is_void_v<To>)> {};

template <class From, class To>
LIBC_INLINE_VAR constexpr bool is_convertible_v =
is_convertible<From, To>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H
66 changes: 66 additions & 0 deletions libc/src/__support/CPP/type_traits/is_destructible.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//===-- is_destructible 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_TYPE_TRAITS_IS_DESTRUCTIBLE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/CPP/type_traits/false_type.h"
#include "src/__support/CPP/type_traits/is_function.h"
#include "src/__support/CPP/type_traits/is_reference.h"
#include "src/__support/CPP/type_traits/remove_all_extents.h"
#include "src/__support/CPP/type_traits/true_type.h"
#include "src/__support/CPP/type_traits/type_identity.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

namespace __llvm_libc::cpp {

// is_destructible
#if LIBC_HAS_BUILTIN(__is_destructible)
template <typename T>
struct is_destructible : bool_constant<__is_destructible(T)> {};
#else
// if it's a reference, return true
// if it's a function, return false
// if it's void, return false
// if it's an array of unknown bound, return false
// Otherwise, return "declval<T&>().~T()" is well-formed
// where T is remove_all_extents<T>::type
template <typename> struct __is_destructible_apply : cpp::type_identity<int> {};
template <typename T> struct __is_destructor_wellformed {
template <typename T1>
static cpp::true_type __test(
typename __is_destructible_apply<decltype(declval<T1 &>().~T1())>::type);
template <typename T1> static cpp::false_type __test(...);
static const bool value = decltype(__test<T>(12))::value;
};
template <typename T, bool> struct __destructible_imp;
template <typename T>
struct __destructible_imp<T, false>
: public bool_constant<
__is_destructor_wellformed<cpp::remove_all_extents_t<T>>::value> {};
template <typename T>
struct __destructible_imp<T, true> : public cpp::true_type {};
template <typename T, bool> struct __destructible_false;
template <typename T>
struct __destructible_false<T, false>
: public __destructible_imp<T, is_reference<T>::value> {};
template <typename T>
struct __destructible_false<T, true> : public cpp::false_type {};
template <typename T>
struct is_destructible : public __destructible_false<T, is_function<T>::value> {
};
template <typename T> struct is_destructible<T[]> : public false_type {};
template <> struct is_destructible<void> : public false_type {};
#endif
template <class T>
LIBC_INLINE_VAR constexpr bool is_destructible_v = is_destructible<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H
23 changes: 23 additions & 0 deletions libc/src/__support/CPP/type_traits/is_enum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===-- is_enum 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_TYPE_TRAITS_IS_ENUM_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_enum
template <typename T> struct is_enum : bool_constant<__is_enum(T)> {};
template <typename T>
LIBC_INLINE_VAR constexpr bool is_enum_v = is_enum<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H
35 changes: 35 additions & 0 deletions libc/src/__support/CPP/type_traits/is_floating_point.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===-- is_floating_point 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_TYPE_TRAITS_IS_FLOATING_POINT_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H

#include "src/__support/CPP/type_traits/is_same.h"
#include "src/__support/CPP/type_traits/remove_cv.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_floating_point
template <typename T> struct is_floating_point {
private:
template <typename Head, typename... Args>
LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() {
return (... || is_same_v<remove_cv_t<Head>, Args>);
}

public:
LIBC_INLINE_VAR static constexpr bool value =
__is_unqualified_any_of<T, float, double, long double>();
};
template <typename T>
LIBC_INLINE_VAR constexpr bool is_floating_point_v =
is_floating_point<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H
33 changes: 33 additions & 0 deletions libc/src/__support/CPP/type_traits/is_function.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//===-- is_function 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_TYPE_TRAITS_IS_FUNCTION_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/CPP/type_traits/is_const.h"
#include "src/__support/CPP/type_traits/is_reference.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

namespace __llvm_libc::cpp {

// is_function
#if LIBC_HAS_BUILTIN(__is_function)
template <typename T>
struct is_function : integral_constant<bool, __is_function(T)> {};
#else
template <typename T>
struct is_function
: public bool_constant<!(is_reference_v<T> || is_const_v<const T>)> {};
#endif
template <class T>
LIBC_INLINE_VAR constexpr bool is_function_v = is_function<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H
39 changes: 39 additions & 0 deletions libc/src/__support/CPP/type_traits/is_integral.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//===-- is_integral 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_TYPE_TRAITS_IS_INTEGRAL_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H

#include "src/__support/CPP/type_traits/is_same.h"
#include "src/__support/CPP/type_traits/remove_cv.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_integral
template <typename T> struct is_integral {
private:
template <typename Head, typename... Args>
LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() {
return (... || is_same_v<remove_cv_t<Head>, Args>);
}

public:
LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of<
T,
#ifdef __SIZEOF_INT128__
__int128_t, __uint128_t,
#endif
char, signed char, unsigned char, short, unsigned short, int,
unsigned int, long, unsigned long, long long, unsigned long long, bool>();
};
template <typename T>
LIBC_INLINE_VAR constexpr bool is_integral_v = is_integral<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H
33 changes: 33 additions & 0 deletions libc/src/__support/CPP/type_traits/is_lvalue_reference.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//===-- is_lvalue_reference 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_TYPE_TRAITS_IS_LVALUE_REFERENCE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/CPP/type_traits/false_type.h"
#include "src/__support/CPP/type_traits/true_type.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

namespace __llvm_libc::cpp {

// is_lvalue_reference
#if LIBC_HAS_BUILTIN(__is_lvalue_reference)
template <typename T>
struct is_lvalue_reference : bool_constant<__is_lvalue_reference(T)> {};
#else
template <typename T> struct is_lvalue_reference : public false_type {};
template <typename T> struct is_lvalue_reference<T &> : public true_type {};
#endif
template <class T>
LIBC_INLINE_VAR constexpr bool is_lvalue_reference_v =
is_lvalue_reference<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H
24 changes: 24 additions & 0 deletions libc/src/__support/CPP/type_traits/is_null_pointer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//===-- is_null_pointer 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_TYPE_TRAITS_IS_NULL_POINTER_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H

#include "src/__support/CPP/type_traits/is_same.h"
#include "src/__support/CPP/type_traits/remove_cv.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_null_pointer
using nullptr_t = decltype(nullptr);
template <class T>
struct is_null_pointer : cpp::is_same<cpp::nullptr_t, cpp::remove_cv_t<T>> {};

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H
28 changes: 28 additions & 0 deletions libc/src/__support/CPP/type_traits/is_pointer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===-- is_pointer 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_TYPE_TRAITS_IS_POINTER_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H

#include "src/__support/CPP/type_traits/false_type.h"
#include "src/__support/CPP/type_traits/true_type.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_pointer
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>
LIBC_INLINE_VAR constexpr bool is_pointer_v = is_pointer<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H
32 changes: 32 additions & 0 deletions libc/src/__support/CPP/type_traits/is_reference.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//===-- is_reference 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_TYPE_TRAITS_IS_REFERENCE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/CPP/type_traits/false_type.h"
#include "src/__support/CPP/type_traits/true_type.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

namespace __llvm_libc::cpp {

// is_reference
#if LIBC_HAS_BUILTIN(__is_reference)
template <typename T> struct is_reference : bool_constant<__is_reference(T)> {};
#else
template <typename T> struct is_reference : public false_type {};
template <typename T> struct is_reference<T &> : public true_type {};
template <typename T> struct is_reference<T &&> : public true_type {};
#endif
template <class T>
LIBC_INLINE_VAR constexpr bool is_reference_v = is_reference<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H
32 changes: 32 additions & 0 deletions libc/src/__support/CPP/type_traits/is_rvalue_reference.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//===-- is_rvalue_reference 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_TYPE_TRAITS_IS_RVALUE_REFERENCE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/CPP/type_traits/false_type.h"
#include "src/__support/CPP/type_traits/true_type.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

namespace __llvm_libc::cpp {

// is_rvalue_reference
#if LIBC_HAS_BUILTIN(__is_rvalue_reference)
template <typename T>
struct is_rvalue_reference : bool_constant<__is_rvalue_reference(T)> {};
#else
template <typename T> struct is_rvalue_reference : public false_type {};
template <typename T> struct is_rvalue_reference<T &&> : public true_type {};
#endif
template <class T>
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H
25 changes: 25 additions & 0 deletions libc/src/__support/CPP/type_traits/is_same.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===-- is_same 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_TYPE_TRAITS_IS_SAME_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H

#include "src/__support/CPP/type_traits/false_type.h"
#include "src/__support/CPP/type_traits/true_type.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_same
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>
LIBC_INLINE_VAR constexpr bool is_same_v = is_same<T, U>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H
28 changes: 28 additions & 0 deletions libc/src/__support/CPP/type_traits/is_signed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===-- is_signed 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_TYPE_TRAITS_IS_SIGNED_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/CPP/type_traits/is_arithmetic.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_signed
template <typename T>
struct is_signed : bool_constant<(is_arithmetic_v<T> && (T(-1) < T(0)))> {
LIBC_INLINE constexpr operator bool() const { return is_signed::value; }
LIBC_INLINE constexpr bool operator()() const { return is_signed::value; }
};
template <typename T>
LIBC_INLINE_VAR constexpr bool is_signed_v = is_signed<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H
22 changes: 22 additions & 0 deletions libc/src/__support/CPP/type_traits/is_trivially_constructible.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//===-- is_trivially_constructible 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_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H

#include "src/__support/CPP/type_traits/integral_constant.h"

namespace __llvm_libc::cpp {

// is_trivially_constructible
template <class T, class... Args>
struct is_trivially_constructible
: integral_constant<bool, __is_trivially_constructible(T, Args...)> {};

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
23 changes: 23 additions & 0 deletions libc/src/__support/CPP/type_traits/is_trivially_copyable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===-- is_trivially_copyable 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_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H

#include "src/__support/CPP/type_traits/integral_constant.h"
#include "src/__support/macros/config.h"

namespace __llvm_libc::cpp {

// is_trivially_copyable
template <class T>
struct is_trivially_copyable
: public integral_constant<bool, __is_trivially_copyable(T)> {};

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H
35 changes: 35 additions & 0 deletions libc/src/__support/CPP/type_traits/is_trivially_destructible.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===-- is_trivially_destructible 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_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/CPP/type_traits/is_destructible.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

namespace __llvm_libc::cpp {

// is_trivially_destructible
#if LIBC_HAS_BUILTIN(__is_trivially_destructible)
template <typename T>
struct is_trivially_destructible
: public bool_constant<__is_trivially_destructible(T)> {};
#else
template <typename T>
struct is_trivially_destructible
: public bool_constant<cpp::is_destructible_v<T> &&__has_trivial_destructor(
T)> {};
#endif // LIBC_HAS_BUILTIN(__is_trivially_destructible)
template <typename T>
LIBC_INLINE_VAR constexpr bool is_trivially_destructible_v =
is_trivially_destructible<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
23 changes: 23 additions & 0 deletions libc/src/__support/CPP/type_traits/is_union.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===-- is_union 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_TYPE_TRAITS_IS_UNION_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_union
template <class T> struct is_union : bool_constant<__is_union(T)> {};
template <typename T>
LIBC_INLINE_VAR constexpr bool is_union_v = is_union<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H
28 changes: 28 additions & 0 deletions libc/src/__support/CPP/type_traits/is_unsigned.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===-- is_unsigned 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_TYPE_TRAITS_IS_UNSIGNED_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H

#include "src/__support/CPP/type_traits/bool_constant.h"
#include "src/__support/CPP/type_traits/is_arithmetic.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_unsigned
template <typename T>
struct is_unsigned : bool_constant<(is_arithmetic_v<T> && (T(-1) > T(0)))> {
LIBC_INLINE constexpr operator bool() const { return is_unsigned::value; }
LIBC_INLINE constexpr bool operator()() const { return is_unsigned::value; }
};
template <typename T>
LIBC_INLINE_VAR constexpr bool is_unsigned_v = is_unsigned<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H
24 changes: 24 additions & 0 deletions libc/src/__support/CPP/type_traits/is_void.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//===-- is_void 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_TYPE_TRAITS_IS_VOID_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H

#include "src/__support/CPP/type_traits/is_same.h"
#include "src/__support/CPP/type_traits/remove_cv.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// is_void
template <typename T> struct is_void : is_same<void, remove_cv_t<T>> {};
template <typename T>
LIBC_INLINE_VAR constexpr bool is_void_v = is_void<T>::value;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H
37 changes: 37 additions & 0 deletions libc/src/__support/CPP/type_traits/make_signed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//===-- make_signed 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_TYPE_TRAITS_MAKE_SIGNED_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H

#include "src/__support/CPP/type_traits/type_identity.h"

namespace __llvm_libc::cpp {

// make_signed
template <typename T> struct make_signed;
template <> struct make_signed<char> : type_identity<char> {};
template <> struct make_signed<signed char> : type_identity<char> {};
template <> struct make_signed<short> : type_identity<short> {};
template <> struct make_signed<int> : type_identity<int> {};
template <> struct make_signed<long> : type_identity<long> {};
template <> struct make_signed<long long> : type_identity<long long> {};
template <> struct make_signed<unsigned char> : type_identity<char> {};
template <> struct make_signed<unsigned short> : type_identity<short> {};
template <> struct make_signed<unsigned int> : type_identity<int> {};
template <> struct make_signed<unsigned long> : type_identity<long> {};
template <>
struct make_signed<unsigned long long> : type_identity<long long> {};
#ifdef __SIZEOF_INT128__
template <> struct make_signed<__int128_t> : type_identity<__int128_t> {};
template <> struct make_signed<__uint128_t> : type_identity<__int128_t> {};
#endif
template <typename T> using make_signed_t = typename make_signed<T>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H
42 changes: 42 additions & 0 deletions libc/src/__support/CPP/type_traits/make_unsigned.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//===-- make_unsigned 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_TYPE_TRAITS_MAKE_UNSIGNED_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H

#include "src/__support/CPP/type_traits/type_identity.h"

namespace __llvm_libc::cpp {

// make_unsigned

template <typename T> struct make_unsigned;
template <> struct make_unsigned<char> : type_identity<unsigned char> {};
template <> struct make_unsigned<signed char> : type_identity<unsigned char> {};
template <> struct make_unsigned<short> : type_identity<unsigned short> {};
template <> struct make_unsigned<int> : type_identity<unsigned int> {};
template <> struct make_unsigned<long> : type_identity<unsigned long> {};
template <>
struct make_unsigned<long long> : type_identity<unsigned long long> {};
template <>
struct make_unsigned<unsigned char> : type_identity<unsigned char> {};
template <>
struct make_unsigned<unsigned short> : type_identity<unsigned short> {};
template <> struct make_unsigned<unsigned int> : type_identity<unsigned int> {};
template <>
struct make_unsigned<unsigned long> : type_identity<unsigned long> {};
template <>
struct make_unsigned<unsigned long long> : type_identity<unsigned long long> {};
#ifdef __SIZEOF_INT128__
template <> struct make_unsigned<__int128_t> : type_identity<__uint128_t> {};
template <> struct make_unsigned<__uint128_t> : type_identity<__uint128_t> {};
#endif
template <typename T> using make_unsigned_t = typename make_unsigned<T>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H
37 changes: 37 additions & 0 deletions libc/src/__support/CPP/type_traits/remove_all_extents.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//===-- remove_all_extents 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_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H

#include "src/__support/CPP/type_traits/type_identity.h"
#include "src/__support/macros/config.h"

namespace __llvm_libc::cpp {

// remove_all_extents
#if LIBC_HAS_BUILTIN(__remove_all_extents)
template <typename T> using remove_all_extents_t = __remove_all_extents(T);
template <typename T>
struct remove_all_extents : cpp::type_identity<remove_all_extents_t<T>> {};
#else
template <typename T> struct remove_all_extents {
using type = T;
};
template <typename T> struct remove_all_extents<T[]> {
using type = typename remove_all_extents<T>::type;
};
template <typename T, size_t _Np> struct remove_all_extents<T[_Np]> {
using type = typename remove_all_extents<T>::type;
};
template <typename T>
using remove_all_extents_t = typename remove_all_extents<T>::type;
#endif

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
25 changes: 25 additions & 0 deletions libc/src/__support/CPP/type_traits/remove_cv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===-- remove_cv 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_TYPE_TRAITS_REMOVE_CV_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H

#include "src/__support/CPP/type_traits/type_identity.h"

namespace __llvm_libc::cpp {

// remove_cv
template <class T> struct remove_cv : cpp::type_identity<T> {};
template <class T> struct remove_cv<const T> : cpp::type_identity<T> {};
template <class T> struct remove_cv<volatile T> : cpp::type_identity<T> {};
template <class T>
struct remove_cv<const volatile T> : cpp::type_identity<T> {};
template <class T> using remove_cv_t = typename remove_cv<T>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H
24 changes: 24 additions & 0 deletions libc/src/__support/CPP/type_traits/remove_cvref.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//===-- remove_cvref 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_TYPE_TRAITS_REMOVE_CVREF_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H

#include "src/__support/CPP/type_traits/remove_cv.h"
#include "src/__support/CPP/type_traits/remove_reference.h"

namespace __llvm_libc::cpp {

// remove_cvref
template <typename T> struct remove_cvref {
using type = remove_cv_t<remove_reference_t<T>>;
};
template <typename T> using remove_cvref_t = typename remove_cvref<T>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H
24 changes: 24 additions & 0 deletions libc/src/__support/CPP/type_traits/remove_extent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//===-- remove_extent 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_TYPE_TRAITS_REMOVE_EXTENT_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H

#include "src/__support/CPP/type_traits/type_identity.h"

namespace __llvm_libc::cpp {

// remove_extent
template <class T> struct remove_extent : cpp::type_identity<T> {};
template <class T> struct remove_extent<T[]> : cpp::type_identity<T> {};
template <class T, size_t N>
struct remove_extent<T[N]> : cpp::type_identity<T> {};
template <class T> using remove_extent_t = typename remove_extent<T>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H
24 changes: 24 additions & 0 deletions libc/src/__support/CPP/type_traits/remove_reference.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//===-- remove_reference 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_TYPE_TRAITS_REMOVE_REFERENCE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H

#include "src/__support/CPP/type_traits/type_identity.h"

namespace __llvm_libc::cpp {

// remove_reference
template <class T> struct remove_reference : cpp::type_identity<T> {};
template <class T> struct remove_reference<T &> : cpp::type_identity<T> {};
template <class T> struct remove_reference<T &&> : cpp::type_identity<T> {};
template <class T>
using remove_reference_t = typename remove_reference<T>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H
20 changes: 20 additions & 0 deletions libc/src/__support/CPP/type_traits/true_type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- true_type 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_TYPE_TRAITS_TRUE_TYPE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H

#include "src/__support/CPP/type_traits/bool_constant.h"

namespace __llvm_libc::cpp {

// true_type
using true_type = cpp::bool_constant<true>;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H
20 changes: 20 additions & 0 deletions libc/src/__support/CPP/type_traits/type_identity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- type_identity 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_TYPE_TRAITS_TYPE_IDENTITY_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H

namespace __llvm_libc::cpp {

// type_identity
template <typename T> struct type_identity {
using type = T;
};

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H
26 changes: 26 additions & 0 deletions libc/src/__support/CPP/type_traits/void_t.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//===-- void_t 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_TYPE_TRAITS_VOID_T_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_VOID_T_H

#include "src/__support/CPP/type_traits/type_identity.h"

namespace __llvm_libc::cpp {

// void_t

namespace detail {
template <typename... Ts> struct make_void : cpp::type_identity<void> {};
} // namespace detail

template <typename... Ts>
using void_t = typename detail::make_void<Ts...>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_VOID_T_H
47 changes: 4 additions & 43 deletions libc/src/__support/CPP/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,9 @@
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H

#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

template <typename T, T... Ints> struct integer_sequence {
static_assert(is_integral_v<T>);
template <T Next> using append = integer_sequence<T, Ints..., Next>;
};

namespace internal {

template <typename T, int N> struct make_integer_sequence {
using type =
typename make_integer_sequence<T, N - 1>::type::template append<N>;
};

template <typename T> struct make_integer_sequence<T, -1> {
using type = integer_sequence<T>;
};

} // namespace internal

template <typename T, int N>
using make_integer_sequence =
typename internal::make_integer_sequence<T, N - 1>::type;

template <typename T>
LIBC_INLINE constexpr T &&forward(typename remove_reference<T>::type &value) {
return static_cast<T &&>(value);
}

template <typename T>
LIBC_INLINE constexpr T &&forward(typename remove_reference<T>::type &&value) {
return static_cast<T &&>(value);
}

template <typename T>
LIBC_INLINE constexpr typename remove_reference<T>::type &&move(T &&value) {
return static_cast<typename remove_reference<T>::type &&>(value);
}

} // namespace __llvm_libc::cpp
#include "src/__support/CPP/utility/declval.h"
#include "src/__support/CPP/utility/forward.h"
#include "src/__support/CPP/utility/integer_sequence.h"
#include "src/__support/CPP/utility/move.h"

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H
28 changes: 28 additions & 0 deletions libc/src/__support/CPP/utility/declval.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===-- declval utility -----------------------------------------*- 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_UTILITY_DECLVAL_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_DECLVAL_H

#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// declval
namespace detail {
template <typename T> LIBC_INLINE_VAR constexpr bool always_false = false;
}

template <typename T> cpp::add_rvalue_reference_t<T> declval() {
static_assert(detail::always_false<T>,
"declval not allowed in an evaluated context");
}

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_DECLVAL_H
32 changes: 32 additions & 0 deletions libc/src/__support/CPP/utility/forward.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//===-- forward utility -----------------------------------------*- 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_UTILITY_FORWARD_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_FORWARD_H

#include "src/__support/CPP/type_traits/is_lvalue_reference.h"
#include "src/__support/CPP/type_traits/remove_reference.h"
#include "src/__support/macros/attributes.h"

namespace __llvm_libc::cpp {

// forward
template <typename T>
LIBC_INLINE constexpr T &&forward(remove_reference_t<T> &value) {
return static_cast<T &&>(value);
}

template <typename T>
LIBC_INLINE constexpr T &&forward(remove_reference_t<T> &&value) {
static_assert(!is_lvalue_reference_v<T>,
"cannot forward an rvalue as an lvalue");
return static_cast<T &&>(value);
}

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_FORWARD_H
37 changes: 37 additions & 0 deletions libc/src/__support/CPP/utility/integer_sequence.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//===-- integer_sequence utility --------------------------------*- 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_UTILITY_INTEGER_SEQUENCE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H

#include "src/__support/CPP/type_traits/is_integral.h"

namespace __llvm_libc::cpp {

// integer_sequence
template <typename T, T... Ints> struct integer_sequence {
static_assert(cpp::is_integral_v<T>);
template <T Next> using append = integer_sequence<T, Ints..., Next>;
};

namespace detail {
template <typename T, int N> struct make_integer_sequence {
using type =
typename make_integer_sequence<T, N - 1>::type::template append<N>;
};
template <typename T> struct make_integer_sequence<T, -1> {
using type = integer_sequence<T>;
};
} // namespace detail

template <typename T, int N>
using make_integer_sequence =
typename detail::make_integer_sequence<T, N - 1>::type;

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H
22 changes: 22 additions & 0 deletions libc/src/__support/CPP/utility/move.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//===-- move utility --------------------------------------------*- 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_UTILITY_MOVE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_MOVE_H

#include "src/__support/CPP/type_traits/remove_reference.h"

namespace __llvm_libc::cpp {

// move
template <class T> constexpr cpp::remove_reference_t<T> &&move(T &&t) {
return static_cast<typename cpp::remove_reference_t<T> &&>(t);
}

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_MOVE_H
56 changes: 54 additions & 2 deletions utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,53 @@ libc_support_library(

libc_support_library(
name = "__support_cpp_type_traits",
hdrs = ["src/__support/CPP/type_traits.h"],
hdrs = [
"src/__support/CPP/type_traits.h",
"src/__support/CPP/type_traits/add_lvalue_reference.h",
"src/__support/CPP/type_traits/add_pointer.h",
"src/__support/CPP/type_traits/add_rvalue_reference.h",
"src/__support/CPP/type_traits/bool_constant.h",
"src/__support/CPP/type_traits/conditional.h",
"src/__support/CPP/type_traits/decay.h",
"src/__support/CPP/type_traits/enable_if.h",
"src/__support/CPP/type_traits/false_type.h",
"src/__support/CPP/type_traits/integral_constant.h",
"src/__support/CPP/type_traits/is_arithmetic.h",
"src/__support/CPP/type_traits/is_array.h",
"src/__support/CPP/type_traits/is_base_of.h",
"src/__support/CPP/type_traits/is_class.h",
"src/__support/CPP/type_traits/is_const.h",
"src/__support/CPP/type_traits/is_convertible.h",
"src/__support/CPP/type_traits/is_destructible.h",
"src/__support/CPP/type_traits/is_enum.h",
"src/__support/CPP/type_traits/is_floating_point.h",
"src/__support/CPP/type_traits/is_function.h",
"src/__support/CPP/type_traits/is_integral.h",
"src/__support/CPP/type_traits/is_lvalue_reference.h",
"src/__support/CPP/type_traits/is_null_pointer.h",
"src/__support/CPP/type_traits/is_pointer.h",
"src/__support/CPP/type_traits/is_reference.h",
"src/__support/CPP/type_traits/is_rvalue_reference.h",
"src/__support/CPP/type_traits/is_same.h",
"src/__support/CPP/type_traits/is_signed.h",
"src/__support/CPP/type_traits/is_trivially_constructible.h",
"src/__support/CPP/type_traits/is_trivially_copyable.h",
"src/__support/CPP/type_traits/is_trivially_destructible.h",
"src/__support/CPP/type_traits/is_union.h",
"src/__support/CPP/type_traits/is_unsigned.h",
"src/__support/CPP/type_traits/is_void.h",
"src/__support/CPP/type_traits/make_signed.h",
"src/__support/CPP/type_traits/make_unsigned.h",
"src/__support/CPP/type_traits/remove_all_extents.h",
"src/__support/CPP/type_traits/remove_cv.h",
"src/__support/CPP/type_traits/remove_cvref.h",
"src/__support/CPP/type_traits/remove_extent.h",
"src/__support/CPP/type_traits/remove_reference.h",
"src/__support/CPP/type_traits/true_type.h",
"src/__support/CPP/type_traits/type_identity.h",
"src/__support/CPP/type_traits/void_t.h",
"src/__support/CPP/utility/declval.h",
],
deps = [
":__support_macros_attributes",
":__support_macros_config",
Expand All @@ -294,7 +340,13 @@ libc_support_library(

libc_support_library(
name = "__support_cpp_utility",
hdrs = ["src/__support/CPP/utility.h"],
hdrs = [
"src/__support/CPP/utility.h",
"src/__support/CPP/utility/declval.h",
"src/__support/CPP/utility/forward.h",
"src/__support/CPP/utility/integer_sequence.h",
"src/__support/CPP/utility/move.h",
],
deps = [
":__support_cpp_type_traits",
":__support_macros_attributes",
Expand Down