Debian Codegraph @

libcxx/include/__cxx03/__memory/swap_allocator.h

raw
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___MEMORY_SWAP_ALLOCATOR_H
10 #define _LIBCPP___CXX03___MEMORY_SWAP_ALLOCATOR_H
11
12 #include <__cxx03/__config>
13 #include <__cxx03/__memory/allocator_traits.h>
14 #include <__cxx03/__type_traits/integral_constant.h>
15 #include <__cxx03/__type_traits/is_swappable.h>
16 #include <__cxx03/__utility/swap.h>
17
18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 # pragma GCC system_header
20 #endif
21
22 _LIBCPP_BEGIN_NAMESPACE_STD
23
24 template <typename _Alloc>
25 _LIBCPP_HIDE_FROM_ABI void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type) {
26 using std::swap;
27 swap(__a1, __a2);
28 }
29
30 template <typename _Alloc>
31 inline _LIBCPP_HIDE_FROM_ABI void __swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {}
32
33 template <typename _Alloc>
34 inline _LIBCPP_HIDE_FROM_ABI void __swap_allocator(_Alloc& __a1, _Alloc& __a2) {
35 std::__swap_allocator(
36 __a1, __a2, integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>());
37 }
38
39 _LIBCPP_END_NAMESPACE_STD
40
41 #endif // _LIBCPP___CXX03___MEMORY_SWAP_ALLOCATOR_H