operations.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  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. #if _LIBCPP_STD_VER > 11
  21. template <class _Tp = void>
  22. #else
  23. template <class _Tp>
  24. #endif
  25. struct _LIBCPP_TEMPLATE_VIS plus
  26. : __binary_function<_Tp, _Tp, _Tp>
  27. {
  28. typedef _Tp __result_type; // used by valarray
  29. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  30. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  31. {return __x + __y;}
  32. };
  33. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
  34. #if _LIBCPP_STD_VER > 11
  35. template <>
  36. struct _LIBCPP_TEMPLATE_VIS plus<void>
  37. {
  38. template <class _T1, class _T2>
  39. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  40. auto operator()(_T1&& __t, _T2&& __u) const
  41. noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
  42. -> decltype( _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
  43. { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
  44. typedef void is_transparent;
  45. };
  46. #endif
  47. #if _LIBCPP_STD_VER > 11
  48. template <class _Tp = void>
  49. #else
  50. template <class _Tp>
  51. #endif
  52. struct _LIBCPP_TEMPLATE_VIS minus
  53. : __binary_function<_Tp, _Tp, _Tp>
  54. {
  55. typedef _Tp __result_type; // used by valarray
  56. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  57. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  58. {return __x - __y;}
  59. };
  60. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
  61. #if _LIBCPP_STD_VER > 11
  62. template <>
  63. struct _LIBCPP_TEMPLATE_VIS minus<void>
  64. {
  65. template <class _T1, class _T2>
  66. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  67. auto operator()(_T1&& __t, _T2&& __u) const
  68. noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
  69. -> decltype( _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
  70. { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
  71. typedef void is_transparent;
  72. };
  73. #endif
  74. #if _LIBCPP_STD_VER > 11
  75. template <class _Tp = void>
  76. #else
  77. template <class _Tp>
  78. #endif
  79. struct _LIBCPP_TEMPLATE_VIS multiplies
  80. : __binary_function<_Tp, _Tp, _Tp>
  81. {
  82. typedef _Tp __result_type; // used by valarray
  83. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  84. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  85. {return __x * __y;}
  86. };
  87. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
  88. #if _LIBCPP_STD_VER > 11
  89. template <>
  90. struct _LIBCPP_TEMPLATE_VIS multiplies<void>
  91. {
  92. template <class _T1, class _T2>
  93. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  94. auto operator()(_T1&& __t, _T2&& __u) const
  95. noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
  96. -> decltype( _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
  97. { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
  98. typedef void is_transparent;
  99. };
  100. #endif
  101. #if _LIBCPP_STD_VER > 11
  102. template <class _Tp = void>
  103. #else
  104. template <class _Tp>
  105. #endif
  106. struct _LIBCPP_TEMPLATE_VIS divides
  107. : __binary_function<_Tp, _Tp, _Tp>
  108. {
  109. typedef _Tp __result_type; // used by valarray
  110. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  111. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  112. {return __x / __y;}
  113. };
  114. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
  115. #if _LIBCPP_STD_VER > 11
  116. template <>
  117. struct _LIBCPP_TEMPLATE_VIS divides<void>
  118. {
  119. template <class _T1, class _T2>
  120. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  121. auto operator()(_T1&& __t, _T2&& __u) const
  122. noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
  123. -> decltype( _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
  124. { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
  125. typedef void is_transparent;
  126. };
  127. #endif
  128. #if _LIBCPP_STD_VER > 11
  129. template <class _Tp = void>
  130. #else
  131. template <class _Tp>
  132. #endif
  133. struct _LIBCPP_TEMPLATE_VIS modulus
  134. : __binary_function<_Tp, _Tp, _Tp>
  135. {
  136. typedef _Tp __result_type; // used by valarray
  137. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  138. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  139. {return __x % __y;}
  140. };
  141. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
  142. #if _LIBCPP_STD_VER > 11
  143. template <>
  144. struct _LIBCPP_TEMPLATE_VIS modulus<void>
  145. {
  146. template <class _T1, class _T2>
  147. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  148. auto operator()(_T1&& __t, _T2&& __u) const
  149. noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
  150. -> decltype( _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
  151. { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
  152. typedef void is_transparent;
  153. };
  154. #endif
  155. #if _LIBCPP_STD_VER > 11
  156. template <class _Tp = void>
  157. #else
  158. template <class _Tp>
  159. #endif
  160. struct _LIBCPP_TEMPLATE_VIS negate
  161. : __unary_function<_Tp, _Tp>
  162. {
  163. typedef _Tp __result_type; // used by valarray
  164. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  165. _Tp operator()(const _Tp& __x) const
  166. {return -__x;}
  167. };
  168. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
  169. #if _LIBCPP_STD_VER > 11
  170. template <>
  171. struct _LIBCPP_TEMPLATE_VIS negate<void>
  172. {
  173. template <class _Tp>
  174. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  175. auto operator()(_Tp&& __x) const
  176. noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
  177. -> decltype( - _VSTD::forward<_Tp>(__x))
  178. { return - _VSTD::forward<_Tp>(__x); }
  179. typedef void is_transparent;
  180. };
  181. #endif
  182. // Bitwise operations
  183. #if _LIBCPP_STD_VER > 11
  184. template <class _Tp = void>
  185. #else
  186. template <class _Tp>
  187. #endif
  188. struct _LIBCPP_TEMPLATE_VIS bit_and
  189. : __binary_function<_Tp, _Tp, _Tp>
  190. {
  191. typedef _Tp __result_type; // used by valarray
  192. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  193. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  194. {return __x & __y;}
  195. };
  196. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
  197. #if _LIBCPP_STD_VER > 11
  198. template <>
  199. struct _LIBCPP_TEMPLATE_VIS bit_and<void>
  200. {
  201. template <class _T1, class _T2>
  202. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  203. auto operator()(_T1&& __t, _T2&& __u) const
  204. noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
  205. -> decltype( _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
  206. { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
  207. typedef void is_transparent;
  208. };
  209. #endif
  210. #if _LIBCPP_STD_VER > 11
  211. template <class _Tp = void>
  212. struct _LIBCPP_TEMPLATE_VIS bit_not
  213. : __unary_function<_Tp, _Tp>
  214. {
  215. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  216. _Tp operator()(const _Tp& __x) const
  217. {return ~__x;}
  218. };
  219. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
  220. template <>
  221. struct _LIBCPP_TEMPLATE_VIS bit_not<void>
  222. {
  223. template <class _Tp>
  224. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  225. auto operator()(_Tp&& __x) const
  226. noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
  227. -> decltype( ~_VSTD::forward<_Tp>(__x))
  228. { return ~_VSTD::forward<_Tp>(__x); }
  229. typedef void is_transparent;
  230. };
  231. #endif
  232. #if _LIBCPP_STD_VER > 11
  233. template <class _Tp = void>
  234. #else
  235. template <class _Tp>
  236. #endif
  237. struct _LIBCPP_TEMPLATE_VIS bit_or
  238. : __binary_function<_Tp, _Tp, _Tp>
  239. {
  240. typedef _Tp __result_type; // used by valarray
  241. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  242. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  243. {return __x | __y;}
  244. };
  245. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
  246. #if _LIBCPP_STD_VER > 11
  247. template <>
  248. struct _LIBCPP_TEMPLATE_VIS bit_or<void>
  249. {
  250. template <class _T1, class _T2>
  251. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  252. auto operator()(_T1&& __t, _T2&& __u) const
  253. noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
  254. -> decltype( _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
  255. { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
  256. typedef void is_transparent;
  257. };
  258. #endif
  259. #if _LIBCPP_STD_VER > 11
  260. template <class _Tp = void>
  261. #else
  262. template <class _Tp>
  263. #endif
  264. struct _LIBCPP_TEMPLATE_VIS bit_xor
  265. : __binary_function<_Tp, _Tp, _Tp>
  266. {
  267. typedef _Tp __result_type; // used by valarray
  268. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  269. _Tp operator()(const _Tp& __x, const _Tp& __y) const
  270. {return __x ^ __y;}
  271. };
  272. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
  273. #if _LIBCPP_STD_VER > 11
  274. template <>
  275. struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
  276. {
  277. template <class _T1, class _T2>
  278. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  279. auto operator()(_T1&& __t, _T2&& __u) const
  280. noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
  281. -> decltype( _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
  282. { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
  283. typedef void is_transparent;
  284. };
  285. #endif
  286. // Comparison operations
  287. #if _LIBCPP_STD_VER > 11
  288. template <class _Tp = void>
  289. #else
  290. template <class _Tp>
  291. #endif
  292. struct _LIBCPP_TEMPLATE_VIS equal_to
  293. : __binary_function<_Tp, _Tp, bool>
  294. {
  295. typedef bool __result_type; // used by valarray
  296. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  297. bool operator()(const _Tp& __x, const _Tp& __y) const
  298. {return __x == __y;}
  299. };
  300. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
  301. #if _LIBCPP_STD_VER > 11
  302. template <>
  303. struct _LIBCPP_TEMPLATE_VIS equal_to<void>
  304. {
  305. template <class _T1, class _T2>
  306. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  307. auto operator()(_T1&& __t, _T2&& __u) const
  308. noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
  309. -> decltype( _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
  310. { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
  311. typedef void is_transparent;
  312. };
  313. #endif
  314. #if _LIBCPP_STD_VER > 11
  315. template <class _Tp = void>
  316. #else
  317. template <class _Tp>
  318. #endif
  319. struct _LIBCPP_TEMPLATE_VIS not_equal_to
  320. : __binary_function<_Tp, _Tp, bool>
  321. {
  322. typedef bool __result_type; // used by valarray
  323. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  324. bool operator()(const _Tp& __x, const _Tp& __y) const
  325. {return __x != __y;}
  326. };
  327. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
  328. #if _LIBCPP_STD_VER > 11
  329. template <>
  330. struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
  331. {
  332. template <class _T1, class _T2>
  333. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  334. auto operator()(_T1&& __t, _T2&& __u) const
  335. noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
  336. -> decltype( _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
  337. { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
  338. typedef void is_transparent;
  339. };
  340. #endif
  341. #if _LIBCPP_STD_VER > 11
  342. template <class _Tp = void>
  343. #else
  344. template <class _Tp>
  345. #endif
  346. struct _LIBCPP_TEMPLATE_VIS less
  347. : __binary_function<_Tp, _Tp, bool>
  348. {
  349. typedef bool __result_type; // used by valarray
  350. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  351. bool operator()(const _Tp& __x, const _Tp& __y) const
  352. {return __x < __y;}
  353. };
  354. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
  355. #if _LIBCPP_STD_VER > 11
  356. template <>
  357. struct _LIBCPP_TEMPLATE_VIS less<void>
  358. {
  359. template <class _T1, class _T2>
  360. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  361. auto operator()(_T1&& __t, _T2&& __u) const
  362. noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
  363. -> decltype( _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
  364. { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
  365. typedef void is_transparent;
  366. };
  367. #endif
  368. #if _LIBCPP_STD_VER > 11
  369. template <class _Tp = void>
  370. #else
  371. template <class _Tp>
  372. #endif
  373. struct _LIBCPP_TEMPLATE_VIS less_equal
  374. : __binary_function<_Tp, _Tp, bool>
  375. {
  376. typedef bool __result_type; // used by valarray
  377. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  378. bool operator()(const _Tp& __x, const _Tp& __y) const
  379. {return __x <= __y;}
  380. };
  381. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
  382. #if _LIBCPP_STD_VER > 11
  383. template <>
  384. struct _LIBCPP_TEMPLATE_VIS less_equal<void>
  385. {
  386. template <class _T1, class _T2>
  387. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  388. auto operator()(_T1&& __t, _T2&& __u) const
  389. noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
  390. -> decltype( _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
  391. { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
  392. typedef void is_transparent;
  393. };
  394. #endif
  395. #if _LIBCPP_STD_VER > 11
  396. template <class _Tp = void>
  397. #else
  398. template <class _Tp>
  399. #endif
  400. struct _LIBCPP_TEMPLATE_VIS greater_equal
  401. : __binary_function<_Tp, _Tp, bool>
  402. {
  403. typedef bool __result_type; // used by valarray
  404. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  405. bool operator()(const _Tp& __x, const _Tp& __y) const
  406. {return __x >= __y;}
  407. };
  408. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
  409. #if _LIBCPP_STD_VER > 11
  410. template <>
  411. struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
  412. {
  413. template <class _T1, class _T2>
  414. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  415. auto operator()(_T1&& __t, _T2&& __u) const
  416. noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
  417. -> decltype( _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
  418. { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
  419. typedef void is_transparent;
  420. };
  421. #endif
  422. #if _LIBCPP_STD_VER > 11
  423. template <class _Tp = void>
  424. #else
  425. template <class _Tp>
  426. #endif
  427. struct _LIBCPP_TEMPLATE_VIS greater
  428. : __binary_function<_Tp, _Tp, bool>
  429. {
  430. typedef bool __result_type; // used by valarray
  431. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  432. bool operator()(const _Tp& __x, const _Tp& __y) const
  433. {return __x > __y;}
  434. };
  435. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
  436. #if _LIBCPP_STD_VER > 11
  437. template <>
  438. struct _LIBCPP_TEMPLATE_VIS greater<void>
  439. {
  440. template <class _T1, class _T2>
  441. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  442. auto operator()(_T1&& __t, _T2&& __u) const
  443. noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
  444. -> decltype( _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
  445. { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
  446. typedef void is_transparent;
  447. };
  448. #endif
  449. // Logical operations
  450. #if _LIBCPP_STD_VER > 11
  451. template <class _Tp = void>
  452. #else
  453. template <class _Tp>
  454. #endif
  455. struct _LIBCPP_TEMPLATE_VIS logical_and
  456. : __binary_function<_Tp, _Tp, bool>
  457. {
  458. typedef bool __result_type; // used by valarray
  459. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  460. bool operator()(const _Tp& __x, const _Tp& __y) const
  461. {return __x && __y;}
  462. };
  463. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
  464. #if _LIBCPP_STD_VER > 11
  465. template <>
  466. struct _LIBCPP_TEMPLATE_VIS logical_and<void>
  467. {
  468. template <class _T1, class _T2>
  469. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  470. auto operator()(_T1&& __t, _T2&& __u) const
  471. noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
  472. -> decltype( _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
  473. { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
  474. typedef void is_transparent;
  475. };
  476. #endif
  477. #if _LIBCPP_STD_VER > 11
  478. template <class _Tp = void>
  479. #else
  480. template <class _Tp>
  481. #endif
  482. struct _LIBCPP_TEMPLATE_VIS logical_not
  483. : __unary_function<_Tp, bool>
  484. {
  485. typedef bool __result_type; // used by valarray
  486. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  487. bool operator()(const _Tp& __x) const
  488. {return !__x;}
  489. };
  490. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
  491. #if _LIBCPP_STD_VER > 11
  492. template <>
  493. struct _LIBCPP_TEMPLATE_VIS logical_not<void>
  494. {
  495. template <class _Tp>
  496. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  497. auto operator()(_Tp&& __x) const
  498. noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
  499. -> decltype( !_VSTD::forward<_Tp>(__x))
  500. { return !_VSTD::forward<_Tp>(__x); }
  501. typedef void is_transparent;
  502. };
  503. #endif
  504. #if _LIBCPP_STD_VER > 11
  505. template <class _Tp = void>
  506. #else
  507. template <class _Tp>
  508. #endif
  509. struct _LIBCPP_TEMPLATE_VIS logical_or
  510. : __binary_function<_Tp, _Tp, bool>
  511. {
  512. typedef bool __result_type; // used by valarray
  513. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  514. bool operator()(const _Tp& __x, const _Tp& __y) const
  515. {return __x || __y;}
  516. };
  517. _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
  518. #if _LIBCPP_STD_VER > 11
  519. template <>
  520. struct _LIBCPP_TEMPLATE_VIS logical_or<void>
  521. {
  522. template <class _T1, class _T2>
  523. _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
  524. auto operator()(_T1&& __t, _T2&& __u) const
  525. noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
  526. -> decltype( _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
  527. { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
  528. typedef void is_transparent;
  529. };
  530. #endif
  531. _LIBCPP_END_NAMESPACE_STD
  532. #endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H