[libc++][NFC] Merge add_{r,l}value_reference.h (#147022)

The implementation is now quite simple, so it doesn't make a ton of
sense to have these in separate headers.
This commit is contained in:
Nikolas Klauser 2025-07-05 18:11:36 +02:00 committed by GitHub
parent bdbac2bb49
commit 1121d64ba9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 42 additions and 85 deletions

View File

@ -778,9 +778,8 @@ set(files
__tuple/tuple_size.h
__tuple/tuple_types.h
__type_traits/add_cv_quals.h
__type_traits/add_lvalue_reference.h
__type_traits/add_pointer.h
__type_traits/add_rvalue_reference.h
__type_traits/add_reference.h
__type_traits/aligned_storage.h
__type_traits/aligned_union.h
__type_traits/alignment_of.h

View File

@ -12,7 +12,7 @@
#include <__concepts/common_reference_with.h>
#include <__concepts/same_as.h>
#include <__config>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/common_reference.h>
#include <__type_traits/common_type.h>
#include <__utility/declval.h>

View File

@ -34,7 +34,7 @@
#include <__memory/shared_count.h>
#include <__memory/uninitialized_algorithms.h>
#include <__memory/unique_ptr.h>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/conditional.h>
#include <__type_traits/conjunction.h>
#include <__type_traits/disjunction.h>

View File

@ -24,7 +24,7 @@
#include <__memory/auto_ptr.h>
#include <__memory/compressed_pair.h>
#include <__memory/pointer_traits.h>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/common_type.h>
#include <__type_traits/conditional.h>
#include <__type_traits/dependent_type.h>

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
#define _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
#ifndef _LIBCPP___TYPE_TRAITS_ADD_REFERENCE_H
#define _LIBCPP___TYPE_TRAITS_ADD_REFERENCE_H
#include <__config>
@ -35,6 +35,24 @@ template <class _Tp>
using add_lvalue_reference_t = __add_lvalue_reference_t<_Tp>;
#endif
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference {
using type _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
};
#ifdef _LIBCPP_COMPILER_GCC
template <class _Tp>
using __add_rvalue_reference_t _LIBCPP_NODEBUG = typename add_rvalue_reference<_Tp>::type;
#else
template <class _Tp>
using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp>
using add_rvalue_reference_t = __add_rvalue_reference_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
#endif // _LIBCPP___TYPE_TRAITS_ADD_REFERENCE_H

View File

@ -1,40 +0,0 @@
//===----------------------------------------------------------------------===//
//
// 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>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference {
using type _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
};
#ifdef _LIBCPP_COMPILER_GCC
template <class _Tp>
using __add_rvalue_reference_t _LIBCPP_NODEBUG = typename add_rvalue_reference<_Tp>::type;
#else
template <class _Tp>
using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp>
using add_rvalue_reference_t = __add_rvalue_reference_t<_Tp>;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H

View File

@ -10,8 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_COPY_CVREF_H
#include <__config>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/copy_cv.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -10,8 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
#include <__config>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -10,7 +10,6 @@
#define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
#include <__config>
#include <__cstddef/size_t.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@ -19,26 +18,16 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class>
inline const bool __is_bounded_array_v = false;
template <class _Tp, size_t _Np>
inline const bool __is_bounded_array_v<_Tp[_Np]> = true;
template <class _Tp>
inline const bool __is_bounded_array_v = __is_bounded_array(_Tp);
#if _LIBCPP_STD_VER >= 20
template <class>
struct _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : false_type {};
_LIBCPP_DIAGNOSTIC_PUSH
# if __has_warning("-Winvalid-specialization")
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
# endif
template <class _Tp, size_t _Np>
struct is_bounded_array<_Tp[_Np]> : true_type {};
_LIBCPP_DIAGNOSTIC_POP
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : bool_constant<__is_bounded_array(_Tp)> {};
template <class _Tp>
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = is_bounded_array<_Tp>::value;
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = __is_bounded_array(_Tp);
#endif

View File

@ -10,8 +10,7 @@
#define _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H
#include <__config>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -10,8 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
#include <__config>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -10,8 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H
#include <__config>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -11,7 +11,7 @@
#include <__config>
#include <__cstddef/size_t.h>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/integral_constant.h>
#include <__type_traits/is_assignable.h>

View File

@ -10,8 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
#include <__config>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -10,8 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
#include <__config>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/add_reference.h>
#include <__type_traits/integral_constant.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -57,8 +57,8 @@ public:
# include <__cstddef/size_t.h>
# include <__functional/hash.h>
# include <__functional/operations.h>
# include <__type_traits/add_lvalue_reference.h>
# include <__type_traits/add_pointer.h>
# include <__type_traits/add_reference.h>
# include <__type_traits/common_type.h>
# include <__type_traits/enable_if.h>
# include <__type_traits/is_convertible.h>

View File

@ -393,7 +393,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
# include <__system_error/error_code.h>
# include <__system_error/error_condition.h>
# include <__thread/thread.h>
# include <__type_traits/add_lvalue_reference.h>
# include <__type_traits/add_reference.h>
# include <__type_traits/aligned_storage.h>
# include <__type_traits/conditional.h>
# include <__type_traits/decay.h>

View File

@ -65,9 +65,8 @@ module std_core [system] {
module type_traits {
module add_cv_quals { header "__type_traits/add_cv_quals.h" }
module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" }
module add_pointer { header "__type_traits/add_pointer.h" }
module add_rvalue_reference { header "__type_traits/add_rvalue_reference.h" }
module add_reference { header "__type_traits/add_reference.h" }
module aligned_storage { header "__type_traits/aligned_storage.h" }
module aligned_union { header "__type_traits/aligned_union.h" }
module alignment_of { header "__type_traits/alignment_of.h" }

View File

@ -463,9 +463,8 @@ namespace std
#else
# include <__config>
# include <__type_traits/add_cv_quals.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_reference.h>
# include <__type_traits/aligned_storage.h>
# include <__type_traits/aligned_union.h>
# include <__type_traits/alignment_of.h>