operations.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP___FUNCTIONAL_OPERATIONS_H
  10. #define _LIBCPP___FUNCTIONAL_OPERATIONS_H
  11. #include <__config>
  12. #include <__functional/binary_function.h>
  13. #include <__functional/unary_function.h>
  14. #include <__utility/forward.h>
  15. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  16. # pragma GCC system_header
  17. #endif
  18. _LIBCPP_BEGIN_NAMESPACE_STD
  19. // Arithmetic operations
  20. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  21. #if _LIBCPP_STD_VER > 11
  22. template <class _Tp = void>
  23. #else
  24. template <class _Tp>
  25. #endif
  26. struct _LIBCPP_TEMPLATE_VIS plus
  27. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  28. : binary_function<_Tp, _Tp, _Tp>
  29. #endif
  30. {
  31. _LIBCPP_SUPPRESS_DEPRECATED_POP
  32. typedef _Tp __result_type; // used by valarray
  33. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  34. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
  35. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  36. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  37. #endif
  38. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  39. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  40. {return __x + __y;}
  41. };
  42. #if _LIBCPP_STD_VER > 11
  43. template <>
  44. struct _LIBCPP_TEMPLATE_VIS plus<void>
  45. {
  46. template <class _T1, class _T2>
  47. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  48. auto operator()(_T1&& __t, _T2&& __u) const
  49. noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
  50. -> decltype( _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
  51. { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
  52. typedef void is_transparent;
  53. };
  54. #endif
  55. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  56. #if _LIBCPP_STD_VER > 11
  57. template <class _Tp = void>
  58. #else
  59. template <class _Tp>
  60. #endif
  61. struct _LIBCPP_TEMPLATE_VIS minus
  62. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  63. : binary_function<_Tp, _Tp, _Tp>
  64. #endif
  65. {
  66. _LIBCPP_SUPPRESS_DEPRECATED_POP
  67. typedef _Tp __result_type; // used by valarray
  68. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  69. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
  70. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  71. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  72. #endif
  73. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  74. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  75. {return __x - __y;}
  76. };
  77. #if _LIBCPP_STD_VER > 11
  78. template <>
  79. struct _LIBCPP_TEMPLATE_VIS minus<void>
  80. {
  81. template <class _T1, class _T2>
  82. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  83. auto operator()(_T1&& __t, _T2&& __u) const
  84. noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
  85. -> decltype( _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
  86. { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
  87. typedef void is_transparent;
  88. };
  89. #endif
  90. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  91. #if _LIBCPP_STD_VER > 11
  92. template <class _Tp = void>
  93. #else
  94. template <class _Tp>
  95. #endif
  96. struct _LIBCPP_TEMPLATE_VIS multiplies
  97. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  98. : binary_function<_Tp, _Tp, _Tp>
  99. #endif
  100. {
  101. _LIBCPP_SUPPRESS_DEPRECATED_POP
  102. typedef _Tp __result_type; // used by valarray
  103. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  104. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
  105. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  106. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  107. #endif
  108. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  109. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  110. {return __x * __y;}
  111. };
  112. #if _LIBCPP_STD_VER > 11
  113. template <>
  114. struct _LIBCPP_TEMPLATE_VIS multiplies<void>
  115. {
  116. template <class _T1, class _T2>
  117. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  118. auto operator()(_T1&& __t, _T2&& __u) const
  119. noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
  120. -> decltype( _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
  121. { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
  122. typedef void is_transparent;
  123. };
  124. #endif
  125. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  126. #if _LIBCPP_STD_VER > 11
  127. template <class _Tp = void>
  128. #else
  129. template <class _Tp>
  130. #endif
  131. struct _LIBCPP_TEMPLATE_VIS divides
  132. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  133. : binary_function<_Tp, _Tp, _Tp>
  134. #endif
  135. {
  136. _LIBCPP_SUPPRESS_DEPRECATED_POP
  137. typedef _Tp __result_type; // used by valarray
  138. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  139. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
  140. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  141. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  142. #endif
  143. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  144. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  145. {return __x / __y;}
  146. };
  147. #if _LIBCPP_STD_VER > 11
  148. template <>
  149. struct _LIBCPP_TEMPLATE_VIS divides<void>
  150. {
  151. template <class _T1, class _T2>
  152. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  153. auto operator()(_T1&& __t, _T2&& __u) const
  154. noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
  155. -> decltype( _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
  156. { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
  157. typedef void is_transparent;
  158. };
  159. #endif
  160. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  161. #if _LIBCPP_STD_VER > 11
  162. template <class _Tp = void>
  163. #else
  164. template <class _Tp>
  165. #endif
  166. struct _LIBCPP_TEMPLATE_VIS modulus
  167. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  168. : binary_function<_Tp, _Tp, _Tp>
  169. #endif
  170. {
  171. _LIBCPP_SUPPRESS_DEPRECATED_POP
  172. typedef _Tp __result_type; // used by valarray
  173. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  174. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
  175. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  176. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  177. #endif
  178. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  179. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  180. {return __x % __y;}
  181. };
  182. #if _LIBCPP_STD_VER > 11
  183. template <>
  184. struct _LIBCPP_TEMPLATE_VIS modulus<void>
  185. {
  186. template <class _T1, class _T2>
  187. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  188. auto operator()(_T1&& __t, _T2&& __u) const
  189. noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
  190. -> decltype( _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
  191. { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
  192. typedef void is_transparent;
  193. };
  194. #endif
  195. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  196. #if _LIBCPP_STD_VER > 11
  197. template <class _Tp = void>
  198. #else
  199. template <class _Tp>
  200. #endif
  201. struct _LIBCPP_TEMPLATE_VIS negate
  202. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  203. : unary_function<_Tp, _Tp>
  204. #endif
  205. {
  206. _LIBCPP_SUPPRESS_DEPRECATED_POP
  207. typedef _Tp __result_type; // used by valarray
  208. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  209. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
  210. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
  211. #endif
  212. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  213. _Tp operator()(const _Tp& __x) const
  214. {return -__x;}
  215. };
  216. #if _LIBCPP_STD_VER > 11
  217. template <>
  218. struct _LIBCPP_TEMPLATE_VIS negate<void>
  219. {
  220. template <class _Tp>
  221. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  222. auto operator()(_Tp&& __x) const
  223. noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
  224. -> decltype( - _VSTD::forward<_Tp>(__x))
  225. { return - _VSTD::forward<_Tp>(__x); }
  226. typedef void is_transparent;
  227. };
  228. #endif
  229. // Bitwise operations
  230. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  231. #if _LIBCPP_STD_VER > 11
  232. template <class _Tp = void>
  233. #else
  234. template <class _Tp>
  235. #endif
  236. struct _LIBCPP_TEMPLATE_VIS bit_and
  237. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  238. : binary_function<_Tp, _Tp, _Tp>
  239. #endif
  240. {
  241. _LIBCPP_SUPPRESS_DEPRECATED_POP
  242. typedef _Tp __result_type; // used by valarray
  243. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  244. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
  245. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  246. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  247. #endif
  248. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  249. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  250. {return __x & __y;}
  251. };
  252. #if _LIBCPP_STD_VER > 11
  253. template <>
  254. struct _LIBCPP_TEMPLATE_VIS bit_and<void>
  255. {
  256. template <class _T1, class _T2>
  257. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  258. auto operator()(_T1&& __t, _T2&& __u) const
  259. noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
  260. -> decltype( _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
  261. { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
  262. typedef void is_transparent;
  263. };
  264. #endif
  265. #if _LIBCPP_STD_VER > 11
  266. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  267. template <class _Tp = void>
  268. struct _LIBCPP_TEMPLATE_VIS bit_not
  269. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  270. : unary_function<_Tp, _Tp>
  271. #endif
  272. {
  273. _LIBCPP_SUPPRESS_DEPRECATED_POP
  274. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  275. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
  276. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
  277. #endif
  278. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  279. _Tp operator()(const _Tp& __x) const
  280. {return ~__x;}
  281. };
  282. template <>
  283. struct _LIBCPP_TEMPLATE_VIS bit_not<void>
  284. {
  285. template <class _Tp>
  286. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  287. auto operator()(_Tp&& __x) const
  288. noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
  289. -> decltype( ~_VSTD::forward<_Tp>(__x))
  290. { return ~_VSTD::forward<_Tp>(__x); }
  291. typedef void is_transparent;
  292. };
  293. #endif
  294. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  295. #if _LIBCPP_STD_VER > 11
  296. template <class _Tp = void>
  297. #else
  298. template <class _Tp>
  299. #endif
  300. struct _LIBCPP_TEMPLATE_VIS bit_or
  301. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  302. : binary_function<_Tp, _Tp, _Tp>
  303. #endif
  304. {
  305. _LIBCPP_SUPPRESS_DEPRECATED_POP
  306. typedef _Tp __result_type; // used by valarray
  307. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  308. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
  309. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  310. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  311. #endif
  312. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  313. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  314. {return __x | __y;}
  315. };
  316. #if _LIBCPP_STD_VER > 11
  317. template <>
  318. struct _LIBCPP_TEMPLATE_VIS bit_or<void>
  319. {
  320. template <class _T1, class _T2>
  321. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  322. auto operator()(_T1&& __t, _T2&& __u) const
  323. noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
  324. -> decltype( _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
  325. { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
  326. typedef void is_transparent;
  327. };
  328. #endif
  329. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  330. #if _LIBCPP_STD_VER > 11
  331. template <class _Tp = void>
  332. #else
  333. template <class _Tp>
  334. #endif
  335. struct _LIBCPP_TEMPLATE_VIS bit_xor
  336. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  337. : binary_function<_Tp, _Tp, _Tp>
  338. #endif
  339. {
  340. _LIBCPP_SUPPRESS_DEPRECATED_POP
  341. typedef _Tp __result_type; // used by valarray
  342. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  343. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
  344. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  345. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  346. #endif
  347. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  348. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  349. {return __x ^ __y;}
  350. };
  351. #if _LIBCPP_STD_VER > 11
  352. template <>
  353. struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
  354. {
  355. template <class _T1, class _T2>
  356. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  357. auto operator()(_T1&& __t, _T2&& __u) const
  358. noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
  359. -> decltype( _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
  360. { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
  361. typedef void is_transparent;
  362. };
  363. #endif
  364. // Comparison operations
  365. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  366. #if _LIBCPP_STD_VER > 11
  367. template <class _Tp = void>
  368. #else
  369. template <class _Tp>
  370. #endif
  371. struct _LIBCPP_TEMPLATE_VIS equal_to
  372. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  373. : binary_function<_Tp, _Tp, bool>
  374. #endif
  375. {
  376. _LIBCPP_SUPPRESS_DEPRECATED_POP
  377. typedef bool __result_type; // used by valarray
  378. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  379. _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
  380. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  381. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  382. #endif
  383. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  384. bool operator()(const _Tp& __x, const _Tp& __y) const
  385. {return __x == __y;}
  386. };
  387. #if _LIBCPP_STD_VER > 11
  388. template <>
  389. struct _LIBCPP_TEMPLATE_VIS equal_to<void>
  390. {
  391. template <class _T1, class _T2>
  392. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  393. auto operator()(_T1&& __t, _T2&& __u) const
  394. noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
  395. -> decltype( _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
  396. { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
  397. typedef void is_transparent;
  398. };
  399. #endif
  400. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  401. #if _LIBCPP_STD_VER > 11
  402. template <class _Tp = void>
  403. #else
  404. template <class _Tp>
  405. #endif
  406. struct _LIBCPP_TEMPLATE_VIS not_equal_to
  407. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  408. : binary_function<_Tp, _Tp, bool>
  409. #endif
  410. {
  411. _LIBCPP_SUPPRESS_DEPRECATED_POP
  412. typedef bool __result_type; // used by valarray
  413. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  414. _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
  415. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  416. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  417. #endif
  418. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  419. bool operator()(const _Tp& __x, const _Tp& __y) const
  420. {return __x != __y;}
  421. };
  422. #if _LIBCPP_STD_VER > 11
  423. template <>
  424. struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
  425. {
  426. template <class _T1, class _T2>
  427. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  428. auto operator()(_T1&& __t, _T2&& __u) const
  429. noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
  430. -> decltype( _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
  431. { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
  432. typedef void is_transparent;
  433. };
  434. #endif
  435. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  436. #if _LIBCPP_STD_VER > 11
  437. template <class _Tp = void>
  438. #else
  439. template <class _Tp>
  440. #endif
  441. struct _LIBCPP_TEMPLATE_VIS less
  442. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  443. : binary_function<_Tp, _Tp, bool>
  444. #endif
  445. {
  446. _LIBCPP_SUPPRESS_DEPRECATED_POP
  447. typedef bool __result_type; // used by valarray
  448. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  449. _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
  450. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  451. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  452. #endif
  453. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  454. bool operator()(const _Tp& __x, const _Tp& __y) const
  455. {return __x < __y;}
  456. };
  457. #if _LIBCPP_STD_VER > 11
  458. template <>
  459. struct _LIBCPP_TEMPLATE_VIS less<void>
  460. {
  461. template <class _T1, class _T2>
  462. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  463. auto operator()(_T1&& __t, _T2&& __u) const
  464. noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
  465. -> decltype( _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
  466. { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
  467. typedef void is_transparent;
  468. };
  469. #endif
  470. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  471. #if _LIBCPP_STD_VER > 11
  472. template <class _Tp = void>
  473. #else
  474. template <class _Tp>
  475. #endif
  476. struct _LIBCPP_TEMPLATE_VIS less_equal
  477. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  478. : binary_function<_Tp, _Tp, bool>
  479. #endif
  480. {
  481. _LIBCPP_SUPPRESS_DEPRECATED_POP
  482. typedef bool __result_type; // used by valarray
  483. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  484. _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
  485. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  486. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  487. #endif
  488. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  489. bool operator()(const _Tp& __x, const _Tp& __y) const
  490. {return __x <= __y;}
  491. };
  492. #if _LIBCPP_STD_VER > 11
  493. template <>
  494. struct _LIBCPP_TEMPLATE_VIS less_equal<void>
  495. {
  496. template <class _T1, class _T2>
  497. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  498. auto operator()(_T1&& __t, _T2&& __u) const
  499. noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
  500. -> decltype( _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
  501. { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
  502. typedef void is_transparent;
  503. };
  504. #endif
  505. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  506. #if _LIBCPP_STD_VER > 11
  507. template <class _Tp = void>
  508. #else
  509. template <class _Tp>
  510. #endif
  511. struct _LIBCPP_TEMPLATE_VIS greater_equal
  512. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  513. : binary_function<_Tp, _Tp, bool>
  514. #endif
  515. {
  516. _LIBCPP_SUPPRESS_DEPRECATED_POP
  517. typedef bool __result_type; // used by valarray
  518. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  519. _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
  520. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  521. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  522. #endif
  523. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  524. bool operator()(const _Tp& __x, const _Tp& __y) const
  525. {return __x >= __y;}
  526. };
  527. #if _LIBCPP_STD_VER > 11
  528. template <>
  529. struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
  530. {
  531. template <class _T1, class _T2>
  532. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  533. auto operator()(_T1&& __t, _T2&& __u) const
  534. noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
  535. -> decltype( _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
  536. { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
  537. typedef void is_transparent;
  538. };
  539. #endif
  540. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  541. #if _LIBCPP_STD_VER > 11
  542. template <class _Tp = void>
  543. #else
  544. template <class _Tp>
  545. #endif
  546. struct _LIBCPP_TEMPLATE_VIS greater
  547. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  548. : binary_function<_Tp, _Tp, bool>
  549. #endif
  550. {
  551. _LIBCPP_SUPPRESS_DEPRECATED_POP
  552. typedef bool __result_type; // used by valarray
  553. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  554. _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
  555. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  556. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  557. #endif
  558. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  559. bool operator()(const _Tp& __x, const _Tp& __y) const
  560. {return __x > __y;}
  561. };
  562. #if _LIBCPP_STD_VER > 11
  563. template <>
  564. struct _LIBCPP_TEMPLATE_VIS greater<void>
  565. {
  566. template <class _T1, class _T2>
  567. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  568. auto operator()(_T1&& __t, _T2&& __u) const
  569. noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
  570. -> decltype( _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
  571. { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
  572. typedef void is_transparent;
  573. };
  574. #endif
  575. // Logical operations
  576. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  577. #if _LIBCPP_STD_VER > 11
  578. template <class _Tp = void>
  579. #else
  580. template <class _Tp>
  581. #endif
  582. struct _LIBCPP_TEMPLATE_VIS logical_and
  583. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  584. : binary_function<_Tp, _Tp, bool>
  585. #endif
  586. {
  587. _LIBCPP_SUPPRESS_DEPRECATED_POP
  588. typedef bool __result_type; // used by valarray
  589. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  590. _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
  591. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  592. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  593. #endif
  594. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  595. bool operator()(const _Tp& __x, const _Tp& __y) const
  596. {return __x && __y;}
  597. };
  598. #if _LIBCPP_STD_VER > 11
  599. template <>
  600. struct _LIBCPP_TEMPLATE_VIS logical_and<void>
  601. {
  602. template <class _T1, class _T2>
  603. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  604. auto operator()(_T1&& __t, _T2&& __u) const
  605. noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
  606. -> decltype( _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
  607. { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
  608. typedef void is_transparent;
  609. };
  610. #endif
  611. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  612. #if _LIBCPP_STD_VER > 11
  613. template <class _Tp = void>
  614. #else
  615. template <class _Tp>
  616. #endif
  617. struct _LIBCPP_TEMPLATE_VIS logical_not
  618. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  619. : unary_function<_Tp, bool>
  620. #endif
  621. {
  622. _LIBCPP_SUPPRESS_DEPRECATED_POP
  623. typedef bool __result_type; // used by valarray
  624. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  625. _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
  626. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
  627. #endif
  628. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  629. bool operator()(const _Tp& __x) const
  630. {return !__x;}
  631. };
  632. #if _LIBCPP_STD_VER > 11
  633. template <>
  634. struct _LIBCPP_TEMPLATE_VIS logical_not<void>
  635. {
  636. template <class _Tp>
  637. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  638. auto operator()(_Tp&& __x) const
  639. noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
  640. -> decltype( !_VSTD::forward<_Tp>(__x))
  641. { return !_VSTD::forward<_Tp>(__x); }
  642. typedef void is_transparent;
  643. };
  644. #endif
  645. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  646. #if _LIBCPP_STD_VER > 11
  647. template <class _Tp = void>
  648. #else
  649. template <class _Tp>
  650. #endif
  651. struct _LIBCPP_TEMPLATE_VIS logical_or
  652. #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
  653. : binary_function<_Tp, _Tp, bool>
  654. #endif
  655. {
  656. _LIBCPP_SUPPRESS_DEPRECATED_POP
  657. typedef bool __result_type; // used by valarray
  658. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
  659. _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
  660. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
  661. _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
  662. #endif
  663. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  664. bool operator()(const _Tp& __x, const _Tp& __y) const
  665. {return __x || __y;}
  666. };
  667. #if _LIBCPP_STD_VER > 11
  668. template <>
  669. struct _LIBCPP_TEMPLATE_VIS logical_or<void>
  670. {
  671. template <class _T1, class _T2>
  672. _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
  673. auto operator()(_T1&& __t, _T2&& __u) const
  674. noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
  675. -> decltype( _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
  676. { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
  677. typedef void is_transparent;
  678. };
  679. #endif
  680. _LIBCPP_END_NAMESPACE_STD
  681. #endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H