Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:14:06

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___UTILITY_EXCHANGE_H
0010 #define _LIBCPP___UTILITY_EXCHANGE_H
0011 
0012 #include <__config>
0013 #include <__type_traits/is_nothrow_assignable.h>
0014 #include <__type_traits/is_nothrow_constructible.h>
0015 #include <__utility/forward.h>
0016 #include <__utility/move.h>
0017 
0018 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0019 #  pragma GCC system_header
0020 #endif
0021 
0022 _LIBCPP_PUSH_MACROS
0023 #include <__undef_macros>
0024 
0025 _LIBCPP_BEGIN_NAMESPACE_STD
0026 
0027 #if _LIBCPP_STD_VER >= 14
0028 template <class _T1, class _T2 = _T1>
0029 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _T1 exchange(_T1& __obj, _T2&& __new_value) noexcept(
0030     is_nothrow_move_constructible<_T1>::value && is_nothrow_assignable<_T1&, _T2>::value) {
0031   _T1 __old_value = std::move(__obj);
0032   __obj           = std::forward<_T2>(__new_value);
0033   return __old_value;
0034 }
0035 #endif // _LIBCPP_STD_VER >= 14
0036 
0037 _LIBCPP_END_NAMESPACE_STD
0038 
0039 _LIBCPP_POP_MACROS
0040 
0041 #endif // _LIBCPP___UTILITY_EXCHANGE_H