[libcxx][modularisation] moves <utility> content out of <type_traits>
Moves:
* `std::move`, `std::forward`, `std::declval`, and `std::swap` into
`__utility/${FUNCTION_NAME}`.
* `std::swap_ranges` and `std::iter_swap` into
`__algorithm/${FUNCTION_NAME}`
Differential Revision: https://reviews.llvm.org/D103734
NOKEYCHECK=True
GitOrigin-RevId: 6adbc83ee9e46b476e0f75d5671c3a21f675a936
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 6773ec3..faaf932 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -34,6 +34,7 @@
__algorithm/is_permutation.h
__algorithm/is_sorted.h
__algorithm/is_sorted_until.h
+ __algorithm/iter_swap.h
__algorithm/lexicographical_compare.h
__algorithm/lower_bound.h
__algorithm/make_heap.h
@@ -85,6 +86,7 @@
__algorithm/sort_heap.h
__algorithm/stable_partition.h
__algorithm/stable_sort.h
+ __algorithm/swap_ranges.h
__algorithm/transform.h
__algorithm/unique_copy.h
__algorithm/unique.h
@@ -157,6 +159,11 @@
__tree
__tuple
__undef_macros
+ __utility/__decay_copy.h
+ __utility/declval.h
+ __utility/forward.h
+ __utility/move.h
+ __utility/swap.h
__utility/to_underlying.h
algorithm
any
diff --git a/include/__algorithm/inplace_merge.h b/include/__algorithm/inplace_merge.h
index 81db692..24ad363 100644
--- a/include/__algorithm/inplace_merge.h
+++ b/include/__algorithm/inplace_merge.h
@@ -17,6 +17,7 @@
#include <__algorithm/min.h>
#include <__algorithm/upper_bound.h>
#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
#include <memory>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/include/__algorithm/iter_swap.h b/include/__algorithm/iter_swap.h
new file mode 100644
index 0000000..b63bce6
--- /dev/null
+++ b/include/__algorithm/iter_swap.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___ALGORITHM_ITER_SWAP_H
+#define _LIBCPP___ALGORITHM_ITER_SWAP_H
+
+#include <__config>
+#include <__utility/declval.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void iter_swap(_ForwardIterator1 __a,
+ _ForwardIterator2 __b)
+ // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
+ _NOEXCEPT_(_NOEXCEPT_(swap(*declval<_ForwardIterator1>(), *declval<_ForwardIterator2>()))) {
+ swap(*__a, *__b);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_ITER_SWAP_H
diff --git a/include/__algorithm/move.h b/include/__algorithm/move.h
index 120f00f..f5fc748 100644
--- a/include/__algorithm/move.h
+++ b/include/__algorithm/move.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/unwrap_iter.h>
+#include <__utility/move.h>
#include <cstring>
#include <utility>
#include <type_traits>
diff --git a/include/__algorithm/next_permutation.h b/include/__algorithm/next_permutation.h
index 91eef92..a337e5e 100644
--- a/include/__algorithm/next_permutation.h
+++ b/include/__algorithm/next_permutation.h
@@ -14,7 +14,7 @@
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/reverse.h>
#include <__iterator/iterator_traits.h>
-#include <type_traits> // swap
+#include <__utility/swap.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/nth_element.h b/include/__algorithm/nth_element.h
index 622c669..67a03cf 100644
--- a/include/__algorithm/nth_element.h
+++ b/include/__algorithm/nth_element.h
@@ -14,7 +14,7 @@
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/sort.h>
#include <__iterator/iterator_traits.h>
-#include <type_traits> // swap
+#include <__utility/swap.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/partial_sort.h b/include/__algorithm/partial_sort.h
index 377f6d4..4f9872c 100644
--- a/include/__algorithm/partial_sort.h
+++ b/include/__algorithm/partial_sort.h
@@ -16,7 +16,7 @@
#include <__algorithm/sift_down.h>
#include <__algorithm/sort_heap.h>
#include <__iterator/iterator_traits.h>
-#include <type_traits> // swap
+#include <__utility/swap.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/partition.h b/include/__algorithm/partition.h
index 9b6f37c..c859eac 100644
--- a/include/__algorithm/partition.h
+++ b/include/__algorithm/partition.h
@@ -11,6 +11,8 @@
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+#include <utility> // pair
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/include/__algorithm/pop_heap.h b/include/__algorithm/pop_heap.h
index 356a433..7ebbef2 100644
--- a/include/__algorithm/pop_heap.h
+++ b/include/__algorithm/pop_heap.h
@@ -14,7 +14,7 @@
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/sift_down.h>
#include <__iterator/iterator_traits.h>
-#include <type_traits> // swap
+#include <__utility/swap.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/prev_permutation.h b/include/__algorithm/prev_permutation.h
index 24945b2..d6daa73 100644
--- a/include/__algorithm/prev_permutation.h
+++ b/include/__algorithm/prev_permutation.h
@@ -14,7 +14,7 @@
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/reverse.h>
#include <__iterator/iterator_traits.h>
-#include <type_traits> // swap
+#include <__utility/swap.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/push_heap.h b/include/__algorithm/push_heap.h
index c2ce07d..82a7c12 100644
--- a/include/__algorithm/push_heap.h
+++ b/include/__algorithm/push_heap.h
@@ -13,7 +13,7 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__iterator/iterator_traits.h>
-#include <type_traits> // swap
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/remove.h b/include/__algorithm/remove.h
index f8a6f27..4717d7d 100644
--- a/include/__algorithm/remove.h
+++ b/include/__algorithm/remove.h
@@ -11,8 +11,8 @@
#include <__config>
#include <__algorithm/find.h>
-#include <utility>
-#include <type_traits>
+#include <__algorithm/find_if.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/reverse.h b/include/__algorithm/reverse.h
index 210a332..e538de1 100644
--- a/include/__algorithm/reverse.h
+++ b/include/__algorithm/reverse.h
@@ -10,8 +10,8 @@
#define _LIBCPP___ALGORITHM_REVERSE_H
#include <__config>
+#include <__algorithm/iter_swap.h>
#include <__iterator/iterator_traits.h>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/rotate.h b/include/__algorithm/rotate.h
index 812e400..0c9ccd7 100644
--- a/include/__algorithm/rotate.h
+++ b/include/__algorithm/rotate.h
@@ -11,11 +11,13 @@
#include <__algorithm/move.h>
#include <__algorithm/move_backward.h>
+#include <__algorithm/swap_ranges.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__iterator/next.h>
#include <__iterator/prev.h>
-#include <type_traits>
+#include <__utility/swap.h>
+#include <iterator>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/shift_right.h b/include/__algorithm/shift_right.h
index 983252d..5cb4195 100644
--- a/include/__algorithm/shift_right.h
+++ b/include/__algorithm/shift_right.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__algorithm/move.h>
#include <__algorithm/move_backward.h>
+#include <__algorithm/swap_ranges.h>
#include <__iterator/iterator_traits.h>
#include <type_traits> // swap
diff --git a/include/__algorithm/shuffle.h b/include/__algorithm/shuffle.h
index 0b4d3d4..637fca5 100644
--- a/include/__algorithm/shuffle.h
+++ b/include/__algorithm/shuffle.h
@@ -12,9 +12,9 @@
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__random/uniform_int_distribution.h>
+#include <__utility/swap.h>
#include <cstddef>
#include <cstdint>
-#include <type_traits> // swap
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/sift_down.h b/include/__algorithm/sift_down.h
index ce38d7f..dd4b54e 100644
--- a/include/__algorithm/sift_down.h
+++ b/include/__algorithm/sift_down.h
@@ -11,8 +11,7 @@
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <utility>
-#include <type_traits>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__algorithm/sort.h b/include/__algorithm/sort.h
index eb3a5de..39ec213 100644
--- a/include/__algorithm/sort.h
+++ b/include/__algorithm/sort.h
@@ -15,6 +15,7 @@
#include <__algorithm/min_element.h>
#include <__algorithm/partial_sort.h>
#include <__algorithm/unwrap_iter.h>
+#include <__utility/swap.h>
#include <memory>
#include <type_traits> // swap
diff --git a/include/__algorithm/stable_partition.h b/include/__algorithm/stable_partition.h
index 7ed8c1e..931335f 100644
--- a/include/__algorithm/stable_partition.h
+++ b/include/__algorithm/stable_partition.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__algorithm/rotate.h>
#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
#include <memory>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/include/__algorithm/stable_sort.h b/include/__algorithm/stable_sort.h
index e94a8e0..32b239a 100644
--- a/include/__algorithm/stable_sort.h
+++ b/include/__algorithm/stable_sort.h
@@ -15,6 +15,7 @@
#include <__algorithm/inplace_merge.h>
#include <__algorithm/sort.h>
#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
#include <memory>
#include <type_traits> // swap
diff --git a/include/__algorithm/swap_ranges.h b/include/__algorithm/swap_ranges.h
new file mode 100644
index 0000000..3c72dbd
--- /dev/null
+++ b/include/__algorithm/swap_ranges.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___ALGORITHM_SWAP_RANGES_H
+#define _LIBCPP___ALGORITHM_SWAP_RANGES_H
+
+#include <__config>
+#include <__utility/swap.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator2
+swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
+ for (; __first1 != __last1; ++__first1, (void)++__first2)
+ swap(*__first1, *__first2);
+ return __first2;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SWAP_RANGES_H
diff --git a/include/__algorithm/unique.h b/include/__algorithm/unique.h
index c4ac052..fb6251a 100644
--- a/include/__algorithm/unique.h
+++ b/include/__algorithm/unique.h
@@ -13,7 +13,7 @@
#include <__algorithm/comp.h>
#include <__algorithm/adjacent_find.h>
#include <__iterator/iterator_traits.h>
-#include <utility>
+#include <__utility/move.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/include/__iterator/concepts.h b/include/__iterator/concepts.h
index 95f6891..e3664db 100644
--- a/include/__iterator/concepts.h
+++ b/include/__iterator/concepts.h
@@ -16,6 +16,7 @@
#include <__iterator/iterator_traits.h>
#include <__iterator/readable_traits.h>
#include <__memory/pointer_traits.h>
+#include <__utility/forward.h>
#include <concepts>
#include <type_traits>
diff --git a/include/__iterator/iter_move.h b/include/__iterator/iter_move.h
index c83eb77..e384c56 100644
--- a/include/__iterator/iter_move.h
+++ b/include/__iterator/iter_move.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/forward.h>
#include <concepts> // __class_or_enum
#include <type_traits>
#include <utility>
diff --git a/include/__memory/allocator.h b/include/__memory/allocator.h
index cbce817..2c21a16 100644
--- a/include/__memory/allocator.h
+++ b/include/__memory/allocator.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__memory/allocator_traits.h>
+#include <__utility/forward.h>
#include <cstddef>
#include <new>
#include <stdexcept>
diff --git a/include/__memory/allocator_traits.h b/include/__memory/allocator_traits.h
index dfef264..a02af0d 100644
--- a/include/__memory/allocator_traits.h
+++ b/include/__memory/allocator_traits.h
@@ -13,6 +13,7 @@
#include <__config>
#include <__memory/construct_at.h>
#include <__memory/pointer_traits.h>
+#include <__utility/forward.h>
#include <limits>
#include <type_traits>
diff --git a/include/__memory/compressed_pair.h b/include/__memory/compressed_pair.h
index fcdfaf2..08f0318 100644
--- a/include/__memory/compressed_pair.h
+++ b/include/__memory/compressed_pair.h
@@ -11,6 +11,7 @@
#define _LIBCPP___MEMORY_COMPRESSED_PAIR_H
#include <__config>
+#include <__utility/forward.h>
#include <tuple> // needed in c++03 for some constructors
#include <type_traits>
#include <utility>
diff --git a/include/__memory/construct_at.h b/include/__memory/construct_at.h
index 8cd7d5e..7ab1931 100644
--- a/include/__memory/construct_at.h
+++ b/include/__memory/construct_at.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__debug>
+#include <__utility/forward.h>
#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/include/__memory/shared_ptr.h b/include/__memory/shared_ptr.h
index ab92651..64f5b06 100644
--- a/include/__memory/shared_ptr.h
+++ b/include/__memory/shared_ptr.h
@@ -20,6 +20,7 @@
#include <__memory/compressed_pair.h>
#include <__memory/pointer_traits.h>
#include <__memory/unique_ptr.h>
+#include <__utility/forward.h>
#include <cstddef>
#include <cstdlib> // abort
#include <iosfwd>
diff --git a/include/__memory/unique_ptr.h b/include/__memory/unique_ptr.h
index 9442e54..56a3637 100644
--- a/include/__memory/unique_ptr.h
+++ b/include/__memory/unique_ptr.h
@@ -14,6 +14,7 @@
#include <__functional_base> // std::less
#include <__memory/allocator_traits.h> // __pointer
#include <__memory/compressed_pair.h>
+#include <__utility/forward.h>
#include <cstddef>
#include <type_traits>
#include <utility>
diff --git a/include/__ranges/access.h b/include/__ranges/access.h
index 9e9fb52..528dba1 100644
--- a/include/__ranges/access.h
+++ b/include/__ranges/access.h
@@ -13,6 +13,8 @@
#include <__iterator/concepts.h>
#include <__iterator/readable_traits.h>
#include <__ranges/enable_borrowed_range.h>
+#include <__utility/__decay_copy.h>
+#include <__utility/forward.h>
#include <concepts>
#include <type_traits>
diff --git a/include/__ranges/all.h b/include/__ranges/all.h
index 2dfdb78..d1312d1 100644
--- a/include/__ranges/all.h
+++ b/include/__ranges/all.h
@@ -16,6 +16,8 @@
#include <__ranges/concepts.h>
#include <__ranges/ref_view.h>
#include <__ranges/subrange.h>
+#include <__utility/__decay_copy.h>
+#include <__utility/forward.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/include/__ranges/data.h b/include/__ranges/data.h
index 99d1811..f001178 100644
--- a/include/__ranges/data.h
+++ b/include/__ranges/data.h
@@ -14,6 +14,7 @@
#include <__iterator/iterator_traits.h>
#include <__memory/pointer_traits.h>
#include <__ranges/access.h>
+#include <__utility/forward.h>
#include <concepts>
#include <type_traits>
diff --git a/include/__ranges/empty.h b/include/__ranges/empty.h
index 05f492c..186be96 100644
--- a/include/__ranges/empty.h
+++ b/include/__ranges/empty.h
@@ -13,6 +13,7 @@
#include <__iterator/concepts.h>
#include <__ranges/access.h>
#include <__ranges/size.h>
+#include <__utility/forward.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/include/__ranges/size.h b/include/__ranges/size.h
index 0d3685a..999d211 100644
--- a/include/__ranges/size.h
+++ b/include/__ranges/size.h
@@ -13,6 +13,8 @@
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
#include <__ranges/access.h>
+#include <__utility/__decay_copy.h>
+#include <__utility/forward.h>
#include <concepts>
#include <type_traits>
diff --git a/include/__split_buffer b/include/__split_buffer
index 85cc0db..901c037 100644
--- a/include/__split_buffer
+++ b/include/__split_buffer
@@ -3,6 +3,7 @@
#define _LIBCPP_SPLIT_BUFFER
#include <__config>
+#include <__utility/forward.h>
#include <algorithm>
#include <type_traits>
diff --git a/include/__tree b/include/__tree
index b599a04..5f9ba8b 100644
--- a/include/__tree
+++ b/include/__tree
@@ -11,6 +11,7 @@
#define _LIBCPP___TREE
#include <__config>
+#include <__utility/forward.h>
#include <algorithm>
#include <iterator>
#include <memory>
diff --git a/include/__utility/__decay_copy.h b/include/__utility/__decay_copy.h
new file mode 100644
index 0000000..eda8db6
--- /dev/null
+++ b/include/__utility/__decay_copy.h
@@ -0,0 +1,39 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_DECAY_COPY_H
+#define _LIBCPP___TYPE_TRAITS_DECAY_COPY_H
+
+#include <__config>
+#include <__utility/forward.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY typename decay<_Tp>::type __decay_copy(_Tp&& __t)
+#if _LIBCPP_STD_VER > 17
+ noexcept(is_nothrow_convertible_v<_Tp, remove_reference_t<_Tp> >)
+#endif
+{
+ return _VSTD::forward<_Tp>(__t);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___TYPE_TRAITS_DECAY_COPY_H
diff --git a/include/__utility/declval.h b/include/__utility/declval.h
new file mode 100644
index 0000000..185527c
--- /dev/null
+++ b/include/__utility/declval.h
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___UTILITY_DECLVAL_H
+#define _LIBCPP___UTILITY_DECLVAL_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Suppress deprecation notice for volatile-qualified return type resulting
+// from volatile-qualified types _Tp.
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp>
+_Tp&& __declval(int);
+template <class _Tp>
+_Tp __declval(long);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+template <class _Tp>
+decltype(__declval<_Tp>(0)) declval() _NOEXCEPT;
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_DECLVAL_H
diff --git a/include/__utility/forward.h b/include/__utility/forward.h
new file mode 100644
index 0000000..c994f12
--- /dev/null
+++ b/include/__utility/forward.h
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_FORWARD_H
+#define _LIBCPP___UTILITY_FORWARD_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp&&
+forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT {
+ return static_cast<_Tp&&>(__t);
+}
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp&&
+forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT {
+ static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue");
+ return static_cast<_Tp&&>(__t);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_FORWARD_H
diff --git a/include/__utility/move.h b/include/__utility/move.h
new file mode 100644
index 0000000..d3c56f9
--- /dev/null
+++ b/include/__utility/move.h
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_MOVE_H
+#define _LIBCPP___UTILITY_MOVE_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename remove_reference<_Tp>::type&&
+move(_Tp&& __t) _NOEXCEPT {
+ typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
+ return static_cast<_Up&&>(__t);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+using __move_if_noexcept_result_t =
+ typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&,
+ _Tp&&>::type;
+#else // _LIBCPP_CXX03_LANG
+template <class _Tp>
+using __move_if_noexcept_result_t = const _Tp&;
+#endif
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __move_if_noexcept_result_t<_Tp>
+move_if_noexcept(_Tp& __x) _NOEXCEPT {
+ return _VSTD::move(__x);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_MOVE_H
diff --git a/include/__utility/swap.h b/include/__utility/swap.h
new file mode 100644
index 0000000..8af83a9
--- /dev/null
+++ b/include/__utility/swap.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___UTILITY_SWAP_H
+#define _LIBCPP___UTILITY_SWAP_H
+
+#include <__config>
+#include <__utility/declval.h>
+#include <__utility/move.h>
+#include <type_traits>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type;
+#else
+template <class>
+using __swap_result_t = void;
+#endif
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_AFTER_CXX17 swap(_Tp& __x, _Tp& __y)
+ _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value) {
+ _Tp __t(_VSTD::move(__x));
+ __x = _VSTD::move(__y);
+ __y = _VSTD::move(__t);
+}
+
+template <class _Tp, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if<__is_swappable<_Tp>::value>::type
+swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
+ for (size_t __i = 0; __i != _Np; ++__i) {
+ swap(__a[__i], __b[__i]);
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_SWAP_H
diff --git a/include/algorithm b/include/algorithm
index c040ede..849302a 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -695,6 +695,7 @@
#include <__algorithm/is_permutation.h>
#include <__algorithm/is_sorted.h>
#include <__algorithm/is_sorted_until.h>
+#include <__algorithm/iter_swap.h>
#include <__algorithm/lexicographical_compare.h>
#include <__algorithm/lower_bound.h>
#include <__algorithm/make_heap.h>
@@ -746,6 +747,7 @@
#include <__algorithm/sort_heap.h>
#include <__algorithm/stable_partition.h>
#include <__algorithm/stable_sort.h>
+#include <__algorithm/swap_ranges.h>
#include <__algorithm/transform.h>
#include <__algorithm/unique_copy.h>
#include <__algorithm/unique.h>
diff --git a/include/any b/include/any
index f844800..3a826c4 100644
--- a/include/any
+++ b/include/any
@@ -82,6 +82,7 @@
#include <__availability>
#include <__config>
+#include <__utility/forward.h>
#include <cstdlib>
#include <memory>
#include <type_traits>
diff --git a/include/deque b/include/deque
index 526a1c8..1f23ef0 100644
--- a/include/deque
+++ b/include/deque
@@ -163,6 +163,7 @@
#include <__config>
#include <__debug>
#include <__split_buffer>
+#include <__utility/forward.h>
#include <algorithm>
#include <compare>
#include <initializer_list>
diff --git a/include/exception b/include/exception
index 353ebf7..816f259 100644
--- a/include/exception
+++ b/include/exception
@@ -266,7 +266,7 @@
_LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
__do_throw(_Tp&& __t)
{
- throw __nested<_Up>(_VSTD::forward<_Tp>(__t));
+ throw __nested<_Up>(static_cast<_Tp&&>(__t));
}
};
@@ -279,7 +279,7 @@
__do_throw (_Tp& __t)
#endif // _LIBCPP_CXX03_LANG
{
- throw _VSTD::forward<_Tp>(__t);
+ throw static_cast<_Tp&&>(__t);
}
};
#endif
@@ -296,7 +296,7 @@
is_class<_Up>::value &&
!is_base_of<nested_exception, _Up>::value &&
!__libcpp_is_final<_Up>::value>::
- __do_throw(_VSTD::forward<_Tp>(__t));
+ __do_throw(static_cast<_Tp&&>(__t));
#else
((void)__t);
// FIXME: Make this abort
diff --git a/include/experimental/iterator b/include/experimental/iterator
index 10b0599..09ea2cb 100644
--- a/include/experimental/iterator
+++ b/include/experimental/iterator
@@ -56,6 +56,9 @@
#if _LIBCPP_STD_VER > 11
+#include <__memory/addressof.h>
+#include <__utility/move.h>
+#include <__utility/forward.h>
#include <iterator>
_LIBCPP_BEGIN_NAMESPACE_LFTS
diff --git a/include/filesystem b/include/filesystem
index a652eed..61d6c65 100644
--- a/include/filesystem
+++ b/include/filesystem
@@ -232,6 +232,7 @@
#include <__availability>
#include <__config>
#include <__debug>
+#include <__utility/forward.h>
#include <chrono>
#include <compare>
#include <cstddef>
diff --git a/include/forward_list b/include/forward_list
index 9622d9d..0ae8f19 100644
--- a/include/forward_list
+++ b/include/forward_list
@@ -180,6 +180,7 @@
*/
#include <__config>
+#include <__utility/forward.h>
#include <algorithm>
#include <initializer_list>
#include <iterator>
diff --git a/include/functional b/include/functional
index 68ed22e..249c0dc 100644
--- a/include/functional
+++ b/include/functional
@@ -491,6 +491,7 @@
#include <__debug>
#include <__functional_base>
#include <__functional/search.h>
+#include <__utility/forward.h>
#include <concepts>
#include <exception>
#include <memory>
diff --git a/include/future b/include/future
index d794fae..5d2732b 100644
--- a/include/future
+++ b/include/future
@@ -364,6 +364,8 @@
#include <__availability>
#include <__config>
#include <__debug>
+#include <__utility/__decay_copy.h>
+#include <__utility/forward.h>
#include <chrono>
#include <exception>
#include <memory>
diff --git a/include/istream b/include/istream
index 7f827bb..c83b025 100644
--- a/include/istream
+++ b/include/istream
@@ -159,6 +159,7 @@
*/
#include <__config>
+#include <__utility/forward.h>
#include <ostream>
#include <version>
diff --git a/include/iterator b/include/iterator
index 0b5c4ee..092e589 100644
--- a/include/iterator
+++ b/include/iterator
@@ -570,6 +570,7 @@
#include <__iterator/readable_traits.h>
#include <__memory/addressof.h>
#include <__memory/pointer_traits.h>
+#include <__utility/forward.h>
#include <compare>
#include <concepts> // Mandated by the Standard.
#include <cstddef>
diff --git a/include/list b/include/list
index f598057..23da5fc 100644
--- a/include/list
+++ b/include/list
@@ -182,6 +182,7 @@
#include <__config>
#include <__debug>
+#include <__utility/forward.h>
#include <algorithm>
#include <initializer_list>
#include <iterator>
diff --git a/include/map b/include/map
index c7f7df2..0da590f 100644
--- a/include/map
+++ b/include/map
@@ -493,6 +493,7 @@
#include <__debug>
#include <__node_handle>
#include <__tree>
+#include <__utility/forward.h>
#include <compare>
#include <functional>
#include <initializer_list>
diff --git a/include/module.modulemap b/include/module.modulemap
index dc89843..c5f9f43 100644
--- a/include/module.modulemap
+++ b/include/module.modulemap
@@ -666,9 +666,12 @@
export *
module __utility {
- module to_underlying {
- header "__utility/to_underlying.h"
- }
+ module __decay_copy { header "__utility/__decay_copy.h" }
+ module declval { header "__utility/declval.h" }
+ module forward { header "__utility/forward.h" }
+ module move { header "__utility/move.h" }
+ module swap { header "__utility/swap.h" }
+ module to_underlying { header "__utility/to_underlying.h" }
}
}
module valarray {
diff --git a/include/mutex b/include/mutex
index a23c213..eb8e54a 100644
--- a/include/mutex
+++ b/include/mutex
@@ -189,6 +189,7 @@
#include <__config>
#include <__mutex_base>
#include <__threading_support>
+#include <__utility/forward.h>
#include <cstdint>
#include <functional>
#include <memory>
diff --git a/include/queue b/include/queue
index 9470a75..3c7bbf2 100644
--- a/include/queue
+++ b/include/queue
@@ -179,6 +179,7 @@
*/
#include <__config>
+#include <__utility/forward.h>
#include <algorithm>
#include <compare>
#include <deque>
diff --git a/include/scoped_allocator b/include/scoped_allocator
index d9de95d..dc24d30 100644
--- a/include/scoped_allocator
+++ b/include/scoped_allocator
@@ -106,6 +106,7 @@
*/
#include <__config>
+#include <__utility/forward.h>
#include <memory>
#include <version>
diff --git a/include/set b/include/set
index b9d2895..0da484b 100644
--- a/include/set
+++ b/include/set
@@ -437,6 +437,7 @@
#include <__debug>
#include <__node_handle>
#include <__tree>
+#include <__utility/forward.h>
#include <compare>
#include <functional>
#include <initializer_list>
diff --git a/include/stack b/include/stack
index c1b2cbe..6dd055e 100644
--- a/include/stack
+++ b/include/stack
@@ -88,6 +88,7 @@
*/
#include <__config>
+#include <__utility/forward.h>
#include <deque>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/include/thread b/include/thread
index 09a1f02..acfc20b 100644
--- a/include/thread
+++ b/include/thread
@@ -87,6 +87,8 @@
#include <__functional_base>
#include <__mutex_base>
#include <__threading_support>
+#include <__utility/__decay_copy.h>
+#include <__utility/forward.h>
#include <chrono>
#include <cstddef>
#include <functional>
diff --git a/include/tuple b/include/tuple
index 58f72b1..3a4b0df 100644
--- a/include/tuple
+++ b/include/tuple
@@ -151,6 +151,8 @@
#include <__config>
#include <__functional_base>
+#include <__utility/forward.h>
+#include <__utility/move.h>
#include <__tuple>
#include <compare>
#include <cstddef>
diff --git a/include/type_traits b/include/type_traits
index f257fa3..09b66c7 100644
--- a/include/type_traits
+++ b/include/type_traits
@@ -2818,46 +2818,6 @@
#endif // __has_keyword(__is_destructible)
-// move
-
-template <class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename remove_reference<_Tp>::type&&
-move(_Tp&& __t) _NOEXCEPT
-{
- typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
- return static_cast<_Up&&>(__t);
-}
-
-template <class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-_Tp&&
-forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
-{
- return static_cast<_Tp&&>(__t);
-}
-
-template <class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-_Tp&&
-forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
-{
- static_assert(!is_lvalue_reference<_Tp>::value,
- "cannot forward an rvalue as an lvalue");
- return static_cast<_Tp&&>(__t);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename decay<_Tp>::type
-__decay_copy(_Tp&& __t)
-#if _LIBCPP_STD_VER > 17
-noexcept(is_nothrow_convertible_v<_Tp, remove_reference_t<_Tp>>)
-#endif
-{
- return static_cast<_Tp&&>(__t);
-}
-
template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
struct __member_pointer_traits_imp
{
@@ -4185,10 +4145,11 @@
#endif // _LIBCPP_STD_VER > 14
+// __swappable
+
template <class _Tp> struct __is_swappable;
template <class _Tp> struct __is_nothrow_swappable;
-// swap, swap_ranges
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp>
@@ -4202,49 +4163,14 @@
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 __swap_result_t<_Tp>
swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
- is_nothrow_move_assignable<_Tp>::value)
-{
- _Tp __t(_VSTD::move(__x));
- __x = _VSTD::move(__y);
- __y = _VSTD::move(__t);
-}
+ is_nothrow_move_assignable<_Tp>::value);
template<class _Tp, size_t _Np>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if<
__is_swappable<_Tp>::value
>::type
-swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
-{
- for (size_t __i = 0; __i != _Np; ++__i) {
- swap(__a[__i], __b[__i]);
- }
-}
-
-template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator2
-swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
-{
- for(; __first1 != __last1; ++__first1, (void) ++__first2)
- swap(*__first1, *__first2);
- return __first2;
-}
-
-// iter_swap
-
-template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
- // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
- _NOEXCEPT_(_NOEXCEPT_(swap(*declval<_ForwardIterator1>(),
- *declval<_ForwardIterator2>())))
-{
- swap(*__a, *__b);
-}
-
-// __swappable
+swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
namespace __detail
{
diff --git a/include/unordered_map b/include/unordered_map
index 66fd520..6e58fa9 100644
--- a/include/unordered_map
+++ b/include/unordered_map
@@ -435,6 +435,7 @@
#include <__debug>
#include <__hash_table>
#include <__node_handle>
+#include <__utility/forward.h>
#include <compare>
#include <functional>
#include <iterator> // __libcpp_erase_if_container
diff --git a/include/unordered_set b/include/unordered_set
index f44dcac..0e4901d 100644
--- a/include/unordered_set
+++ b/include/unordered_set
@@ -390,6 +390,7 @@
#include <__debug>
#include <__hash_table>
#include <__node_handle>
+#include <__utility/forward.h>
#include <compare>
#include <functional>
#include <iterator> // __libcpp_erase_if_container
diff --git a/include/utility b/include/utility
index c536a1a..49e7b3e 100644
--- a/include/utility
+++ b/include/utility
@@ -210,6 +210,10 @@
#include <__config>
#include <__debug>
#include <__tuple>
+#include <__utility/declval.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <__utility/to_underlying.h>
#include <compare>
#include <cstddef>
@@ -266,29 +270,6 @@
} // rel_ops
-// swap_ranges is defined in <type_traits>`
-
-// swap is defined in <type_traits>
-
-// move_if_noexcept
-
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Tp>
-using __move_if_noexcept_result_t =
- typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&,
- _Tp&&>::type;
-#else // _LIBCPP_CXX03_LANG
-template <class _Tp>
-using __move_if_noexcept_result_t = const _Tp&;
-#endif
-
-template <class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-__move_if_noexcept_result_t<_Tp> move_if_noexcept(_Tp& __x) _NOEXCEPT
-{
- return _VSTD::move(__x);
-}
-
#if _LIBCPP_STD_VER > 14
template <class _Tp>
_LIBCPP_NODISCARD_EXT constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; }
diff --git a/include/variant b/include/variant
index 5a431c3..2145700 100644
--- a/include/variant
+++ b/include/variant
@@ -201,6 +201,7 @@
#include <__availability>
#include <__config>
+#include <__utility/forward.h>
#include <__tuple>
#include <array>
#include <compare>
diff --git a/include/vector b/include/vector
index 95ef439..bf193e5 100644
--- a/include/vector
+++ b/include/vector
@@ -276,6 +276,7 @@
#include <__debug>
#include <__functional_base>
#include <__split_buffer>
+#include <__utility/forward.h>
#include <algorithm>
#include <climits>
#include <compare>
diff --git a/test/std/utilities/utility/forward/forward.fail.cpp b/test/std/utilities/utility/forward/forward.fail.cpp
index 90287dc..4d7790a 100644
--- a/test/std/utilities/utility/forward/forward.fail.cpp
+++ b/test/std/utilities/utility/forward/forward.fail.cpp
@@ -23,7 +23,7 @@
{
{
std::forward<A&>(source()); // expected-note {{requested here}}
- // expected-error-re@type_traits:* 1 {{static_assert failed{{.*}} "cannot forward an rvalue as an lvalue"}}
+ // expected-error-re@*:* 1 {{static_assert failed{{.*}} "cannot forward an rvalue as an lvalue"}}
}
{
const A ca = A();
diff --git a/test/std/utilities/utility/utility.swap/swap.pass.cpp b/test/std/utilities/utility/utility.swap/swap.pass.cpp
index c9146ee..3c9439b 100644
--- a/test/std/utilities/utility/utility.swap/swap.pass.cpp
+++ b/test/std/utilities/utility/utility.swap/swap.pass.cpp
@@ -13,9 +13,10 @@
// void
// swap(T& a, T& b);
-#include <utility>
#include <cassert>
#include <memory>
+#include <type_traits>
+#include <utility>
#include "test_macros.h"
diff --git a/test/std/utilities/utility/utility.swap/swap_array.pass.cpp b/test/std/utilities/utility/utility.swap/swap_array.pass.cpp
index 512505b..3d562dd 100644
--- a/test/std/utilities/utility/utility.swap/swap_array.pass.cpp
+++ b/test/std/utilities/utility/utility.swap/swap_array.pass.cpp
@@ -13,9 +13,11 @@
// void
// swap(T (&a)[N], T (&b)[N]);
-#include <utility>
+#include <algorithm>
#include <cassert>
#include <memory>
+#include <type_traits>
+#include <utility>
#include "test_macros.h"
diff --git a/test/support/poisoned_hash_helper.h b/test/support/poisoned_hash_helper.h
index 60ce6f9..a1f5f79 100644
--- a/test/support/poisoned_hash_helper.h
+++ b/test/support/poisoned_hash_helper.h
@@ -9,8 +9,9 @@
#ifndef SUPPORT_POISONED_HASH_HELPER_H
#define SUPPORT_POISONED_HASH_HELPER_H
-#include <type_traits>
+#include <__utility/move.h> // TODO: replace with <utility> when std::hash is moved out of the header
#include <cassert>
+#include <type_traits>
#include "test_macros.h"
#include "test_workarounds.h"