30#ifndef _GLIBCXX_PREDEFINED_OPS_H
31#define _GLIBCXX_PREDEFINED_OPS_H 1
34#if __cplusplus >= 201103L
46 typedef std::equal_to<void> equal_to;
47 typedef std::less<void> less;
49#if __cplusplus >= 201103L
51 template<
typename _Fn>
52 using __by_ref_or_value_fn
53 = std::__conditional_t<std::__or_<std::is_empty<_Fn>,
54 std::is_scalar<_Fn>>::value,
62 template<
typename _Func,
typename _Value,
bool _Val_2nd = false>
65 using _Fn = __by_ref_or_value_fn<_Func>;
68 _Comp_with_val(_Fn __f,
const _Value& __v)
69 : _M_f(__f), _M_val(__v) { }
71 [[__no_unique_address__]] _Fn _M_f;
74 template<
typename _Tp>
75 _GLIBCXX14_CONSTEXPR
bool
76 operator()(_Tp&& __arg)
78#pragma GCC diagnostic push
79#pragma GCC diagnostic ignored "-Wc++17-extensions"
80 if constexpr (_Val_2nd)
81 return _M_f(__arg, _M_val);
83 return _M_f(_M_val, __arg);
84#pragma GCC diagnostic pop
88 template<
typename _Func,
typename _Value>
89 using _Comp_with_val_1st = _Comp_with_val<_Func, _Value, false>;
90 template<
typename _Func,
typename _Value>
91 using _Comp_with_val_2nd = _Comp_with_val<_Func, _Value, true>;
93 template<
typename _Func>
96 using _Fn = __by_ref_or_value_fn<_Func>;
99 _Unary_negate(_Fn __f) : _M_f(__f) { }
101 [[__no_unique_address__]] _Fn _M_f;
103 template<
typename _Tp>
104 _GLIBCXX14_CONSTEXPR
bool
105 operator()(_Tp&& __arg) {
return !_M_f(__arg); }
108 template<
typename _Func>
109 constexpr _Unary_negate<_Func>
111 {
return _Unary_negate<_Func>(__f); }
115 template<
typename _Fn>
116 struct __by_ref_or_value_fn
117 : __conditional_type<__is_empty(_Fn), _Fn, _Fn&>
120 template<
typename _Fn>
121 struct __by_ref_or_value_fn<_Fn*>
122 {
typedef _Fn* __type; };
128 template<
typename _Func,
typename _Value>
129 struct _Comp_with_val_1st
131 typedef typename __by_ref_or_value_fn<_Func>::__type _Fn;
134 _Comp_with_val_1st(_Fn __f,
const _Value& __v)
135 : _M_f(__f), _M_val(__v) { }
138 const _Value& _M_val;
140 template<
typename _Tp>
141 bool operator()(_Tp& __arg) {
return _M_f(_M_val, __arg); }
142 template<
typename _Tp>
143 bool operator()(
const _Tp& __arg) {
return _M_f(_M_val, __arg); }
146 template<
typename _Func,
typename _Value>
147 struct _Comp_with_val_2nd
149 typedef typename __by_ref_or_value_fn<_Func>::__type _Fn;
152 _Comp_with_val_2nd(_Fn __f,
const _Value& __v)
153 : _M_f(__f), _M_val(__v) { }
156 const _Value& _M_val;
158 template<
typename _Tp>
159 bool operator()(_Tp& __arg) {
return _M_f(__arg, _M_val); }
160 template<
typename _Tp>
161 bool operator()(
const _Tp& __arg) {
return _M_f(__arg, _M_val); }
164 template<
typename _Func>
165 struct _Unary_negate_1
167 typedef typename __by_ref_or_value_fn<_Func>::__type _Fn;
169 explicit _Unary_negate_1(_Fn __f) : _M_f(__f) { }
173 template<
typename _Tp>
175 operator()(_Tp& __arg) {
return !_M_f(__arg); }
176 template<
typename _Tp>
178 operator()(
const _Tp& __arg) {
return !_M_f(__arg); }
181 template<
typename _Func>
182 inline _Unary_negate_1<_Func>
184 {
return _Unary_negate_1<_Func>(__f); }
190 template<
typename _Func,
typename _Value>
191 _GLIBCXX_CONSTEXPR
inline _Comp_with_val_1st<_Func, _Value>
192 bind1st(_Func& __f,
const _Value& __val)
193 {
return _Comp_with_val_1st<_Func, _Value>(__f, __val); }
195 template<
typename _Func,
typename _Value>
196 _GLIBCXX_CONSTEXPR
inline _Comp_with_val_2nd<_Func, _Value>
197 bind2nd(_Func& __f,
const _Value& __val)
198 {
return _Comp_with_val_2nd<_Func, _Value>(__f, __val); }
201 template<
typename _Value>
202 _GLIBCXX_CONSTEXPR
inline _Comp_with_val_2nd<equal_to, _Value>
203 __equal_to(
const _Value& __val)
204 {
return _Comp_with_val_2nd<equal_to, _Value>(equal_to(), __val); }
GNU extensions for public use.