Warning: This file is not a C or C++ file. It does not have highlighting.
1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef _LIBCPP___CXX03___UTILITY_SWAP_H |
10 | #define _LIBCPP___CXX03___UTILITY_SWAP_H |
11 | |
12 | #include <__cxx03/__config> |
13 | #include <__cxx03/__type_traits/is_assignable.h> |
14 | #include <__cxx03/__type_traits/is_constructible.h> |
15 | #include <__cxx03/__type_traits/is_nothrow_assignable.h> |
16 | #include <__cxx03/__type_traits/is_nothrow_constructible.h> |
17 | #include <__cxx03/__type_traits/is_swappable.h> |
18 | #include <__cxx03/__utility/declval.h> |
19 | #include <__cxx03/__utility/move.h> |
20 | #include <__cxx03/cstddef> |
21 | |
22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
23 | # pragma GCC system_header |
24 | #endif |
25 | |
26 | _LIBCPP_PUSH_MACROS |
27 | #include <__cxx03/__undef_macros> |
28 | |
29 | _LIBCPP_BEGIN_NAMESPACE_STD |
30 | |
31 | template <class> |
32 | using __swap_result_t = void; |
33 | |
34 | template <class _Tp> |
35 | inline _LIBCPP_HIDE_FROM_ABI __swap_result_t<_Tp> swap(_Tp& __x, _Tp& __y) { |
36 | _Tp __t(std::move(__x)); |
37 | __x = std::move(__y); |
38 | __y = std::move(__t); |
39 | } |
40 | |
41 | template <class _Tp, size_t _Np, __enable_if_t<__is_swappable_v<_Tp>, int> > |
42 | inline _LIBCPP_HIDE_FROM_ABI void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) { |
43 | for (size_t __i = 0; __i != _Np; ++__i) { |
44 | swap(__a[__i], __b[__i]); |
45 | } |
46 | } |
47 | |
48 | _LIBCPP_END_NAMESPACE_STD |
49 | |
50 | _LIBCPP_POP_MACROS |
51 | |
52 | #endif // _LIBCPP___CXX03___UTILITY_SWAP_H |
53 |
Warning: This file is not a C or C++ file. It does not have highlighting.