tr1_impl/utility
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 namespace std
00031 {
00032 _GLIBCXX_BEGIN_NAMESPACE_TR1
00033
00034 template<class _Tp>
00035 class tuple_size;
00036
00037 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00038 template<std::size_t _Int, class _Tp>
00039 #else
00040 template<int _Int, class _Tp>
00041 #endif
00042 class tuple_element;
00043
00044
00045 template<class _Tp1, class _Tp2>
00046 struct tuple_size<std::pair<_Tp1, _Tp2> >
00047 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00048 { static const std::size_t value = 2; };
00049 #else
00050 { static const int value = 2; };
00051 #endif
00052
00053 template<class _Tp1, class _Tp2>
00054 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00055 const std::size_t
00056 #else
00057 const int
00058 #endif
00059 tuple_size<std::pair<_Tp1, _Tp2> >::value;
00060
00061 template<class _Tp1, class _Tp2>
00062 struct tuple_element<0, std::pair<_Tp1, _Tp2> >
00063 { typedef _Tp1 type; };
00064
00065 template<class _Tp1, class _Tp2>
00066 struct tuple_element<1, std::pair<_Tp1, _Tp2> >
00067 { typedef _Tp2 type; };
00068
00069 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00070 template<std::size_t _Int>
00071 #else
00072 template<int _Int>
00073 #endif
00074 struct __pair_get;
00075
00076 template<>
00077 struct __pair_get<0>
00078 {
00079 template<typename _Tp1, typename _Tp2>
00080 static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair)
00081 { return __pair.first; }
00082
00083 template<typename _Tp1, typename _Tp2>
00084 static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
00085 { return __pair.first; }
00086 };
00087
00088 template<>
00089 struct __pair_get<1>
00090 {
00091 template<typename _Tp1, typename _Tp2>
00092 static _Tp2& __get(std::pair<_Tp1, _Tp2>& __pair)
00093 { return __pair.second; }
00094
00095 template<typename _Tp1, typename _Tp2>
00096 static const _Tp2& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
00097 { return __pair.second; }
00098 };
00099
00100 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00101 template<std::size_t _Int, class _Tp1, class _Tp2>
00102 #else
00103 template<int _Int, class _Tp1, class _Tp2>
00104 #endif
00105 inline typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
00106 get(std::pair<_Tp1, _Tp2>& __in)
00107 { return __pair_get<_Int>::__get(__in); }
00108
00109 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00110 template<std::size_t _Int, class _Tp1, class _Tp2>
00111 #else
00112 template<int _Int, class _Tp1, class _Tp2>
00113 #endif
00114 inline const typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
00115 get(const std::pair<_Tp1, _Tp2>& __in)
00116 { return __pair_get<_Int>::__const_get(__in); }
00117
00118 _GLIBCXX_END_NAMESPACE_TR1
00119 }
00120