diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -431,8 +431,33 @@ __threading_support __tree __tuple + __type_traits/add_pointer.h + __type_traits/conditional.h + __type_traits/decay.h + __type_traits/enable_if.h __type_traits/integral_constant.h + __type_traits/is_array.h + __type_traits/is_base_of.h __type_traits/is_callable.h + __type_traits/is_const.h + __type_traits/is_convertible.h + __type_traits/is_floating_point.h + __type_traits/is_function.h + __type_traits/is_integral.h + __type_traits/is_member_function_pointer.h + __type_traits/is_member_object_pointer.h + __type_traits/is_null_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_void.h + __type_traits/is_volatile.h + __type_traits/remove_const.h + __type_traits/remove_cv.h + __type_traits/remove_extent.h + __type_traits/remove_reference.h + __type_traits/remove_volatile.h __undef_macros __utility/as_const.h __utility/auto_cast.h diff --git a/libcxx/include/__type_traits/add_pointer.h b/libcxx/include/__type_traits/add_pointer.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/add_pointer.h @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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_POINTER_H +#define _LIBCPP___TYPE_TRAITS_ADD_POINTER_H + +#include <__config> +#include <__type_traits/is_referenceable.h> +#include <__type_traits/is_same.h> +#include <__type_traits/remove_cv.h> +#include <__type_traits/remove_reference.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template ::value || + _IsSame::type, void>::value> +struct __add_pointer_impl + {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;}; +template struct __add_pointer_impl<_Tp, false> + {typedef _LIBCPP_NODEBUG _Tp type;}; + +template struct _LIBCPP_TEMPLATE_VIS add_pointer + {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;}; + +#if _LIBCPP_STD_VER > 11 +template using add_pointer_t = typename add_pointer<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_ADD_POINTER_H diff --git a/libcxx/include/__type_traits/conditional.h b/libcxx/include/__type_traits/conditional.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/conditional.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_CONDITIONAL_H +#define _LIBCPP___TYPE_TRAITS_CONDITIONAL_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 conditional {typedef _If type;}; +template + struct _LIBCPP_TEMPLATE_VIS conditional {typedef _Then type;}; + +#if _LIBCPP_STD_VER > 11 +template using conditional_t = typename conditional<_Bp, _If, _Then>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_CONDITIONAL_H diff --git a/libcxx/include/__type_traits/decay.h b/libcxx/include/__type_traits/decay.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/decay.h @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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_DECAY_H +#define _LIBCPP___TYPE_TRAITS_DECAY_H + +#include <__config> +#include <__type_traits/add_pointer.h> +#include <__type_traits/conditional.h> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_array.h> +#include <__type_traits/is_function.h> +#include <__type_traits/is_referenceable.h> +#include <__type_traits/remove_cv.h> +#include <__type_traits/remove_extent.h> +#include <__type_traits/remove_reference.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +struct __decay { + typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type; +}; + +template +struct __decay<_Up, true> { +public: + typedef _LIBCPP_NODEBUG typename conditional + < + is_array<_Up>::value, + typename remove_extent<_Up>::type*, + typename conditional + < + is_function<_Up>::value, + typename add_pointer<_Up>::type, + typename remove_cv<_Up>::type + >::type + >::type type; +}; + +template +struct _LIBCPP_TEMPLATE_VIS decay +{ +private: + typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up; +public: + typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type; +}; + +#if _LIBCPP_STD_VER > 11 +template using decay_t = typename decay<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_DECAY_H diff --git a/libcxx/include/__type_traits/enable_if.h b/libcxx/include/__type_traits/enable_if.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/enable_if.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_ENABLE_IF_H +#define _LIBCPP___TYPE_TRAITS_ENABLE_IF_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 enable_if {}; +template struct _LIBCPP_TEMPLATE_VIS enable_if {typedef _Tp type;}; + +template using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type; + +#if _LIBCPP_STD_VER > 11 +template using enable_if_t = typename enable_if<_Bp, _Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_ENABLE_IF_H diff --git a/libcxx/include/__type_traits/is_array.h b/libcxx/include/__type_traits/is_array.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_array.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_ARRAY_H +#define _LIBCPP___TYPE_TRAITS_IS_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 + +// TODO: Clang incorrectly reports that __is_array is true for T[0]. +// Re-enable the branch once https://llvm.org/PR54705 is fixed. +#if __has_keyword(__is_array) && 0 + +template +struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_array_v = __is_array(_Tp); +#endif + +#else + +template struct _LIBCPP_TEMPLATE_VIS is_array + : public false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> + : public true_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> + : public true_type {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_array_v = is_array<_Tp>::value; +#endif + +#endif // __has_keyword(__is_array) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_ARRAY_H diff --git a/libcxx/include/__type_traits/is_base_of.h b/libcxx/include/__type_traits/is_base_of.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_base_of.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_IS_BASE_OF_H +#define _LIBCPP___TYPE_TRAITS_IS_BASE_OF_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_base_of + : public integral_constant {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_base_of_v = is_base_of<_Bp, _Dp>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_BASE_OF_H diff --git a/libcxx/include/__type_traits/is_const.h b/libcxx/include/__type_traits/is_const.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_const.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_CONST_H +#define _LIBCPP___TYPE_TRAITS_IS_CONST_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_const) + +template +struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_const_v = __is_const(_Tp); +#endif + +#else + +template struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_const_v = is_const<_Tp>::value; +#endif + +#endif // __has_keyword(__is_const) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_CONST_H diff --git a/libcxx/include/__type_traits/is_convertible.h b/libcxx/include/__type_traits/is_convertible.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_convertible.h @@ -0,0 +1,108 @@ +//===----------------------------------------------------------------------===// +// +// 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_CONVERTIBLE_H +#define _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_array.h> +#include <__type_traits/is_function.h> +#include <__type_traits/is_void.h> +#include <__type_traits/remove_reference.h> +#include <__utility/declval.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) + +template struct _LIBCPP_TEMPLATE_VIS is_convertible + : public integral_constant {}; + +#else // __has_feature(is_convertible_to) + +namespace __is_convertible_imp +{ +template void __test_convert(_Tp); + +template +struct __is_convertible_test : public false_type {}; + +template +struct __is_convertible_test<_From, _To, + decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type +{}; + +template ::value, + bool _IsFunction = is_function<_Tp>::value, + bool _IsVoid = is_void<_Tp>::value> + struct __is_array_function_or_void {enum {value = 0};}; +template struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; +template struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; +template struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; +} + +template ::type>::value> +struct __is_convertible_check +{ + static const size_t __v = 0; +}; + +template +struct __is_convertible_check<_Tp, 0> +{ + static const size_t __v = sizeof(_Tp); +}; + +template ::value, + unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> +struct __is_convertible + : public integral_constant::value + > +{}; + +template struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; +template struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; +template struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; +template struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; + +template struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; +template struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; +template struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; +template struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; + +template struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; +template struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; +template struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; +template struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; + +template struct _LIBCPP_TEMPLATE_VIS is_convertible + : public __is_convertible<_T1, _T2> +{ + static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; + static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; +}; + +#endif // __has_feature(is_convertible_to) + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H diff --git a/libcxx/include/__type_traits/is_floating_point.h b/libcxx/include/__type_traits/is_floating_point.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_floating_point.h @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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_FLOATING_POINT_H +#define _LIBCPP___TYPE_TRAITS_IS_FLOATING_POINT_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 + +template struct __libcpp_is_floating_point : public false_type {}; +template <> struct __libcpp_is_floating_point : public true_type {}; +template <> struct __libcpp_is_floating_point : public true_type {}; +template <> struct __libcpp_is_floating_point : public true_type {}; + +template struct _LIBCPP_TEMPLATE_VIS is_floating_point + : public __libcpp_is_floating_point::type> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_FLOATING_POINT_H diff --git a/libcxx/include/__type_traits/is_function.h b/libcxx/include/__type_traits/is_function.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_function.h @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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_FUNCTIONAL_H +#define _LIBCPP___TYPE_TRAITS_IS_FUNCTIONAL_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_const.h> +#include <__type_traits/is_reference.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS is_function + : public _BoolConstant< +#ifdef __clang__ + __is_function(_Tp) +#else + !(is_reference<_Tp>::value || is_const::value) +#endif + > {}; + + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_function_v = is_function<_Tp>::value; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_FUNCTIONAL_H diff --git a/libcxx/include/__type_traits/is_integral.h b/libcxx/include/__type_traits/is_integral.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_integral.h @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// 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_INTEGRAL_H +#define _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_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 + +template struct __libcpp_is_integral { enum { value = 0 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +#endif +#ifndef _LIBCPP_HAS_NO_CHAR8_T +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +#endif +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +#endif +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +template <> struct __libcpp_is_integral { enum { value = 1 }; }; +#ifndef _LIBCPP_HAS_NO_INT128 +template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; }; +template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; }; +#endif + +#if __has_keyword(__is_integral) + +template +struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_integral_v = __is_integral(_Tp); +#endif + +#else + +template struct _LIBCPP_TEMPLATE_VIS is_integral + : public _BoolConstant<__libcpp_is_integral::type>::value> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_integral_v = is_integral<_Tp>::value; +#endif + +#endif // __has_keyword(__is_integral) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H diff --git a/libcxx/include/__type_traits/is_member_function_pointer.h b/libcxx/include/__type_traits/is_member_function_pointer.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_member_function_pointer.h @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// 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_FUNCTION_POINTER_H +#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_function.h> +#include <__type_traits/remove_cv.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct __libcpp_is_member_pointer { + enum { + __is_member = false, + __is_func = false, + __is_obj = false + }; +}; +template struct __libcpp_is_member_pointer<_Tp _Up::*> { + enum { + __is_member = true, + __is_func = is_function<_Tp>::value, + __is_obj = !__is_func, + }; +}; + +#if __has_keyword(__is_member_function_pointer) + +template +struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer + : _BoolConstant<__is_member_function_pointer(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); +#endif + +#else // __has_keyword(__is_member_function_pointer) + +template struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer + : public _BoolConstant< __libcpp_is_member_pointer::type>::__is_func > {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; +#endif + +#endif // __has_keyword(__is_member_function_pointer) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H diff --git a/libcxx/include/__type_traits/is_member_object_pointer.h b/libcxx/include/__type_traits/is_member_object_pointer.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_member_object_pointer.h @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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_OBJECT_POINTER_H +#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_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_object_pointer) + +template +struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer + : _BoolConstant<__is_member_object_pointer(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); +#endif + +#else // __has_keyword(__is_member_object_pointer) + +template struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer + : public _BoolConstant< __libcpp_is_member_pointer::type>::__is_obj > {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; +#endif + +#endif // __has_keyword(__is_member_object_pointer) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H diff --git a/libcxx/include/__type_traits/is_null_pointer.h b/libcxx/include/__type_traits/is_null_pointer.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_null_pointer.h @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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_NULL_POINTER_H +#define _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/remove_cv.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct __is_nullptr_t_impl : public false_type {}; +template <> struct __is_nullptr_t_impl : public true_type {}; + +template struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t + : public __is_nullptr_t_impl::type> {}; + +#if _LIBCPP_STD_VER > 11 +template struct _LIBCPP_TEMPLATE_VIS is_null_pointer + : public __is_nullptr_t_impl::type> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; +#endif +#endif // _LIBCPP_STD_VER > 11 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H diff --git a/libcxx/include/__type_traits/is_reference.h b/libcxx/include/__type_traits/is_reference.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_reference.h @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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_REFERENCE_H +#define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_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_lvalue_reference) && \ + __has_keyword(__is_rvalue_reference) && \ + __has_keyword(__is_reference) + +template +struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { }; + +template +struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { }; + +template +struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_reference_v = __is_reference(_Tp); +template +inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); +template +inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); +#endif + +#else // __has_keyword(__is_lvalue_reference) && etc... + +template struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; + +template struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; + +template struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_reference_v = is_reference<_Tp>::value; + +template +inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; + +template +inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; +#endif + +#endif // __has_keyword(__is_lvalue_reference) && etc... + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H diff --git a/libcxx/include/__type_traits/is_reference_wrapper.h b/libcxx/include/__type_traits/is_reference_wrapper.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_reference_wrapper.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_REFERENCE_WRAPPER_H +#define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_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 + +template class _LIBCPP_TEMPLATE_VIS reference_wrapper; + +template struct __is_reference_wrapper_impl : public false_type {}; +template struct __is_reference_wrapper_impl > : public true_type {}; +template struct __is_reference_wrapper + : public __is_reference_wrapper_impl::type> {}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_ENABLE_IF_H diff --git a/libcxx/include/__type_traits/is_referenceable.h b/libcxx/include/__type_traits/is_referenceable.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_referenceable.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_REFERENCEABLE_H +#define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H + +#include <__config> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_same.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +struct __two {char __lx[2];}; + +struct __is_referenceable_impl { + template static _Tp& __test(int); + template static __two __test(...); +}; + +template +struct __is_referenceable : integral_constant(0)), __two>::value> {}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H diff --git a/libcxx/include/__type_traits/is_same.h b/libcxx/include/__type_traits/is_same.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_same.h @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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_SAME_H +#define _LIBCPP___TYPE_TRAITS_IS_SAME_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_same : _BoolConstant<__is_same(_Tp, _Up)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_same_v = __is_same(_Tp, _Up); +#endif + +// _IsSame has the same effect as is_same but instantiates fewer types: +// is_same and is_same are guaranteed to be different types, but +// _IsSame and _IsSame are the same type (namely, false_type). +// Neither GCC nor Clang can mangle the __is_same builtin, so _IsSame +// mustn't be directly used anywhere that contributes to name-mangling +// (such as in a dependent return type). + +template +using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>; + +template +using _IsNotSame = _BoolConstant; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_SAME_H diff --git a/libcxx/include/__type_traits/is_void.h b/libcxx/include/__type_traits/is_void.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_void.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_VOID_H +#define _LIBCPP___TYPE_TRAITS_IS_VOID_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_void) + +template +struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_void_v = __is_void(_Tp); +#endif + +#else + +template struct _LIBCPP_TEMPLATE_VIS is_void + : public is_same::type, void> {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_void_v = is_void<_Tp>::value; +#endif + +#endif // __has_keyword(__is_void) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_VOID_H diff --git a/libcxx/include/__type_traits/is_volatile.h b/libcxx/include/__type_traits/is_volatile.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/is_volatile.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_VOLATILE_H +#define _LIBCPP___TYPE_TRAITS_IS_VOLATILE_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_volatile) + +template +struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { }; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_volatile_v = __is_volatile(_Tp); +#endif + +#else + +template struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; + +#if _LIBCPP_STD_VER > 14 +template +inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; +#endif + +#endif // __has_keyword(__is_volatile) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_IS_VOLATILE_H diff --git a/libcxx/include/__type_traits/remove_const.h b/libcxx/include/__type_traits/remove_const.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/remove_const.h @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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_CONST_H +#define _LIBCPP___TYPE_TRAITS_REMOVE_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 remove_const {typedef _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; +#if _LIBCPP_STD_VER > 11 +template using remove_const_t = typename remove_const<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CONST_H diff --git a/libcxx/include/__type_traits/remove_cv.h b/libcxx/include/__type_traits/remove_cv.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/remove_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_REMOVE_CV_H +#define _LIBCPP___TYPE_TRAITS_REMOVE_CV_H + +#include <__config> +#include <__type_traits/remove_const.h> +#include <__type_traits/remove_volatile.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct _LIBCPP_TEMPLATE_VIS remove_cv +{typedef typename remove_volatile::type>::type type;}; +#if _LIBCPP_STD_VER > 11 +template using remove_cv_t = typename remove_cv<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CV_H diff --git a/libcxx/include/__type_traits/remove_extent.h b/libcxx/include/__type_traits/remove_extent.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/remove_extent.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_EXTENT_H +#define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_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_extent + {typedef _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]> + {typedef _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]> + {typedef _Tp type;}; + +#if _LIBCPP_STD_VER > 11 +template using remove_extent_t = typename remove_extent<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H diff --git a/libcxx/include/__type_traits/remove_reference.h b/libcxx/include/__type_traits/remove_reference.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/remove_reference.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_REMOVE_REFERENCE_H +#define _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_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_reference {typedef _LIBCPP_NODEBUG _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;}; + +#if _LIBCPP_STD_VER > 11 +template using remove_reference_t = typename remove_reference<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H diff --git a/libcxx/include/__type_traits/remove_volatile.h b/libcxx/include/__type_traits/remove_volatile.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__type_traits/remove_volatile.h @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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_VOLATILE_H +#define _LIBCPP___TYPE_TRAITS_REMOVE_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 remove_volatile {typedef _Tp type;}; +template struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; +#if _LIBCPP_STD_VER > 11 +template using remove_volatile_t = typename remove_volatile<_Tp>::type; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___TYPE_TRAITS_REMOVE_VOLATILE_H diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef --- a/libcxx/include/cstddef +++ b/libcxx/include/cstddef @@ -35,6 +35,7 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> +#include <__type_traits/is_integral.h> #include #include @@ -52,34 +53,6 @@ using ::max_align_t _LIBCPP_USING_IF_EXISTS; #endif -template struct __libcpp_is_integral { enum { value = 0 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -#endif -#ifndef _LIBCPP_HAS_NO_CHAR8_T -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -#endif -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -#endif -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -template <> struct __libcpp_is_integral { enum { value = 1 }; }; -#ifndef _LIBCPP_HAS_NO_INT128 -template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; }; -template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; }; -#endif - _LIBCPP_END_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -982,8 +982,33 @@ export functional.__functional.unwrap_ref export * - module integral_constant { private header "__type_traits/integral_constant.h" } - module is_callable { private header "__type_traits/is_callable.h" } + module add_pointer { private header "__type_traits/add_pointer.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 integral_constant { private header "__type_traits/integral_constant.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_callable { private header "__type_traits/is_callable.h" } + module is_const { private header "__type_traits/is_const.h" } + module is_convertible { private header "__type_traits/is_convertible.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_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_null_pointer { private header "__type_traits/is_null_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_void { private header "__type_traits/is_void.h" } + module is_volatile { private header "__type_traits/is_volatile.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_reference { private header "__type_traits/remove_reference.h" } + module remove_volatile { private header "__type_traits/remove_volatile.h" } } module typeindex { header "typeindex" diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -418,8 +418,33 @@ */ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> +#include <__type_traits/add_pointer.h> +#include <__type_traits/conditional.h> +#include <__type_traits/decay.h> +#include <__type_traits/enable_if.h> #include <__type_traits/integral_constant.h> +#include <__type_traits/is_array.h> +#include <__type_traits/is_base_of.h> #include <__type_traits/is_callable.h> +#include <__type_traits/is_const.h> +#include <__type_traits/is_convertible.h> +#include <__type_traits/is_floating_point.h> +#include <__type_traits/is_function.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_null_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_void.h> +#include <__type_traits/is_volatile.h> +#include <__type_traits/remove_const.h> +#include <__type_traits/remove_cv.h> +#include <__type_traits/remove_extent.h> +#include <__type_traits/remove_reference.h> +#include <__type_traits/remove_volatile.h> #include <__utility/declval.h> #include #include @@ -431,18 +456,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TEMPLATE_VIS pair; -template class _LIBCPP_TEMPLATE_VIS reference_wrapper; template struct _LIBCPP_TEMPLATE_VIS hash; -template struct _LIBCPP_TEMPLATE_VIS enable_if {}; -template struct _LIBCPP_TEMPLATE_VIS enable_if {typedef _Tp type;}; - -template using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type; - -#if _LIBCPP_STD_VER > 11 -template using enable_if_t = typename enable_if<_Bp, _Tp>::type; -#endif - template struct _MetaBase; template <> struct _MetaBase { @@ -505,39 +520,8 @@ template struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; - -template - struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;}; -template - struct _LIBCPP_TEMPLATE_VIS conditional {typedef _Then type;}; - -#if _LIBCPP_STD_VER > 11 -template using conditional_t = typename conditional<_Bp, _If, _Then>::type; -#endif - // is_same -template -struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_same_v = __is_same(_Tp, _Up); -#endif - -// _IsSame has the same effect as is_same but instantiates fewer types: -// is_same and is_same are guaranteed to be different types, but -// _IsSame and _IsSame are the same type (namely, false_type). -// Neither GCC nor Clang can mangle the __is_same builtin, so _IsSame -// mustn't be directly used anywhere that contributes to name-mangling -// (such as in a dependent return type). - -template -using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>; - -template -using _IsNotSame = _BoolConstant; - template using __test_for_primary_template = __enable_if_t< _IsSame<_Tp, typename _Tp::__primary_template>::value @@ -547,148 +531,8 @@ __test_for_primary_template, _Tp >; -// helper class - -struct __two {char __lx[2];}; - -// is_const - -#if __has_keyword(__is_const) - -template -struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_const_v = __is_const(_Tp); -#endif - -#else - -template struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_const_v = is_const<_Tp>::value; -#endif - -#endif // __has_keyword(__is_const) - -// is_volatile - -#if __has_keyword(__is_volatile) - -template -struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_volatile_v = __is_volatile(_Tp); -#endif - -#else - -template struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; -#endif - -#endif // __has_keyword(__is_volatile) - -// remove_const - -template struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; -#if _LIBCPP_STD_VER > 11 -template using remove_const_t = typename remove_const<_Tp>::type; -#endif - -// remove_volatile - -template struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; -#if _LIBCPP_STD_VER > 11 -template using remove_volatile_t = typename remove_volatile<_Tp>::type; -#endif - -// remove_cv - -template struct _LIBCPP_TEMPLATE_VIS remove_cv -{typedef typename remove_volatile::type>::type type;}; -#if _LIBCPP_STD_VER > 11 -template using remove_cv_t = typename remove_cv<_Tp>::type; -#endif - -// is_void - -#if __has_keyword(__is_void) - -template -struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_void_v = __is_void(_Tp); -#endif - -#else - -template struct _LIBCPP_TEMPLATE_VIS is_void - : public is_same::type, void> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_void_v = is_void<_Tp>::value; -#endif - -#endif // __has_keyword(__is_void) - -// __is_nullptr_t - -template struct __is_nullptr_t_impl : public false_type {}; -template <> struct __is_nullptr_t_impl : public true_type {}; - -template struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t - : public __is_nullptr_t_impl::type> {}; - -#if _LIBCPP_STD_VER > 11 -template struct _LIBCPP_TEMPLATE_VIS is_null_pointer - : public __is_nullptr_t_impl::type> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; -#endif -#endif // _LIBCPP_STD_VER > 11 - // is_integral -#if __has_keyword(__is_integral) - -template -struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_integral_v = __is_integral(_Tp); -#endif - -#else - -template struct _LIBCPP_TEMPLATE_VIS is_integral - : public _BoolConstant<__libcpp_is_integral::type>::value> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_integral_v = is_integral<_Tp>::value; -#endif - -#endif // __has_keyword(__is_integral) - // [basic.fundamental] defines five standard signed integer types; // __int128_t is an extended signed integer type. // The signed and unsigned integer types, plus bool and the @@ -714,52 +558,6 @@ template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {}; #endif -// is_floating_point -// implements __libcpp_floating_point - -template struct __libcpp_is_floating_point : public false_type {}; -template <> struct __libcpp_is_floating_point : public true_type {}; -template <> struct __libcpp_is_floating_point : public true_type {}; -template <> struct __libcpp_is_floating_point : public true_type {}; - -template struct _LIBCPP_TEMPLATE_VIS is_floating_point - : public __libcpp_is_floating_point::type> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; -#endif - -// is_array - -// TODO: Clang incorrectly reports that __is_array is true for T[0]. -// Re-enable the branch once https://llvm.org/PR54705 is fixed. -#if __has_keyword(__is_array) && 0 - -template -struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_array_v = __is_array(_Tp); -#endif - -#else - -template struct _LIBCPP_TEMPLATE_VIS is_array - : public false_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> - : public true_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> - : public true_type {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_array_v = is_array<_Tp>::value; -#endif - -#endif // __has_keyword(__is_array) - // is_pointer // Before AppleClang 12.0.5, __is_pointer didn't work for Objective-C types. @@ -797,55 +595,6 @@ #endif // __has_keyword(__is_pointer) -// is_reference - -#if __has_keyword(__is_lvalue_reference) && \ - __has_keyword(__is_rvalue_reference) && \ - __has_keyword(__is_reference) - -template -struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { }; - -template -struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { }; - -template -struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_reference_v = __is_reference(_Tp); -template -inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); -template -inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); -#endif - -#else // __has_keyword(__is_lvalue_reference) && etc... - -template struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; - -template struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; - -template struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; -template struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_reference_v = is_reference<_Tp>::value; - -template -inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; - -template -inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; -#endif - -#endif // __has_keyword(__is_lvalue_reference) && etc... - // is_union #if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC) @@ -891,61 +640,6 @@ inline constexpr bool is_class_v = is_class<_Tp>::value; #endif -// is_function - -template struct _LIBCPP_TEMPLATE_VIS is_function - : public _BoolConstant< -#ifdef __clang__ - __is_function(_Tp) -#else - !(is_reference<_Tp>::value || is_const::value) -#endif - > {}; - - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_function_v = is_function<_Tp>::value; -#endif - -template struct __libcpp_is_member_pointer { - enum { - __is_member = false, - __is_func = false, - __is_obj = false - }; -}; -template struct __libcpp_is_member_pointer<_Tp _Up::*> { - enum { - __is_member = true, - __is_func = is_function<_Tp>::value, - __is_obj = !__is_func, - }; -}; - -#if __has_keyword(__is_member_function_pointer) - -template -struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer - : _BoolConstant<__is_member_function_pointer(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); -#endif - -#else // __has_keyword(__is_member_function_pointer) - -template struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer - : public _BoolConstant< __libcpp_is_member_pointer::type>::__is_func > {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; -#endif - -#endif // __has_keyword(__is_member_function_pointer) - // is_member_pointer #if __has_keyword(__is_member_pointer) @@ -970,31 +664,6 @@ #endif // __has_keyword(__is_member_pointer) -// is_member_object_pointer - -#if __has_keyword(__is_member_object_pointer) - -template -struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer - : _BoolConstant<__is_member_object_pointer(_Tp)> { }; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); -#endif - -#else // __has_keyword(__is_member_object_pointer) - -template struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer - : public _BoolConstant< __libcpp_is_member_pointer::type>::__is_obj > {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; -#endif - -#endif // __has_keyword(__is_member_object_pointer) - // is_enum #if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) @@ -1159,18 +828,6 @@ #endif // __has_keyword(__is_compound) -// __is_referenceable [defns.referenceable] - -struct __is_referenceable_impl { - template static _Tp& __test(int); - template static __two __test(...); -}; - -template -struct __is_referenceable : integral_constant(0)), __two>::value> {}; - - // add_const template struct _LIBCPP_TEMPLATE_VIS add_const { @@ -1200,16 +857,6 @@ template using add_cv_t = typename add_cv<_Tp>::type; #endif -// remove_reference - -template struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;}; - -#if _LIBCPP_STD_VER > 11 -template using remove_reference_t = typename remove_reference<_Tp>::type; -#endif - // add_lvalue_reference template ::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; @@ -1275,21 +922,6 @@ // add_pointer -template ::value || - _IsSame::type, void>::value> -struct __add_pointer_impl - {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;}; -template struct __add_pointer_impl<_Tp, false> - {typedef _LIBCPP_NODEBUG _Tp type;}; - -template struct _LIBCPP_TEMPLATE_VIS add_pointer - {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;}; - -#if _LIBCPP_STD_VER > 11 -template using add_pointer_t = typename add_pointer<_Tp>::type; -#endif - // type_identity template @@ -1422,19 +1054,6 @@ #endif // __has_keyword(__array_extent) -// remove_extent - -template struct _LIBCPP_TEMPLATE_VIS remove_extent - {typedef _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]> - {typedef _Tp type;}; -template struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]> - {typedef _Tp type;}; - -#if _LIBCPP_STD_VER > 11 -template using remove_extent_t = typename remove_extent<_Tp>::type; -#endif - // remove_all_extents template struct _LIBCPP_TEMPLATE_VIS remove_all_extents @@ -1468,42 +1087,6 @@ bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; #endif -// decay - -template -struct __decay { - typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type; -}; - -template -struct __decay<_Up, true> { -public: - typedef _LIBCPP_NODEBUG typename conditional - < - is_array<_Up>::value, - typename remove_extent<_Up>::type*, - typename conditional - < - is_function<_Up>::value, - typename add_pointer<_Up>::type, - typename remove_cv<_Up>::type - >::type - >::type type; -}; - -template -struct _LIBCPP_TEMPLATE_VIS decay -{ -private: - typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up; -public: - typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type; -}; - -#if _LIBCPP_STD_VER > 11 -template using decay_t = typename decay<_Tp>::type; -#endif - // is_abstract template struct _LIBCPP_TEMPLATE_VIS is_abstract @@ -1540,17 +1123,6 @@ #endif // _LIBCPP_STD_VER > 14 -// is_base_of - -template -struct _LIBCPP_TEMPLATE_VIS is_base_of - : public integral_constant {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_base_of_v = is_base_of<_Bp, _Dp>::value; -#endif - // __is_core_convertible // [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed. @@ -1566,87 +1138,6 @@ static_cast(0) ( static_cast<_Tp(*)()>(0)() ) )> : public true_type {}; -// is_convertible - -#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) - -template struct _LIBCPP_TEMPLATE_VIS is_convertible - : public integral_constant {}; - -#else // __has_feature(is_convertible_to) - -namespace __is_convertible_imp -{ -template void __test_convert(_Tp); - -template -struct __is_convertible_test : public false_type {}; - -template -struct __is_convertible_test<_From, _To, - decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type -{}; - -template ::value, - bool _IsFunction = is_function<_Tp>::value, - bool _IsVoid = is_void<_Tp>::value> - struct __is_array_function_or_void {enum {value = 0};}; -template struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; -template struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; -template struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; -} - -template ::type>::value> -struct __is_convertible_check -{ - static const size_t __v = 0; -}; - -template -struct __is_convertible_check<_Tp, 0> -{ - static const size_t __v = sizeof(_Tp); -}; - -template ::value, - unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> -struct __is_convertible - : public integral_constant::value - > -{}; - -template struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; -template struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; -template struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; -template struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; - -template struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; -template struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; -template struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; -template struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; - -template struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; -template struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; -template struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; -template struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; - -template struct _LIBCPP_TEMPLATE_VIS is_convertible - : public __is_convertible<_T1, _T2> -{ - static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; - static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; -}; - -#endif // __has_feature(is_convertible_to) - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; -#endif - // is_nothrow_convertible #if _LIBCPP_STD_VER > 17 @@ -3349,10 +2840,6 @@ inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; #endif -template struct __is_reference_wrapper_impl : public false_type {}; -template struct __is_reference_wrapper_impl > : public true_type {}; -template struct __is_reference_wrapper - : public __is_reference_wrapper_impl::type> {}; #ifndef _LIBCPP_CXX03_LANG diff --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp --- a/libcxx/test/libcxx/private_headers.verify.cpp +++ b/libcxx/test/libcxx/private_headers.verify.cpp @@ -441,8 +441,33 @@ #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_pointer.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_pointer.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/integral_constant.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/integral_constant.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_callable.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_callable.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_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_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_null_pointer.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/is_null_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_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/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_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 <__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'}}