File indexing completed on 2025-12-15 09:45:41
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_CORE_EXCHANGE_HPP
0009 #define BOOST_CORE_EXCHANGE_HPP
0010
0011 #include <boost/config.hpp>
0012 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0013 #include <boost/config/workaround.hpp>
0014 #include <utility>
0015 #endif
0016
0017 namespace boost {
0018
0019 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0020 template<class T, class U>
0021 inline T exchange(T& t, const U& u)
0022 {
0023 T v = t;
0024 t = u;
0025 return v;
0026 }
0027 #else
0028 #if BOOST_WORKAROUND(BOOST_MSVC, < 1800)
0029 template<class T, class U>
0030 inline T exchange(T& t, U&& u)
0031 {
0032 T v = std::move(t);
0033 t = std::forward<U>(u);
0034 return v;
0035 }
0036 #else
0037 template<class T, class U = T>
0038 BOOST_CXX14_CONSTEXPR inline T exchange(T& t, U&& u)
0039 {
0040 T v = std::move(t);
0041 t = std::forward<U>(u);
0042 return v;
0043 }
0044 #endif
0045 #endif
0046
0047 }
0048
0049 #endif