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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef PB_DS_TYPE_UTILS_HPP
00049 #define PB_DS_TYPE_UTILS_HPP
00050
00051 #include <cstddef>
00052 #include <utility>
00053 #include <tr1/type_traits>
00054 #include <ext/type_traits.h>
00055 #include <ext/numeric_traits.h>
00056
00057 namespace __gnu_pbds
00058 {
00059 namespace detail
00060 {
00061 using std::tr1::is_same;
00062 using std::tr1::is_const;
00063 using std::tr1::is_pointer;
00064 using std::tr1::is_reference;
00065 using std::tr1::is_fundamental;
00066 using std::tr1::is_member_object_pointer;
00067 using std::tr1::is_member_pointer;
00068 using std::tr1::is_base_of;
00069 using std::tr1::remove_const;
00070 using std::tr1::remove_reference;
00071
00072
00073
00074
00075 using std::tr1::integral_constant;
00076 typedef std::tr1::integral_constant<int, 1> true_type;
00077 typedef std::tr1::integral_constant<int, 0> false_type;
00078
00079 using __gnu_cxx::__conditional_type;
00080 using __gnu_cxx::__numeric_traits;
00081
00082 template<typename T>
00083 struct is_const_pointer
00084 {
00085 enum
00086 {
00087 value = is_const<T>::value && is_pointer<T>::value
00088 };
00089 };
00090
00091 template<typename T>
00092 struct is_const_reference
00093 {
00094 enum
00095 {
00096 value = is_const<T>::value && is_reference<T>::value
00097 };
00098 };
00099
00100 template<typename T>
00101 struct is_simple
00102 {
00103 enum
00104 {
00105 value = is_fundamental<typename remove_const<T>::type>::value
00106 || is_pointer<typename remove_const<T>::type>::value
00107 || is_member_pointer<T>::value
00108 };
00109 };
00110
00111 template<typename T>
00112 class is_pair
00113 {
00114 private:
00115 template<typename U>
00116 struct is_pair_imp
00117 {
00118 enum
00119 {
00120 value = 0
00121 };
00122 };
00123
00124 template<typename U, typename V>
00125 struct is_pair_imp<std::pair<U,V> >
00126 {
00127 enum
00128 {
00129 value = 1
00130 };
00131 };
00132
00133 public:
00134 enum
00135 {
00136 value = is_pair_imp<T>::value
00137 };
00138 };
00139
00140
00141 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00142 #define PB_DS_STATIC_ASSERT(UNIQUE, E) static_assert(E, #UNIQUE)
00143 #else
00144 template<bool>
00145 struct __static_assert;
00146
00147 template<>
00148 struct __static_assert<true>
00149 { };
00150
00151 template<int>
00152 struct __static_assert_dumclass
00153 {
00154 enum
00155 {
00156 v = 1
00157 };
00158 };
00159
00160 #define PB_DS_STATIC_ASSERT(UNIQUE, E) \
00161 typedef __gnu_pbds::detail::__static_assert_dumclass<sizeof(__gnu_pbds::detail::__static_assert<bool(E)>)> UNIQUE##__static_assert_type
00162
00163 #endif
00164
00165 template<typename Type>
00166 struct type_to_type
00167 {
00168 typedef Type type;
00169 };
00170 }
00171 }
00172
00173 #endif