57 #ifndef _EXT_FUNCTIONAL
58 #define _EXT_FUNCTIONAL 1
60 #pragma GCC system_header
65 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
68 using std::unary_function;
69 using std::binary_function;
70 using std::mem_fun1_t;
71 using std::const_mem_fun1_t;
72 using std::mem_fun1_ref_t;
73 using std::const_mem_fun1_ref_t;
87 identity_element(std::plus<_Tp>)
124 template <
class _Operation1,
class _Operation2>
127 typename _Operation1::result_type>
134 unary_compose(
const _Operation1& __x,
const _Operation2& __y)
135 : _M_fn1(__x), _M_fn2(__y) {}
137 typename _Operation1::result_type
138 operator()(
const typename _Operation2::argument_type& __x)
const
139 {
return _M_fn1(_M_fn2(__x)); }
143 template <
class _Operation1,
class _Operation2>
145 compose1(
const _Operation1& __fn1,
const _Operation2& __fn2)
149 template <
class _Operation1,
class _Operation2,
class _Operation3>
152 typename _Operation1::result_type>
161 const _Operation3& __z)
162 : _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { }
164 typename _Operation1::result_type
165 operator()(
const typename _Operation2::argument_type& __x)
const
166 {
return _M_fn1(_M_fn2(__x), _M_fn3(__x)); }
170 template <
class _Operation1,
class _Operation2,
class _Operation3>
172 compose2(
const _Operation1& __fn1,
const _Operation2& __fn2,
173 const _Operation3& __fn3)
175 (__fn1, __fn2, __fn3); }
185 struct identity :
public std::_Identity<_Tp> {};
198 template <
class _Pair>
202 template <
class _Pair>
207 template <
class _Arg1,
class _Arg2>
211 operator()(
const _Arg1& __x,
const _Arg2&)
const
215 template <
class _Arg1,
class _Arg2>
216 struct _Project2nd :
public binary_function<_Arg1, _Arg2, _Arg2>
219 operator()(
const _Arg1&,
const _Arg2& __y)
const
232 template <
class _Arg1,
class _Arg2>
236 template <
class _Arg1,
class _Arg2>
241 template <
class _Result>
242 struct _Constant_void_fun
244 typedef _Result result_type;
247 _Constant_void_fun(
const result_type& __v) : _M_val(__v) {}
254 template <
class _Result,
class _Argument>
255 struct _Constant_unary_fun
257 typedef _Argument argument_type;
258 typedef _Result result_type;
261 _Constant_unary_fun(
const result_type& __v) : _M_val(__v) {}
264 operator()(
const _Argument&)
const
268 template <
class _Result,
class _Arg1,
class _Arg2>
269 struct _Constant_binary_fun
271 typedef _Arg1 first_argument_type;
272 typedef _Arg2 second_argument_type;
273 typedef _Result result_type;
276 _Constant_binary_fun(
const _Result& __v) : _M_val(__v) {}
279 operator()(
const _Arg1&,
const _Arg2&)
const
298 template <
class _Result>
300 :
public _Constant_void_fun<_Result>
303 : _Constant_void_fun<_Result>(__v) {}
307 template <
class _Result,
class _Argument = _Result>
311 : _Constant_unary_fun<_Result, _Argument>(__v) {}
315 template <
class _Result,
class _Arg1 = _Result,
class _Arg2 = _Arg1>
317 :
public _Constant_binary_fun<_Result, _Arg1, _Arg2>
320 : _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {}
324 template <
class _Result>
330 template <
class _Result>
331 inline constant_unary_fun<_Result, _Result>
336 template <
class _Result>
337 inline constant_binary_fun<_Result,_Result,_Result>
352 unsigned int _M_table[55];
359 operator()(
unsigned int __limit)
361 _M_index1 = (_M_index1 + 1) % 55;
362 _M_index2 = (_M_index2 + 1) % 55;
363 _M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2];
364 return _M_table[_M_index1] % __limit;
368 _M_initialize(
unsigned int __seed)
370 unsigned int __k = 1;
371 _M_table[54] = __seed;
373 for (__i = 0; __i < 54; __i++)
375 size_t __ii = (21 * (__i + 1) % 55) - 1;
376 _M_table[__ii] = __k;
378 __seed = _M_table[__ii];
380 for (
int __loop = 0; __loop < 4; __loop++)
382 for (__i = 0; __i < 55; __i++)
383 _M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55];
391 { _M_initialize(__seed); }
395 { _M_initialize(161803398u); }
402 template <
class _Ret,
class _Tp,
class _Arg>
403 inline mem_fun1_t<_Ret, _Tp, _Arg>
404 mem_fun1(_Ret (_Tp::*__f)(_Arg))
405 {
return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
407 template <
class _Ret,
class _Tp,
class _Arg>
408 inline const_mem_fun1_t<_Ret, _Tp, _Arg>
409 mem_fun1(_Ret (_Tp::*__f)(_Arg)
const)
410 {
return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
412 template <
class _Ret,
class _Tp,
class _Arg>
413 inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
414 mem_fun1_ref(_Ret (_Tp::*__f)(_Arg))
415 {
return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
417 template <
class _Ret,
class _Tp,
class _Arg>
418 inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
419 mem_fun1_ref(_Ret (_Tp::*__f)(_Arg)
const)
420 {
return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
422 _GLIBCXX_END_NAMESPACE