move.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _MOVE_H
00031 #define _MOVE_H 1
00032
00033 #include <bits/c++config.h>
00034 #include <cstddef>
00035 #include <bits/concept_check.h>
00036
00037 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00038 #include <type_traits>
00039
00040 _GLIBCXX_BEGIN_NAMESPACE(std)
00041
00042
00043 template<typename _Tp>
00044 struct identity
00045 {
00046 typedef _Tp type;
00047 };
00048
00049 template<typename _Tp>
00050 inline _Tp&&
00051 forward(typename std::identity<_Tp>::type&& __t)
00052 { return __t; }
00053
00054 template<typename _Tp>
00055 inline typename std::remove_reference<_Tp>::type&&
00056 move(_Tp&& __t)
00057 { return __t; }
00058
00059 _GLIBCXX_END_NAMESPACE
00060
00061 #define _GLIBCXX_MOVE(_Tp) std::move(_Tp)
00062 #else
00063 #define _GLIBCXX_MOVE(_Tp) (_Tp)
00064 #endif
00065
00066 _GLIBCXX_BEGIN_NAMESPACE(std)
00067
00068
00069
00070
00071
00072
00073
00074 template<typename _Tp>
00075 inline void
00076 swap(_Tp& __a, _Tp& __b)
00077 {
00078
00079 __glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
00080
00081 _Tp __tmp = _GLIBCXX_MOVE(__a);
00082 __a = _GLIBCXX_MOVE(__b);
00083 __b = _GLIBCXX_MOVE(__tmp);
00084 }
00085
00086
00087
00088 template<typename _Tp, size_t _Nm>
00089 inline void
00090 swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
00091 {
00092 for (size_t __n = 0; __n < _Nm; ++__n)
00093 swap(__a[__n], __b[__n]);
00094 }
00095
00096 _GLIBCXX_END_NAMESPACE
00097
00098 #endif