brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · df29e1e Raw
53 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___CXX03___UTILITY_SWAP_H10#define _LIBCPP___CXX03___UTILITY_SWAP_H11 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_header24#endif25 26_LIBCPP_PUSH_MACROS27#include <__cxx03/__undef_macros>28 29_LIBCPP_BEGIN_NAMESPACE_STD30 31template <class>32using __swap_result_t = void;33 34template <class _Tp>35inline _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 41template <class _Tp, size_t _Np, __enable_if_t<__is_swappable_v<_Tp>, int> >42inline _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_STD49 50_LIBCPP_POP_MACROS51 52#endif // _LIBCPP___CXX03___UTILITY_SWAP_H53