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___MEMORY_SWAP_ALLOCATOR_H
10 #define _LIBCPP___MEMORY_SWAP_ALLOCATOR_H
11
12 #include <__config>
13 #include <__memory/allocator_traits.h>
14 #include <__type_traits/integral_constant.h>
15 #include <__utility/swap.h>
16
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 # pragma GCC system_header
19 #endif
20
21 _LIBCPP_BEGIN_NAMESPACE_STD
22
23 template <typename _Alloc>
__swap_allocator(_Alloc & __a1,_Alloc & __a2,true_type)24 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type)
25 #if _LIBCPP_STD_VER > 11
26 _NOEXCEPT
27 #else
28 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
29 #endif
30 {
31 using _VSTD::swap;
32 swap(__a1, __a2);
33 }
34
35 template <typename _Alloc>
36 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void
__swap_allocator(_Alloc &,_Alloc &,false_type)37 __swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {}
38
39 template <typename _Alloc>
__swap_allocator(_Alloc & __a1,_Alloc & __a2)40 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2)
41 #if _LIBCPP_STD_VER > 11
42 _NOEXCEPT
43 #else
44 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
45 #endif
46 {
47 _VSTD::__swap_allocator(
48 __a1, __a2, integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>());
49 }
50
51 _LIBCPP_END_NAMESPACE_STD
52
53 #endif // _LIBCPP___MEMORY_SWAP_ALLOCATOR_H
54