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