libstdc++
|
00001 // Default predicates for internal use -*- C++ -*- 00002 00003 // Copyright (C) 2013-2015 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file predefined_ops.h 00026 * This is an internal header file, included by other library headers. 00027 * You should not attempt to use it directly. 00028 */ 00029 00030 #ifndef _GLIBCXX_PREDEFINED_OPS_H 00031 #define _GLIBCXX_PREDEFINED_OPS_H 1 00032 00033 namespace __gnu_cxx 00034 { 00035 namespace __ops 00036 { 00037 struct _Iter_less_iter 00038 { 00039 template<typename _Iterator1, typename _Iterator2> 00040 _GLIBCXX14_CONSTEXPR 00041 bool 00042 operator()(_Iterator1 __it1, _Iterator2 __it2) const 00043 { return *__it1 < *__it2; } 00044 }; 00045 _GLIBCXX14_CONSTEXPR 00046 inline _Iter_less_iter 00047 __iter_less_iter() 00048 { return _Iter_less_iter(); } 00049 00050 struct _Iter_less_val 00051 { 00052 template<typename _Iterator, typename _Value> 00053 bool 00054 operator()(_Iterator __it, _Value& __val) const 00055 { return *__it < __val; } 00056 }; 00057 00058 inline _Iter_less_val 00059 __iter_less_val() 00060 { return _Iter_less_val(); } 00061 00062 inline _Iter_less_val 00063 __iter_comp_val(_Iter_less_iter) 00064 { return _Iter_less_val(); } 00065 00066 struct _Val_less_iter 00067 { 00068 template<typename _Value, typename _Iterator> 00069 bool 00070 operator()(_Value& __val, _Iterator __it) const 00071 { return __val < *__it; } 00072 }; 00073 00074 inline _Val_less_iter 00075 __val_less_iter() 00076 { return _Val_less_iter(); } 00077 00078 inline _Val_less_iter 00079 __val_comp_iter(_Iter_less_iter) 00080 { return _Val_less_iter(); } 00081 00082 struct _Iter_equal_to_iter 00083 { 00084 template<typename _Iterator1, typename _Iterator2> 00085 bool 00086 operator()(_Iterator1 __it1, _Iterator2 __it2) const 00087 { return *__it1 == *__it2; } 00088 }; 00089 00090 inline _Iter_equal_to_iter 00091 __iter_equal_to_iter() 00092 { return _Iter_equal_to_iter(); } 00093 00094 struct _Iter_equal_to_val 00095 { 00096 template<typename _Iterator, typename _Value> 00097 bool 00098 operator()(_Iterator __it, _Value& __val) const 00099 { return *__it == __val; } 00100 }; 00101 00102 inline _Iter_equal_to_val 00103 __iter_equal_to_val() 00104 { return _Iter_equal_to_val(); } 00105 00106 inline _Iter_equal_to_val 00107 __iter_comp_val(_Iter_equal_to_iter) 00108 { return _Iter_equal_to_val(); } 00109 00110 template<typename _Compare> 00111 struct _Iter_comp_iter 00112 { 00113 _Compare _M_comp; 00114 _GLIBCXX14_CONSTEXPR 00115 _Iter_comp_iter(_Compare __comp) 00116 : _M_comp(__comp) 00117 { } 00118 00119 template<typename _Iterator1, typename _Iterator2> 00120 _GLIBCXX14_CONSTEXPR 00121 bool 00122 operator()(_Iterator1 __it1, _Iterator2 __it2) 00123 { return bool(_M_comp(*__it1, *__it2)); } 00124 }; 00125 00126 template<typename _Compare> 00127 _GLIBCXX14_CONSTEXPR 00128 inline _Iter_comp_iter<_Compare> 00129 __iter_comp_iter(_Compare __comp) 00130 { return _Iter_comp_iter<_Compare>(__comp); } 00131 00132 template<typename _Compare> 00133 struct _Iter_comp_val 00134 { 00135 _Compare _M_comp; 00136 00137 _Iter_comp_val(_Compare __comp) 00138 : _M_comp(__comp) 00139 { } 00140 00141 template<typename _Iterator, typename _Value> 00142 bool 00143 operator()(_Iterator __it, _Value& __val) 00144 { return bool(_M_comp(*__it, __val)); } 00145 }; 00146 00147 template<typename _Compare> 00148 inline _Iter_comp_val<_Compare> 00149 __iter_comp_val(_Compare __comp) 00150 { return _Iter_comp_val<_Compare>(__comp); } 00151 00152 template<typename _Compare> 00153 inline _Iter_comp_val<_Compare> 00154 __iter_comp_val(_Iter_comp_iter<_Compare> __comp) 00155 { return _Iter_comp_val<_Compare>(__comp._M_comp); } 00156 00157 template<typename _Compare> 00158 struct _Val_comp_iter 00159 { 00160 _Compare _M_comp; 00161 00162 _Val_comp_iter(_Compare __comp) 00163 : _M_comp(__comp) 00164 { } 00165 00166 template<typename _Value, typename _Iterator> 00167 bool 00168 operator()(_Value& __val, _Iterator __it) 00169 { return bool(_M_comp(__val, *__it)); } 00170 }; 00171 00172 template<typename _Compare> 00173 inline _Val_comp_iter<_Compare> 00174 __val_comp_iter(_Compare __comp) 00175 { return _Val_comp_iter<_Compare>(__comp); } 00176 00177 template<typename _Compare> 00178 inline _Val_comp_iter<_Compare> 00179 __val_comp_iter(_Iter_comp_iter<_Compare> __comp) 00180 { return _Val_comp_iter<_Compare>(__comp._M_comp); } 00181 00182 template<typename _Value> 00183 struct _Iter_equals_val 00184 { 00185 _Value& _M_value; 00186 00187 _Iter_equals_val(_Value& __value) 00188 : _M_value(__value) 00189 { } 00190 00191 template<typename _Iterator> 00192 bool 00193 operator()(_Iterator __it) 00194 { return *__it == _M_value; } 00195 }; 00196 00197 template<typename _Value> 00198 inline _Iter_equals_val<_Value> 00199 __iter_equals_val(_Value& __val) 00200 { return _Iter_equals_val<_Value>(__val); } 00201 00202 template<typename _Iterator1> 00203 struct _Iter_equals_iter 00204 { 00205 typename std::iterator_traits<_Iterator1>::reference _M_ref; 00206 00207 _Iter_equals_iter(_Iterator1 __it1) 00208 : _M_ref(*__it1) 00209 { } 00210 00211 template<typename _Iterator2> 00212 bool 00213 operator()(_Iterator2 __it2) 00214 { return *__it2 == _M_ref; } 00215 }; 00216 00217 template<typename _Iterator> 00218 inline _Iter_equals_iter<_Iterator> 00219 __iter_comp_iter(_Iter_equal_to_iter, _Iterator __it) 00220 { return _Iter_equals_iter<_Iterator>(__it); } 00221 00222 template<typename _Predicate> 00223 struct _Iter_pred 00224 { 00225 _Predicate _M_pred; 00226 00227 _Iter_pred(_Predicate __pred) 00228 : _M_pred(__pred) 00229 { } 00230 00231 template<typename _Iterator> 00232 bool 00233 operator()(_Iterator __it) 00234 { return bool(_M_pred(*__it)); } 00235 }; 00236 00237 template<typename _Predicate> 00238 inline _Iter_pred<_Predicate> 00239 __pred_iter(_Predicate __pred) 00240 { return _Iter_pred<_Predicate>(__pred); } 00241 00242 template<typename _Compare, typename _Value> 00243 struct _Iter_comp_to_val 00244 { 00245 _Compare _M_comp; 00246 _Value& _M_value; 00247 00248 _Iter_comp_to_val(_Compare __comp, _Value& __value) 00249 : _M_comp(__comp), _M_value(__value) 00250 { } 00251 00252 template<typename _Iterator> 00253 bool 00254 operator()(_Iterator __it) 00255 { return bool(_M_comp(*__it, _M_value)); } 00256 }; 00257 00258 template<typename _Compare, typename _Value> 00259 _Iter_comp_to_val<_Compare, _Value> 00260 __iter_comp_val(_Compare __comp, _Value &__val) 00261 { return _Iter_comp_to_val<_Compare, _Value>(__comp, __val); } 00262 00263 template<typename _Compare, typename _Iterator1> 00264 struct _Iter_comp_to_iter 00265 { 00266 _Compare _M_comp; 00267 typename std::iterator_traits<_Iterator1>::reference _M_ref; 00268 00269 _Iter_comp_to_iter(_Compare __comp, _Iterator1 __it1) 00270 : _M_comp(__comp), _M_ref(*__it1) 00271 { } 00272 00273 template<typename _Iterator2> 00274 bool 00275 operator()(_Iterator2 __it2) 00276 { return bool(_M_comp(*__it2, _M_ref)); } 00277 }; 00278 00279 template<typename _Compare, typename _Iterator> 00280 inline _Iter_comp_to_iter<_Compare, _Iterator> 00281 __iter_comp_iter(_Iter_comp_iter<_Compare> __comp, _Iterator __it) 00282 { return _Iter_comp_to_iter<_Compare, _Iterator>(__comp._M_comp, __it); } 00283 00284 template<typename _Predicate> 00285 struct _Iter_negate 00286 { 00287 _Predicate _M_pred; 00288 00289 _Iter_negate(_Predicate __pred) 00290 : _M_pred(__pred) 00291 { } 00292 00293 template<typename _Iterator> 00294 bool 00295 operator()(_Iterator __it) 00296 { return !bool(_M_pred(*__it)); } 00297 }; 00298 00299 template<typename _Predicate> 00300 inline _Iter_negate<_Predicate> 00301 __negate(_Iter_pred<_Predicate> __pred) 00302 { return _Iter_negate<_Predicate>(__pred._M_pred); } 00303 00304 } // namespace __ops 00305 } // namespace __gnu_cxx 00306 00307 #endif