From 30c37fb89cb7d6cc02e92a7e81abcec5a1a4a38a Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Thu, 26 May 2022 11:49:01 +0200 Subject: [PATCH] [libc++] Granularize more of Reviewed By: ldionne, #libc Spies: libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D126244 --- libcxx/include/CMakeLists.txt | 28 + libcxx/include/__type_traits/add_const.h | 30 + libcxx/include/__type_traits/add_cv.h | 30 + .../__type_traits/add_lvalue_reference.h | 33 + .../__type_traits/add_rvalue_reference.h | 33 + libcxx/include/__type_traits/add_volatile.h | 30 + libcxx/include/__type_traits/extent.h | 55 ++ libcxx/include/__type_traits/is_abstract.h | 31 + libcxx/include/__type_traits/is_aggregate.h | 33 + libcxx/include/__type_traits/is_arithmetic.h | 34 + .../include/__type_traits/is_bounded_array.h | 35 + libcxx/include/__type_traits/is_class.h | 48 ++ libcxx/include/__type_traits/is_compound.h | 47 ++ libcxx/include/__type_traits/is_empty.h | 57 ++ libcxx/include/__type_traits/is_enum.h | 55 ++ libcxx/include/__type_traits/is_final.h | 36 ++ libcxx/include/__type_traits/is_fundamental.h | 53 ++ .../include/__type_traits/is_member_pointer.h | 45 ++ libcxx/include/__type_traits/is_object.h | 52 ++ libcxx/include/__type_traits/is_pointer.h | 59 ++ libcxx/include/__type_traits/is_scalar.h | 62 ++ libcxx/include/__type_traits/is_signed.h | 55 ++ .../__type_traits/is_unbounded_array.h | 34 + libcxx/include/__type_traits/is_union.h | 42 ++ libcxx/include/__type_traits/is_unsigned.h | 59 ++ libcxx/include/__type_traits/rank.h | 36 ++ .../__type_traits/remove_all_extents.h | 34 + libcxx/include/__type_traits/remove_pointer.h | 32 + libcxx/include/__type_traits/type_identity.h | 33 + libcxx/include/module.modulemap | 28 + libcxx/include/type_traits | 600 +----------------- libcxx/test/libcxx/private_headers.verify.cpp | 28 + 32 files changed, 1295 insertions(+), 572 deletions(-) create mode 100644 libcxx/include/__type_traits/add_const.h create mode 100644 libcxx/include/__type_traits/add_cv.h create mode 100644 libcxx/include/__type_traits/add_lvalue_reference.h create mode 100644 libcxx/include/__type_traits/add_rvalue_reference.h create mode 100644 libcxx/include/__type_traits/add_volatile.h create mode 100644 libcxx/include/__type_traits/extent.h create mode 100644 libcxx/include/__type_traits/is_abstract.h create mode 100644 libcxx/include/__type_traits/is_aggregate.h create mode 100644 libcxx/include/__type_traits/is_arithmetic.h create mode 100644 libcxx/include/__type_traits/is_bounded_array.h create mode 100644 libcxx/include/__type_traits/is_class.h create mode 100644 libcxx/include/__type_traits/is_compound.h create mode 100644 libcxx/include/__type_traits/is_empty.h create mode 100644 libcxx/include/__type_traits/is_enum.h create mode 100644 libcxx/include/__type_traits/is_final.h create mode 100644 libcxx/include/__type_traits/is_fundamental.h create mode 100644 libcxx/include/__type_traits/is_member_pointer.h create mode 100644 libcxx/include/__type_traits/is_object.h create mode 100644 libcxx/include/__type_traits/is_pointer.h create mode 100644 libcxx/include/__type_traits/is_scalar.h create mode 100644 libcxx/include/__type_traits/is_signed.h create mode 100644 libcxx/include/__type_traits/is_unbounded_array.h create mode 100644 libcxx/include/__type_traits/is_union.h create mode 100644 libcxx/include/__type_traits/is_unsigned.h create mode 100644 libcxx/include/__type_traits/rank.h create mode 100644 libcxx/include/__type_traits/remove_all_extents.h create mode 100644 libcxx/include/__type_traits/remove_pointer.h create mode 100644 libcxx/include/__type_traits/type_identity.h diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index f1ff3111f6ee8a..bf1c41e05c2b56 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -440,33 +440,61 @@ set(files __threading_support __tree __tuple + __type_traits/add_const.h + __type_traits/add_cv.h + __type_traits/add_lvalue_reference.h __type_traits/add_pointer.h + __type_traits/add_rvalue_reference.h + __type_traits/add_volatile.h __type_traits/conditional.h __type_traits/decay.h __type_traits/enable_if.h + __type_traits/extent.h __type_traits/integral_constant.h + __type_traits/is_abstract.h + __type_traits/is_aggregate.h + __type_traits/is_arithmetic.h __type_traits/is_array.h __type_traits/is_base_of.h + __type_traits/is_bounded_array.h __type_traits/is_callable.h + __type_traits/is_class.h + __type_traits/is_compound.h __type_traits/is_const.h __type_traits/is_convertible.h + __type_traits/is_empty.h + __type_traits/is_enum.h + __type_traits/is_final.h __type_traits/is_floating_point.h __type_traits/is_function.h + __type_traits/is_fundamental.h __type_traits/is_integral.h __type_traits/is_member_function_pointer.h __type_traits/is_member_object_pointer.h + __type_traits/is_member_pointer.h __type_traits/is_null_pointer.h + __type_traits/is_object.h + __type_traits/is_pointer.h __type_traits/is_reference.h __type_traits/is_reference_wrapper.h __type_traits/is_referenceable.h __type_traits/is_same.h + __type_traits/is_scalar.h + __type_traits/is_signed.h + __type_traits/is_unbounded_array.h + __type_traits/is_union.h + __type_traits/is_unsigned.h __type_traits/is_void.h __type_traits/is_volatile.h + __type_traits/rank.h + __type_traits/remove_all_extents.h __type_traits/remove_const.h __type_traits/remove_cv.h __type_traits/remove_extent.h + __type_traits/remove_pointer.h __type_traits/remove_reference.h __type_traits/remove_volatile.h + __type_traits/type_identity.h __undef_macros __utility/as_const.h __utility/auto_cast.h diff --git a/libcxx/include/__type_traits/add_const.h b/libcxx/include/__type_traits/add_const.h new file mode 100644 index 00000000000000..c616a13f840800 --- /dev/null +++ b/libcxx/include/__type_traits/add_const.h @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_ADD_CONST_H +#define _LIBCPP___TYPE_TRAITS_ADD_CONST_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS add_const { + typedef _LIBCPP_NODEBUG const _Tp type; +}; + +#if _LIBCPP_STD_VER > 11 +template using add_const_t = typename add_const<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_ADD_CONST_H diff --git a/libcxx/include/__type_traits/add_cv.h b/libcxx/include/__type_traits/add_cv.h new file mode 100644 index 00000000000000..8a85353f16c047 --- /dev/null +++ b/libcxx/include/__type_traits/add_cv.h @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_ADD_CV_H +#define _LIBCPP___TYPE_TRAITS_ADD_CV_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS add_cv { + typedef _LIBCPP_NODEBUG const volatile _Tp type; +}; + +#if _LIBCPP_STD_VER > 11 +template using add_cv_t = typename add_cv<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H diff --git a/libcxx/include/__type_traits/add_lvalue_reference.h b/libcxx/include/__type_traits/add_lvalue_reference.h new file mode 100644 index 00000000000000..0d1ee4185c8cdb --- /dev/null +++ b/libcxx/include/__type_traits/add_lvalue_reference.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H +#define _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H + +#include <__config> +#include <__type_traits/is_referenceable.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template ::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; +template struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; }; + +template struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference +{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;}; + +#if _LIBCPP_STD_VER > 11 +template using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H diff --git a/libcxx/include/__type_traits/add_rvalue_reference.h b/libcxx/include/__type_traits/add_rvalue_reference.h new file mode 100644 index 00000000000000..b2a1428095d89a --- /dev/null +++ b/libcxx/include/__type_traits/add_rvalue_reference.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H +#define _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H + +#include <__config> +#include <__type_traits/is_referenceable.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template ::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; +template struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; }; + +template struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference +{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;}; + +#if _LIBCPP_STD_VER > 11 +template using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H diff --git a/libcxx/include/__type_traits/add_volatile.h b/libcxx/include/__type_traits/add_volatile.h new file mode 100644 index 00000000000000..73b1cb8418fe16 --- /dev/null +++ b/libcxx/include/__type_traits/add_volatile.h @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H +#define _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS add_volatile { + typedef _LIBCPP_NODEBUG volatile _Tp type; +}; + +#if _LIBCPP_STD_VER > 11 +template using add_volatile_t = typename add_volatile<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H diff --git a/libcxx/include/__type_traits/extent.h b/libcxx/include/__type_traits/extent.h new file mode 100644 index 00000000000000..935ec4937c0ae8 --- /dev/null +++ b/libcxx/include/__type_traits/extent.h @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_EXTENT_H +#define _LIBCPP___TYPE_TRAITS_EXTENT_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if __has_keyword(__array_extent) + +template +struct _LIBCPP_TEMPLATE_VIS extent + : integral_constant { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr size_t extent_v = __array_extent(_Tp, _Ip); +#endif + +#else // __has_keyword(__array_extent) + +template struct _LIBCPP_TEMPLATE_VIS extent + : public integral_constant {}; +template struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> + : public integral_constant {}; +template struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> + : public integral_constant::value> {}; +template struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> + : public integral_constant {}; +template struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> + : public integral_constant::value> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr size_t extent_v = extent<_Tp, _Ip>::value; +#endif + +#endif // __has_keyword(__array_extent) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_EXTENT_H diff --git a/libcxx/include/__type_traits/is_abstract.h b/libcxx/include/__type_traits/is_abstract.h new file mode 100644 index 00000000000000..0480118b37616a --- /dev/null +++ b/libcxx/include/__type_traits/is_abstract.h @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H +#define _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS is_abstract + : public integral_constant {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H diff --git a/libcxx/include/__type_traits/is_aggregate.h b/libcxx/include/__type_traits/is_aggregate.h new file mode 100644 index 00000000000000..f32aec8ac543b8 --- /dev/null +++ b/libcxx/include/__type_traits/is_aggregate.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H +#define _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +template struct _LIBCPP_TEMPLATE_VIS +is_aggregate : public integral_constant {}; + +template +inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; + +#endif // _LIBCPP_STD_VER > 14 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H diff --git a/libcxx/include/__type_traits/is_arithmetic.h b/libcxx/include/__type_traits/is_arithmetic.h new file mode 100644 index 00000000000000..6d631f41c7d4a5 --- /dev/null +++ b/libcxx/include/__type_traits/is_arithmetic.h @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H +#define _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_floating_point.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS is_arithmetic + : public integral_constant::value || + is_floating_point<_Tp>::value> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H diff --git a/libcxx/include/__type_traits/is_bounded_array.h b/libcxx/include/__type_traits/is_bounded_array.h new file mode 100644 index 00000000000000..f6e800d723bd10 --- /dev/null +++ b/libcxx/include/__type_traits/is_bounded_array.h @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H +#define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +template struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {}; + +template +inline constexpr +bool is_bounded_array_v = is_bounded_array<_Tp>::value; + +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H diff --git a/libcxx/include/__type_traits/is_class.h b/libcxx/include/__type_traits/is_class.h new file mode 100644 index 00000000000000..523dc493e8e7fd --- /dev/null +++ b/libcxx/include/__type_traits/is_class.h @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_CLASS_H +#define _LIBCPP___TYPE_TRAITS_IS_CLASS_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_union.h> +#include <__type_traits/remove_cv.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC) + +template struct _LIBCPP_TEMPLATE_VIS is_class + : public integral_constant {}; + +#else + +namespace __is_class_imp +{ +template char __test(int _Tp::*); +template __two __test(...); +} + +template struct _LIBCPP_TEMPLATE_VIS is_class + : public integral_constant(0)) == 1 && !is_union<_Tp>::value> {}; + +#endif + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_class_v = is_class<_Tp>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_CLASS_H diff --git a/libcxx/include/__type_traits/is_compound.h b/libcxx/include/__type_traits/is_compound.h new file mode 100644 index 00000000000000..f055155b9f54f4 --- /dev/null +++ b/libcxx/include/__type_traits/is_compound.h @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H +#define _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_fundamental.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// >= 11 because in C++03 nullptr isn't actually nullptr +#if __has_keyword(__is_compound) && !defined(_LIBCPP_CXX03_LANG) + +template +struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_compound_v = __is_compound(_Tp); +#endif + +#else // __has_keyword(__is_compound) + +template struct _LIBCPP_TEMPLATE_VIS is_compound + : public integral_constant::value> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_compound_v = is_compound<_Tp>::value; +#endif + +#endif // __has_keyword(__is_compound) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H diff --git a/libcxx/include/__type_traits/is_empty.h b/libcxx/include/__type_traits/is_empty.h new file mode 100644 index 00000000000000..e81c6f7e2fa400 --- /dev/null +++ b/libcxx/include/__type_traits/is_empty.h @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_EMPTY_H +#define _LIBCPP___TYPE_TRAITS_IS_EMPTY_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC) + +template +struct _LIBCPP_TEMPLATE_VIS is_empty + : public integral_constant {}; + +#else // __has_feature(is_empty) + +template +struct __is_empty1 + : public _Tp +{ + double __lx; +}; + +struct __is_empty2 +{ + double __lx; +}; + +template ::value> +struct __libcpp_empty : public integral_constant) == sizeof(__is_empty2)> {}; + +template struct __libcpp_empty<_Tp, false> : public false_type {}; + +template struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {}; + +#endif // __has_feature(is_empty) + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_empty_v = is_empty<_Tp>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_EMPTY_H diff --git a/libcxx/include/__type_traits/is_enum.h b/libcxx/include/__type_traits/is_enum.h new file mode 100644 index 00000000000000..ac160da84e9919 --- /dev/null +++ b/libcxx/include/__type_traits/is_enum.h @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_ENUM_H +#define _LIBCPP___TYPE_TRAITS_IS_ENUM_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/remove_cv.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) + +template struct _LIBCPP_TEMPLATE_VIS is_enum + : public integral_constant {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_enum_v = __is_enum(_Tp); +#endif + +#else + +template struct _LIBCPP_TEMPLATE_VIS is_enum + : public integral_constant::value && + !is_integral<_Tp>::value && + !is_floating_point<_Tp>::value && + !is_array<_Tp>::value && + !is_pointer<_Tp>::value && + !is_reference<_Tp>::value && + !is_member_pointer<_Tp>::value && + !is_union<_Tp>::value && + !is_class<_Tp>::value && + !is_function<_Tp>::value > {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_enum_v = is_enum<_Tp>::value; +#endif + +#endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_ENUM_H diff --git a/libcxx/include/__type_traits/is_final.h b/libcxx/include/__type_traits/is_final.h new file mode 100644 index 00000000000000..f2d9b5b3c8f49c --- /dev/null +++ b/libcxx/include/__type_traits/is_final.h @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_FINAL_H +#define _LIBCPP___TYPE_TRAITS_IS_FINAL_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS +__libcpp_is_final : public integral_constant {}; + +#if _LIBCPP_STD_VER > 11 +template struct _LIBCPP_TEMPLATE_VIS +is_final : public integral_constant {}; +#endif + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_final_v = is_final<_Tp>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_FINAL_H diff --git a/libcxx/include/__type_traits/is_fundamental.h b/libcxx/include/__type_traits/is_fundamental.h new file mode 100644 index 00000000000000..859cfde39bfa40 --- /dev/null +++ b/libcxx/include/__type_traits/is_fundamental.h @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H +#define _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_null_pointer.h> +#include <__type_traits/is_void.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// Before Clang 10, __is_fundamental didn't work for nullptr_t. +// In C++03 nullptr_t is library-provided but must still count as "fundamental." +#if __has_keyword(__is_fundamental) && \ + !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1000) && \ + !defined(_LIBCPP_CXX03_LANG) + +template +struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); +#endif + +#else // __has_keyword(__is_fundamental) + +template struct _LIBCPP_TEMPLATE_VIS is_fundamental + : public integral_constant::value || + __is_nullptr_t<_Tp>::value || + is_arithmetic<_Tp>::value> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; +#endif + +#endif // __has_keyword(__is_fundamental) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H diff --git a/libcxx/include/__type_traits/is_member_pointer.h b/libcxx/include/__type_traits/is_member_pointer.h new file mode 100644 index 00000000000000..76595dfdab7f0f --- /dev/null +++ b/libcxx/include/__type_traits/is_member_pointer.h @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H +#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if __has_keyword(__is_member_pointer) + +template +struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); +#endif + +#else // __has_keyword(__is_member_pointer) + +template struct _LIBCPP_TEMPLATE_VIS is_member_pointer + : public _BoolConstant< __libcpp_is_member_pointer::type>::__is_member > {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; +#endif + +#endif // __has_keyword(__is_member_pointer) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H diff --git a/libcxx/include/__type_traits/is_object.h b/libcxx/include/__type_traits/is_object.h new file mode 100644 index 00000000000000..0d8339d19492c0 --- /dev/null +++ b/libcxx/include/__type_traits/is_object.h @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_OBJECT_H +#define _LIBCPP___TYPE_TRAITS_IS_OBJECT_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_array.h> +#include <__type_traits/is_class.h> +#include <__type_traits/is_scalar.h> +#include <__type_traits/is_union.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if __has_keyword(__is_object) + +template +struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_object_v = __is_object(_Tp); +#endif + +#else // __has_keyword(__is_object) + +template struct _LIBCPP_TEMPLATE_VIS is_object + : public integral_constant::value || + is_array<_Tp>::value || + is_union<_Tp>::value || + is_class<_Tp>::value > {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_object_v = is_object<_Tp>::value; +#endif + +#endif // __has_keyword(__is_object) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_OBJECT_H diff --git a/libcxx/include/__type_traits/is_pointer.h b/libcxx/include/__type_traits/is_pointer.h new file mode 100644 index 00000000000000..ab66989ef86d6f --- /dev/null +++ b/libcxx/include/__type_traits/is_pointer.h @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_POINTER_H +#define _LIBCPP___TYPE_TRAITS_IS_POINTER_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/remove_cv.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// Before AppleClang 12.0.5, __is_pointer didn't work for Objective-C types. +#if __has_keyword(__is_pointer) && \ + !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1205) + +template +struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_pointer_v = __is_pointer(_Tp); +#endif + +#else // __has_keyword(__is_pointer) + +template struct __libcpp_is_pointer : public false_type {}; +template struct __libcpp_is_pointer<_Tp*> : public true_type {}; + +template struct __libcpp_remove_objc_qualifiers { typedef _Tp type; }; +#if defined(_LIBCPP_HAS_OBJC_ARC) +template struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; }; +template struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; }; +template struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; }; +template struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; }; +#endif + +template struct _LIBCPP_TEMPLATE_VIS is_pointer + : public __libcpp_is_pointer::type>::type> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; +#endif + +#endif // __has_keyword(__is_pointer) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_POINTER_H diff --git a/libcxx/include/__type_traits/is_scalar.h b/libcxx/include/__type_traits/is_scalar.h new file mode 100644 index 00000000000000..f745bf5e363892 --- /dev/null +++ b/libcxx/include/__type_traits/is_scalar.h @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_SCALAR_H +#define _LIBCPP___TYPE_TRAITS_IS_SCALAR_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_enum.h> +#include <__type_traits/is_member_pointer.h> +#include <__type_traits/is_pointer.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// In C++03 nullptr_t is library-provided but must still count as "scalar." +#if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG) + +template +struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_scalar_v = __is_scalar(_Tp); +#endif + +#else // __has_keyword(__is_scalar) + +template struct __is_block : false_type {}; +#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) +template struct __is_block<_Rp (^)(_Args...)> : true_type {}; +#endif + +template struct _LIBCPP_TEMPLATE_VIS is_scalar + : public integral_constant::value || + is_member_pointer<_Tp>::value || + is_pointer<_Tp>::value || + __is_nullptr_t<_Tp>::value || + __is_block<_Tp>::value || + is_enum<_Tp>::value > {}; + +template <> struct _LIBCPP_TEMPLATE_VIS is_scalar : public true_type {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; +#endif + +#endif // __has_keyword(__is_scalar) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_SCALAR_H diff --git a/libcxx/include/__type_traits/is_signed.h b/libcxx/include/__type_traits/is_signed.h new file mode 100644 index 00000000000000..241d6f551a4ba5 --- /dev/null +++ b/libcxx/include/__type_traits/is_signed.h @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_SIGNED_H +#define _LIBCPP___TYPE_TRAITS_IS_SIGNED_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if __has_keyword(__is_signed) + +template +struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_signed_v = __is_signed(_Tp); +#endif + +#else // __has_keyword(__is_signed) + +template ::value> +struct __libcpp_is_signed_impl : public _BoolConstant<(_Tp(-1) < _Tp(0))> {}; + +template +struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point + +template ::value> +struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; + +template struct __libcpp_is_signed<_Tp, false> : public false_type {}; + +template struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_signed_v = is_signed<_Tp>::value; +#endif + +#endif // __has_keyword(__is_signed) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_SIGNED_H diff --git a/libcxx/include/__type_traits/is_unbounded_array.h b/libcxx/include/__type_traits/is_unbounded_array.h new file mode 100644 index 00000000000000..9e857533c6fd99 --- /dev/null +++ b/libcxx/include/__type_traits/is_unbounded_array.h @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H +#define _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +template struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {}; + +template +inline constexpr +bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; + +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H diff --git a/libcxx/include/__type_traits/is_union.h b/libcxx/include/__type_traits/is_union.h new file mode 100644 index 00000000000000..d02931fc01d342 --- /dev/null +++ b/libcxx/include/__type_traits/is_union.h @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_UNION_H +#define _LIBCPP___TYPE_TRAITS_IS_UNION_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/remove_cv.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC) + +template struct _LIBCPP_TEMPLATE_VIS is_union + : public integral_constant {}; + +#else + +template struct __libcpp_union : public false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_union + : public __libcpp_union::type> {}; + +#endif + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_union_v = is_union<_Tp>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_UNION_H diff --git a/libcxx/include/__type_traits/is_unsigned.h b/libcxx/include/__type_traits/is_unsigned.h new file mode 100644 index 00000000000000..3c25205e6417a6 --- /dev/null +++ b/libcxx/include/__type_traits/is_unsigned.h @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H +#define _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// Before Clang 13, __is_unsigned returned true for enums with signed underlying type. +// No currently-released version of AppleClang contains the fixed intrinsic. +#if __has_keyword(__is_unsigned) && \ + !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1300) && \ + !defined(_LIBCPP_APPLE_CLANG_VER) + +template +struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_unsigned_v = __is_unsigned(_Tp); +#endif + +#else // __has_keyword(__is_unsigned) + +template ::value> +struct __libcpp_is_unsigned_impl : public _BoolConstant<(_Tp(0) < _Tp(-1))> {}; + +template +struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point + +template ::value> +struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; + +template struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; + +template struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; +#endif + +#endif // __has_keyword(__is_unsigned) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H diff --git a/libcxx/include/__type_traits/rank.h b/libcxx/include/__type_traits/rank.h new file mode 100644 index 00000000000000..193d3fd129a151 --- /dev/null +++ b/libcxx/include/__type_traits/rank.h @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_RANK_H +#define _LIBCPP___TYPE_TRAITS_RANK_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS rank + : public integral_constant {}; +template struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> + : public integral_constant::value + 1> {}; +template struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> + : public integral_constant::value + 1> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr size_t rank_v = rank<_Tp>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_RANK_H diff --git a/libcxx/include/__type_traits/remove_all_extents.h b/libcxx/include/__type_traits/remove_all_extents.h new file mode 100644 index 00000000000000..075e3acabb4471 --- /dev/null +++ b/libcxx/include/__type_traits/remove_all_extents.h @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H +#define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS remove_all_extents + {typedef _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]> + {typedef typename remove_all_extents<_Tp>::type type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]> + {typedef typename remove_all_extents<_Tp>::type type;}; + +#if _LIBCPP_STD_VER > 11 +template using remove_all_extents_t = typename remove_all_extents<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H diff --git a/libcxx/include/__type_traits/remove_pointer.h b/libcxx/include/__type_traits/remove_pointer.h new file mode 100644 index 00000000000000..50cde3829470b3 --- /dev/null +++ b/libcxx/include/__type_traits/remove_pointer.h @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H +#define _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;}; + +#if _LIBCPP_STD_VER > 11 +template using remove_pointer_t = typename remove_pointer<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H diff --git a/libcxx/include/__type_traits/type_identity.h b/libcxx/include/__type_traits/type_identity.h new file mode 100644 index 00000000000000..42e52b16725b16 --- /dev/null +++ b/libcxx/include/__type_traits/type_identity.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_H +#define _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +struct __type_identity { typedef _Tp type; }; + +template +using __type_identity_t _LIBCPP_NODEBUG = typename __type_identity<_Tp>::type; + +#if _LIBCPP_STD_VER > 17 +template struct type_identity { typedef _Tp type; }; +template using type_identity_t = typename type_identity<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_H diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap index d186ebe1c34576..ba1d0ffd49f6cc 100644 --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -987,33 +987,61 @@ module std [system] { export functional.__functional.unwrap_ref export * + module add_const { private header "__type_traits/add_const.h" } + module add_cv { private header "__type_traits/add_cv.h" } + module add_lvalue_reference { private header "__type_traits/add_lvalue_reference.h" } module add_pointer { private header "__type_traits/add_pointer.h" } + module add_rvalue_reference { private header "__type_traits/add_rvalue_reference.h" } + module add_volatile { private header "__type_traits/add_volatile.h" } module conditional { private header "__type_traits/conditional.h" } module decay { private header "__type_traits/decay.h" } module enable_if { private header "__type_traits/enable_if.h" } + module extent { private header "__type_traits/extent.h" } module integral_constant { private header "__type_traits/integral_constant.h" } + module is_abstract { private header "__type_traits/is_abstract.h" } + module is_aggregate { private header "__type_traits/is_aggregate.h" } + module is_arithmetic { private header "__type_traits/is_arithmetic.h" } module is_array { private header "__type_traits/is_array.h" } module is_base_of { private header "__type_traits/is_base_of.h" } + module is_bounded_array { private header "__type_traits/is_bounded_array.h" } module is_callable { private header "__type_traits/is_callable.h" } + module is_class { private header "__type_traits/is_class.h" } + module is_compound { private header "__type_traits/is_compound.h" } module is_const { private header "__type_traits/is_const.h" } module is_convertible { private header "__type_traits/is_convertible.h" } + module is_empty { private header "__type_traits/is_empty.h" } + module is_enum { private header "__type_traits/is_enum.h" } + module is_final { private header "__type_traits/is_final.h" } module is_floating_point { private header "__type_traits/is_floating_point.h" } module is_function { private header "__type_traits/is_function.h" } + module is_fundamental { private header "__type_traits/is_fundamental.h" } module is_integral { private header "__type_traits/is_integral.h" } module is_member_function_pointer { private header "__type_traits/is_member_function_pointer.h" } module is_member_object_pointer { private header "__type_traits/is_member_object_pointer.h" } + module is_member_pointer { private header "__type_traits/is_member_pointer.h" } module is_null_pointer { private header "__type_traits/is_null_pointer.h" } + module is_object { private header "__type_traits/is_object.h" } + module is_pointer { private header "__type_traits/is_pointer.h" } module is_reference { private header "__type_traits/is_reference.h" } module is_reference_wrapper { private header "__type_traits/is_reference_wrapper.h" } module is_referenceable { private header "__type_traits/is_referenceable.h" } module is_same { private header "__type_traits/is_same.h" } + module is_scalar { private header "__type_traits/is_scalar.h" } + module is_signed { private header "__type_traits/is_signed.h" } + module is_unbounded_array { private header "__type_traits/is_unbounded_array.h" } + module is_union { private header "__type_traits/is_union.h" } + module is_unsigned { private header "__type_traits/is_unsigned.h" } module is_void { private header "__type_traits/is_void.h" } module is_volatile { private header "__type_traits/is_volatile.h" } + module rank { private header "__type_traits/rank.h" } + module remove_all_extents { private header "__type_traits/remove_all_extents.h" } module remove_const { private header "__type_traits/remove_const.h" } module remove_cv { private header "__type_traits/remove_cv.h" } module remove_extent { private header "__type_traits/remove_extent.h" } + module remove_pointer { private header "__type_traits/remove_pointer.h" } module remove_reference { private header "__type_traits/remove_reference.h" } module remove_volatile { private header "__type_traits/remove_volatile.h" } + module type_identity { private header "__type_traits/type_identity.h" } } module typeindex { header "typeindex" diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 5908850cba5edd..852aed161f086b 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -418,33 +418,61 @@ namespace std */ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> +#include <__type_traits/add_const.h> +#include <__type_traits/add_cv.h> +#include <__type_traits/add_lvalue_reference.h> #include <__type_traits/add_pointer.h> +#include <__type_traits/add_rvalue_reference.h> +#include <__type_traits/add_volatile.h> #include <__type_traits/conditional.h> #include <__type_traits/decay.h> #include <__type_traits/enable_if.h> +#include <__type_traits/extent.h> #include <__type_traits/integral_constant.h> +#include <__type_traits/is_abstract.h> +#include <__type_traits/is_aggregate.h> +#include <__type_traits/is_arithmetic.h> #include <__type_traits/is_array.h> #include <__type_traits/is_base_of.h> +#include <__type_traits/is_bounded_array.h> #include <__type_traits/is_callable.h> +#include <__type_traits/is_class.h> +#include <__type_traits/is_compound.h> #include <__type_traits/is_const.h> #include <__type_traits/is_convertible.h> +#include <__type_traits/is_empty.h> +#include <__type_traits/is_enum.h> +#include <__type_traits/is_final.h> #include <__type_traits/is_floating_point.h> #include <__type_traits/is_function.h> +#include <__type_traits/is_fundamental.h> #include <__type_traits/is_integral.h> #include <__type_traits/is_member_function_pointer.h> #include <__type_traits/is_member_object_pointer.h> +#include <__type_traits/is_member_pointer.h> #include <__type_traits/is_null_pointer.h> +#include <__type_traits/is_object.h> +#include <__type_traits/is_pointer.h> #include <__type_traits/is_reference.h> #include <__type_traits/is_reference_wrapper.h> #include <__type_traits/is_referenceable.h> #include <__type_traits/is_same.h> +#include <__type_traits/is_scalar.h> +#include <__type_traits/is_signed.h> +#include <__type_traits/is_unbounded_array.h> +#include <__type_traits/is_union.h> +#include <__type_traits/is_unsigned.h> #include <__type_traits/is_void.h> #include <__type_traits/is_volatile.h> +#include <__type_traits/rank.h> +#include <__type_traits/remove_all_extents.h> #include <__type_traits/remove_const.h> #include <__type_traits/remove_cv.h> #include <__type_traits/remove_extent.h> +#include <__type_traits/remove_pointer.h> #include <__type_traits/remove_reference.h> #include <__type_traits/remove_volatile.h> +#include <__type_traits/type_identity.h> #include <__utility/declval.h> #include #include @@ -558,327 +586,6 @@ template <> struct __libcpp_is_unsigned_integer : public tru template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {}; #endif -// is_pointer - -// Before AppleClang 12.0.5, __is_pointer didn't work for Objective-C types. -#if __has_keyword(__is_pointer) && \ - !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1205) - -template -struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_pointer_v = __is_pointer(_Tp); -#endif - -#else // __has_keyword(__is_pointer) - -template struct __libcpp_is_pointer : public false_type {}; -template struct __libcpp_is_pointer<_Tp*> : public true_type {}; - -template struct __libcpp_remove_objc_qualifiers { typedef _Tp type; }; -#if defined(_LIBCPP_HAS_OBJC_ARC) -template struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; }; -template struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; }; -template struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; }; -template struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; }; -#endif - -template struct _LIBCPP_TEMPLATE_VIS is_pointer - : public __libcpp_is_pointer::type>::type> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; -#endif - -#endif // __has_keyword(__is_pointer) - -// is_union - -#if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC) - -template struct _LIBCPP_TEMPLATE_VIS is_union - : public integral_constant {}; - -#else - -template struct __libcpp_union : public false_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_union - : public __libcpp_union::type> {}; - -#endif - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_union_v = is_union<_Tp>::value; -#endif - -// is_class - -#if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC) - -template struct _LIBCPP_TEMPLATE_VIS is_class - : public integral_constant {}; - -#else - -namespace __is_class_imp -{ -template char __test(int _Tp::*); -template __two __test(...); -} - -template struct _LIBCPP_TEMPLATE_VIS is_class - : public integral_constant(0)) == 1 && !is_union<_Tp>::value> {}; - -#endif - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_class_v = is_class<_Tp>::value; -#endif - -// is_member_pointer - -#if __has_keyword(__is_member_pointer) - -template -struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); -#endif - -#else // __has_keyword(__is_member_pointer) - -template struct _LIBCPP_TEMPLATE_VIS is_member_pointer - : public _BoolConstant< __libcpp_is_member_pointer::type>::__is_member > {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; -#endif - -#endif // __has_keyword(__is_member_pointer) - -// is_enum - -#if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) - -template struct _LIBCPP_TEMPLATE_VIS is_enum - : public integral_constant {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_enum_v = __is_enum(_Tp); -#endif - -#else - -template struct _LIBCPP_TEMPLATE_VIS is_enum - : public integral_constant::value && - !is_integral<_Tp>::value && - !is_floating_point<_Tp>::value && - !is_array<_Tp>::value && - !is_pointer<_Tp>::value && - !is_reference<_Tp>::value && - !is_member_pointer<_Tp>::value && - !is_union<_Tp>::value && - !is_class<_Tp>::value && - !is_function<_Tp>::value > {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_enum_v = is_enum<_Tp>::value; -#endif - -#endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) - -// is_arithmetic - - -template struct _LIBCPP_TEMPLATE_VIS is_arithmetic - : public integral_constant::value || - is_floating_point<_Tp>::value> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; -#endif - -// is_fundamental - -// Before Clang 10, __is_fundamental didn't work for nullptr_t. -// In C++03 nullptr_t is library-provided but must still count as "fundamental." -#if __has_keyword(__is_fundamental) && \ - !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1000) && \ - !defined(_LIBCPP_CXX03_LANG) - -template -struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); -#endif - -#else // __has_keyword(__is_fundamental) - -template struct _LIBCPP_TEMPLATE_VIS is_fundamental - : public integral_constant::value || - __is_nullptr_t<_Tp>::value || - is_arithmetic<_Tp>::value> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; -#endif - -#endif // __has_keyword(__is_fundamental) - -// is_scalar - -// In C++03 nullptr_t is library-provided but must still count as "scalar." -#if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG) - -template -struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_scalar_v = __is_scalar(_Tp); -#endif - -#else // __has_keyword(__is_scalar) - -template struct __is_block : false_type {}; -#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) -template struct __is_block<_Rp (^)(_Args...)> : true_type {}; -#endif - -template struct _LIBCPP_TEMPLATE_VIS is_scalar - : public integral_constant::value || - is_member_pointer<_Tp>::value || - is_pointer<_Tp>::value || - __is_nullptr_t<_Tp>::value || - __is_block<_Tp>::value || - is_enum<_Tp>::value > {}; - -template <> struct _LIBCPP_TEMPLATE_VIS is_scalar : public true_type {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; -#endif - -#endif // __has_keyword(__is_scalar) - -// is_object - -#if __has_keyword(__is_object) - -template -struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_object_v = __is_object(_Tp); -#endif - -#else // __has_keyword(__is_object) - -template struct _LIBCPP_TEMPLATE_VIS is_object - : public integral_constant::value || - is_array<_Tp>::value || - is_union<_Tp>::value || - is_class<_Tp>::value > {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_object_v = is_object<_Tp>::value; -#endif - -#endif // __has_keyword(__is_object) - -// is_compound - -// >= 11 because in C++03 nullptr isn't actually nullptr -#if __has_keyword(__is_compound) && !defined(_LIBCPP_CXX03_LANG) - -template -struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_compound_v = __is_compound(_Tp); -#endif - -#else // __has_keyword(__is_compound) - -template struct _LIBCPP_TEMPLATE_VIS is_compound - : public integral_constant::value> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_compound_v = is_compound<_Tp>::value; -#endif - -#endif // __has_keyword(__is_compound) - -// add_const - -template struct _LIBCPP_TEMPLATE_VIS add_const { - typedef _LIBCPP_NODEBUG const _Tp type; -}; - -#if _LIBCPP_STD_VER > 11 -template using add_const_t = typename add_const<_Tp>::type; -#endif - -// add_volatile - -template struct _LIBCPP_TEMPLATE_VIS add_volatile { - typedef _LIBCPP_NODEBUG volatile _Tp type; -}; - -#if _LIBCPP_STD_VER > 11 -template using add_volatile_t = typename add_volatile<_Tp>::type; -#endif - -// add_cv -template struct _LIBCPP_TEMPLATE_VIS add_cv { - typedef _LIBCPP_NODEBUG const volatile _Tp type; -}; - -#if _LIBCPP_STD_VER > 11 -template using add_cv_t = typename add_cv<_Tp>::type; -#endif - -// add_lvalue_reference - -template ::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; -template struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; }; - -template struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference -{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;}; - -#if _LIBCPP_STD_VER > 11 -template using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; -#endif - -template ::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; -template struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; }; - -template struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference -{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;}; - -#if _LIBCPP_STD_VER > 11 -template using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; -#endif - template struct __unconstref { typedef _LIBCPP_NODEBUG typename remove_const::type>::type type; @@ -908,221 +615,6 @@ struct __any __any(...); }; -// remove_pointer - -template struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;}; - -#if _LIBCPP_STD_VER > 11 -template using remove_pointer_t = typename remove_pointer<_Tp>::type; -#endif - -// add_pointer - -// type_identity - -template -struct __type_identity { typedef _Tp type; }; - -template -using __type_identity_t _LIBCPP_NODEBUG = typename __type_identity<_Tp>::type; - -#if _LIBCPP_STD_VER > 17 -template struct type_identity { typedef _Tp type; }; -template using type_identity_t = typename type_identity<_Tp>::type; -#endif - -// is_signed - -#if __has_keyword(__is_signed) - -template -struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_signed_v = __is_signed(_Tp); -#endif - -#else // __has_keyword(__is_signed) - -template ::value> -struct __libcpp_is_signed_impl : public _BoolConstant<(_Tp(-1) < _Tp(0))> {}; - -template -struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point - -template ::value> -struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; - -template struct __libcpp_is_signed<_Tp, false> : public false_type {}; - -template struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_signed_v = is_signed<_Tp>::value; -#endif - -#endif // __has_keyword(__is_signed) - -// is_unsigned - -// Before Clang 13, __is_unsigned returned true for enums with signed underlying type. -// No currently-released version of AppleClang contains the fixed intrinsic. -#if __has_keyword(__is_unsigned) && \ - !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1300) && \ - !defined(_LIBCPP_APPLE_CLANG_VER) - -template -struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_unsigned_v = __is_unsigned(_Tp); -#endif - -#else // __has_keyword(__is_unsigned) - -template ::value> -struct __libcpp_is_unsigned_impl : public _BoolConstant<(_Tp(0) < _Tp(-1))> {}; - -template -struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point - -template ::value> -struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; - -template struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; - -template struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; -#endif - -#endif // __has_keyword(__is_unsigned) - -// rank - -template struct _LIBCPP_TEMPLATE_VIS rank - : public integral_constant {}; -template struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> - : public integral_constant::value + 1> {}; -template struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> - : public integral_constant::value + 1> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr size_t rank_v = rank<_Tp>::value; -#endif - -// extent - -#if __has_keyword(__array_extent) - -template -struct _LIBCPP_TEMPLATE_VIS extent - : integral_constant { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr size_t extent_v = __array_extent(_Tp, _Ip); -#endif - -#else // __has_keyword(__array_extent) - -template struct _LIBCPP_TEMPLATE_VIS extent - : public integral_constant {}; -template struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> - : public integral_constant {}; -template struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> - : public integral_constant::value> {}; -template struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> - : public integral_constant {}; -template struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> - : public integral_constant::value> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr size_t extent_v = extent<_Tp, _Ip>::value; -#endif - -#endif // __has_keyword(__array_extent) - -// remove_all_extents - -template struct _LIBCPP_TEMPLATE_VIS remove_all_extents - {typedef _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]> - {typedef typename remove_all_extents<_Tp>::type type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]> - {typedef typename remove_all_extents<_Tp>::type type;}; - -#if _LIBCPP_STD_VER > 11 -template using remove_all_extents_t = typename remove_all_extents<_Tp>::type; -#endif - -#if _LIBCPP_STD_VER > 17 -// is_bounded_array - -template struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {}; - -template -inline constexpr -bool is_bounded_array_v = is_bounded_array<_Tp>::value; - -// is_unbounded_array - -template struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {}; - -template -inline constexpr -bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; -#endif - -// is_abstract - -template struct _LIBCPP_TEMPLATE_VIS is_abstract - : public integral_constant {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; -#endif - -// is_final - -template struct _LIBCPP_TEMPLATE_VIS -__libcpp_is_final : public integral_constant {}; - -#if _LIBCPP_STD_VER > 11 -template struct _LIBCPP_TEMPLATE_VIS -is_final : public integral_constant {}; -#endif - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_final_v = is_final<_Tp>::value; -#endif - -// is_aggregate -#if _LIBCPP_STD_VER > 14 - -template struct _LIBCPP_TEMPLATE_VIS -is_aggregate : public integral_constant {}; - -template -inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; - -#endif // _LIBCPP_STD_VER > 14 - // __is_core_convertible // [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed. @@ -1164,42 +656,6 @@ inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To #endif // _LIBCPP_STD_VER > 17 -// is_empty - -#if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC) - -template -struct _LIBCPP_TEMPLATE_VIS is_empty - : public integral_constant {}; - -#else // __has_feature(is_empty) - -template -struct __is_empty1 - : public _Tp -{ - double __lx; -}; - -struct __is_empty2 -{ - double __lx; -}; - -template ::value> -struct __libcpp_empty : public integral_constant) == sizeof(__is_empty2)> {}; - -template struct __libcpp_empty<_Tp, false> : public false_type {}; - -template struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {}; - -#endif // __has_feature(is_empty) - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_empty_v = is_empty<_Tp>::value; -#endif - // is_polymorphic #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC) diff --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp index c0debf7b8b2257..121e4d9d98778d 100644 --- a/libcxx/test/libcxx/private_headers.verify.cpp +++ b/libcxx/test/libcxx/private_headers.verify.cpp @@ -450,33 +450,61 @@ END-SCRIPT #include <__thread/poll_with_backoff.h> // expected-error@*:* {{use of private header from outside its module: '__thread/poll_with_backoff.h'}} #include <__thread/timed_backoff_policy.h> // expected-error@*:* {{use of private header from outside its module: '__thread/timed_backoff_policy.h'}} #include <__tuple> // expected-error@*:* {{use of private header from outside its module: '__tuple'}} +#include <__type_traits/add_const.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_const.h'}} +#include <__type_traits/add_cv.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_cv.h'}} +#include <__type_traits/add_lvalue_reference.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_lvalue_reference.h'}} #include <__type_traits/add_pointer.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_pointer.h'}} +#include <__type_traits/add_rvalue_reference.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_rvalue_reference.h'}} +#include <__type_traits/add_volatile.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_volatile.h'}} #include <__type_traits/conditional.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/conditional.h'}} #include <__type_traits/decay.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/decay.h'}} #include <__type_traits/enable_if.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/enable_if.h'}} +#include <__type_traits/extent.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/extent.h'}} #include <__type_traits/integral_constant.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/integral_constant.h'}} +#include <__type_traits/is_abstract.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_abstract.h'}} +#include <__type_traits/is_aggregate.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_aggregate.h'}} +#include <__type_traits/is_arithmetic.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_arithmetic.h'}} #include <__type_traits/is_array.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_array.h'}} #include <__type_traits/is_base_of.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_base_of.h'}} +#include <__type_traits/is_bounded_array.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_bounded_array.h'}} #include <__type_traits/is_callable.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_callable.h'}} +#include <__type_traits/is_class.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_class.h'}} +#include <__type_traits/is_compound.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_compound.h'}} #include <__type_traits/is_const.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_const.h'}} #include <__type_traits/is_convertible.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_convertible.h'}} +#include <__type_traits/is_empty.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_empty.h'}} +#include <__type_traits/is_enum.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_enum.h'}} +#include <__type_traits/is_final.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_final.h'}} #include <__type_traits/is_floating_point.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_floating_point.h'}} #include <__type_traits/is_function.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_function.h'}} +#include <__type_traits/is_fundamental.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_fundamental.h'}} #include <__type_traits/is_integral.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_integral.h'}} #include <__type_traits/is_member_function_pointer.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_member_function_pointer.h'}} #include <__type_traits/is_member_object_pointer.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_member_object_pointer.h'}} +#include <__type_traits/is_member_pointer.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_member_pointer.h'}} #include <__type_traits/is_null_pointer.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_null_pointer.h'}} +#include <__type_traits/is_object.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_object.h'}} +#include <__type_traits/is_pointer.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_pointer.h'}} #include <__type_traits/is_reference.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_reference.h'}} #include <__type_traits/is_reference_wrapper.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_reference_wrapper.h'}} #include <__type_traits/is_referenceable.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_referenceable.h'}} #include <__type_traits/is_same.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_same.h'}} +#include <__type_traits/is_scalar.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_scalar.h'}} +#include <__type_traits/is_signed.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_signed.h'}} +#include <__type_traits/is_unbounded_array.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_unbounded_array.h'}} +#include <__type_traits/is_union.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_union.h'}} +#include <__type_traits/is_unsigned.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_unsigned.h'}} #include <__type_traits/is_void.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_void.h'}} #include <__type_traits/is_volatile.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_volatile.h'}} +#include <__type_traits/rank.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/rank.h'}} +#include <__type_traits/remove_all_extents.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/remove_all_extents.h'}} #include <__type_traits/remove_const.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/remove_const.h'}} #include <__type_traits/remove_cv.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/remove_cv.h'}} #include <__type_traits/remove_extent.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/remove_extent.h'}} +#include <__type_traits/remove_pointer.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/remove_pointer.h'}} #include <__type_traits/remove_reference.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/remove_reference.h'}} #include <__type_traits/remove_volatile.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/remove_volatile.h'}} +#include <__type_traits/type_identity.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/type_identity.h'}} #include <__utility/as_const.h> // expected-error@*:* {{use of private header from outside its module: '__utility/as_const.h'}} #include <__utility/auto_cast.h> // expected-error@*:* {{use of private header from outside its module: '__utility/auto_cast.h'}} #include <__utility/cmp.h> // expected-error@*:* {{use of private header from outside its module: '__utility/cmp.h'}}