1972a253aSDimitry Andric //===----------------------------------------------------------------------===// 2972a253aSDimitry Andric // 3972a253aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4972a253aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5972a253aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6972a253aSDimitry Andric // 7972a253aSDimitry Andric //===----------------------------------------------------------------------===// 8972a253aSDimitry Andric 9972a253aSDimitry Andric #ifndef _LIBCPP___MEMORY_SWAP_ALLOCATOR_H 10972a253aSDimitry Andric #define _LIBCPP___MEMORY_SWAP_ALLOCATOR_H 11972a253aSDimitry Andric 12972a253aSDimitry Andric #include <__config> 13972a253aSDimitry Andric #include <__memory/allocator_traits.h> 14972a253aSDimitry Andric #include <__type_traits/integral_constant.h> 15bdd1243dSDimitry Andric #include <__type_traits/is_swappable.h> 16972a253aSDimitry Andric #include <__utility/swap.h> 17972a253aSDimitry Andric 18972a253aSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 19972a253aSDimitry Andric # pragma GCC system_header 20972a253aSDimitry Andric #endif 21972a253aSDimitry Andric 22972a253aSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 23972a253aSDimitry Andric 24972a253aSDimitry Andric template <typename _Alloc> 25bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type) 2606c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14 27972a253aSDimitry Andric _NOEXCEPT 28972a253aSDimitry Andric #else 29*0fca6ea1SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>) 30972a253aSDimitry Andric #endif 31972a253aSDimitry Andric { 325f757f3fSDimitry Andric using std::swap; 33972a253aSDimitry Andric swap(__a1, __a2); 34972a253aSDimitry Andric } 35972a253aSDimitry Andric 36972a253aSDimitry Andric template <typename _Alloc> 37bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void 38972a253aSDimitry Andric __swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {} 39972a253aSDimitry Andric 40972a253aSDimitry Andric template <typename _Alloc> 41bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc& __a1, _Alloc& __a2) 4206c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14 43972a253aSDimitry Andric _NOEXCEPT 44972a253aSDimitry Andric #else 45*0fca6ea1SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>) 46972a253aSDimitry Andric #endif 47972a253aSDimitry Andric { 485f757f3fSDimitry Andric std::__swap_allocator( 49972a253aSDimitry Andric __a1, __a2, integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>()); 50972a253aSDimitry Andric } 51972a253aSDimitry Andric 52972a253aSDimitry Andric _LIBCPP_END_NAMESPACE_STD 53972a253aSDimitry Andric 54972a253aSDimitry Andric #endif // _LIBCPP___MEMORY_SWAP_ALLOCATOR_H 55