123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- #ifndef _MOVE_H
- #define _MOVE_H 1
- #include <bits/c++config.h>
- #include <bits/concept_check.h>
- namespace std _GLIBCXX_VISIBILITY(default)
- {
- _GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-
- template<typename _Tp>
- inline _Tp*
- __addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
- {
- return reinterpret_cast<_Tp*>
- (&const_cast<char&>(reinterpret_cast<const volatile char&>(__r)));
- }
- _GLIBCXX_END_NAMESPACE_VERSION
- }
- #if __cplusplus >= 201103L
- #include <type_traits> // Brings in std::declval too.
- namespace std _GLIBCXX_VISIBILITY(default)
- {
- _GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-
- template<typename _Tp>
- constexpr _Tp&&
- forward(typename std::remove_reference<_Tp>::type& __t) noexcept
- { return static_cast<_Tp&&>(__t); }
-
- template<typename _Tp>
- constexpr _Tp&&
- forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
- {
- static_assert(!std::is_lvalue_reference<_Tp>::value, "template argument"
- " substituting _Tp is an lvalue reference type");
- return static_cast<_Tp&&>(__t);
- }
-
- template<typename _Tp>
- constexpr typename std::remove_reference<_Tp>::type&&
- move(_Tp&& __t) noexcept
- { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
- template<typename _Tp>
- struct __move_if_noexcept_cond
- : public __and_<__not_<is_nothrow_move_constructible<_Tp>>,
- is_copy_constructible<_Tp>>::type { };
-
- template<typename _Tp>
- constexpr typename
- conditional<__move_if_noexcept_cond<_Tp>::value, const _Tp&, _Tp&&>::type
- move_if_noexcept(_Tp& __x) noexcept
- { return std::move(__x); }
-
-
- template<typename _Tp>
- inline _Tp*
- addressof(_Tp& __r) noexcept
- { return std::__addressof(__r); }
-
- template <typename _Tp, typename _Up = _Tp>
- inline _Tp
- __exchange(_Tp& __obj, _Up&& __new_val)
- {
- _Tp __old_val = std::move(__obj);
- __obj = std::forward<_Up>(__new_val);
- return __old_val;
- }
-
- _GLIBCXX_END_NAMESPACE_VERSION
- }
- #define _GLIBCXX_MOVE(__val) std::move(__val)
- #define _GLIBCXX_FORWARD(_Tp, __val) std::forward<_Tp>(__val)
- #else
- #define _GLIBCXX_MOVE(__val) (__val)
- #define _GLIBCXX_FORWARD(_Tp, __val) (__val)
- #endif
- namespace std _GLIBCXX_VISIBILITY(default)
- {
- _GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-
- template<typename _Tp>
- inline void
- swap(_Tp& __a, _Tp& __b)
- #if __cplusplus >= 201103L
- noexcept(__and_<is_nothrow_move_constructible<_Tp>,
- is_nothrow_move_assignable<_Tp>>::value)
- #endif
- {
-
- __glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
- _Tp __tmp = _GLIBCXX_MOVE(__a);
- __a = _GLIBCXX_MOVE(__b);
- __b = _GLIBCXX_MOVE(__tmp);
- }
-
-
-
- template<typename _Tp, size_t _Nm>
- inline void
- swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
- #if __cplusplus >= 201103L
- noexcept(noexcept(swap(*__a, *__b)))
- #endif
- {
- for (size_t __n = 0; __n < _Nm; ++__n)
- swap(__a[__n], __b[__n]);
- }
-
- _GLIBCXX_END_NAMESPACE_VERSION
- }
- #endif
|