Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===------------------------ functional ----------------------------------===// |
| 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_FUNCTIONAL |
| 11 | #define _LIBCPP_FUNCTIONAL |
| 12 | |
| 13 | /* |
| 14 | functional synopsis |
| 15 | |
| 16 | namespace std |
| 17 | { |
| 18 | |
| 19 | template <class Arg, class Result> |
| 20 | struct unary_function |
| 21 | { |
| 22 | typedef Arg argument_type; |
| 23 | typedef Result result_type; |
| 24 | }; |
| 25 | |
| 26 | template <class Arg1, class Arg2, class Result> |
| 27 | struct binary_function |
| 28 | { |
| 29 | typedef Arg1 first_argument_type; |
| 30 | typedef Arg2 second_argument_type; |
| 31 | typedef Result result_type; |
| 32 | }; |
| 33 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 34 | template <class T> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 35 | class reference_wrapper |
| 36 | : public unary_function<T1, R> // if wrapping a unary functor |
| 37 | : public binary_function<T1, T2, R> // if wraping a binary functor |
| 38 | { |
| 39 | public: |
| 40 | // types |
| 41 | typedef T type; |
| 42 | typedef see below result_type; // Not always defined |
| 43 | |
| 44 | // construct/copy/destroy |
Arthur O'Dwyer | 8fa8794 | 2020-12-05 19:37:41 -0500 | [diff] [blame] | 45 | template<class U> |
| 46 | reference_wrapper(U&&); |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 47 | reference_wrapper(const reference_wrapper<T>& x) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 48 | |
| 49 | // assignment |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 50 | reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 51 | |
| 52 | // access |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 53 | operator T& () const noexcept; |
| 54 | T& get() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 55 | |
| 56 | // invoke |
| 57 | template <class... ArgTypes> |
Howard Hinnant | c9c775b | 2013-09-21 17:58:58 +0000 | [diff] [blame] | 58 | typename result_of<T&(ArgTypes&&...)>::type |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 59 | operator() (ArgTypes&&...) const; |
| 60 | }; |
| 61 | |
Arthur O'Dwyer | 8fa8794 | 2020-12-05 19:37:41 -0500 | [diff] [blame] | 62 | template <class T> |
| 63 | reference_wrapper(T&) -> reference_wrapper<T>; |
| 64 | |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 65 | template <class T> reference_wrapper<T> ref(T& t) noexcept; |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 66 | template <class T> void ref(const T&& t) = delete; |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 67 | template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 68 | |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 69 | template <class T> reference_wrapper<const T> cref(const T& t) noexcept; |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 70 | template <class T> void cref(const T&& t) = delete; |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 71 | template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 72 | |
Louis Dionne | db1892a | 2018-12-03 14:03:27 +0000 | [diff] [blame] | 73 | template <class T> struct unwrap_reference; // since C++20 |
| 74 | template <class T> struct unwrap_ref_decay : unwrap_reference<decay_t<T>> { }; // since C++20 |
| 75 | template <class T> using unwrap_reference_t = typename unwrap_reference<T>::type; // since C++20 |
| 76 | template <class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type; // since C++20 |
| 77 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 78 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 79 | struct plus { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 80 | T operator()(const T& x, const T& y) const; |
| 81 | }; |
| 82 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 83 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 84 | struct minus { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 85 | T operator()(const T& x, const T& y) const; |
| 86 | }; |
| 87 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 88 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 89 | struct multiplies { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 90 | T operator()(const T& x, const T& y) const; |
| 91 | }; |
| 92 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 93 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 94 | struct divides { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 95 | T operator()(const T& x, const T& y) const; |
| 96 | }; |
| 97 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 98 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 99 | struct modulus { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 100 | T operator()(const T& x, const T& y) const; |
| 101 | }; |
| 102 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 103 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 104 | struct negate { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 105 | T operator()(const T& x) const; |
| 106 | }; |
| 107 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 108 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 109 | struct equal_to { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 110 | bool operator()(const T& x, const T& y) const; |
| 111 | }; |
| 112 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 113 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 114 | struct not_equal_to { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 115 | bool operator()(const T& x, const T& y) const; |
| 116 | }; |
| 117 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 118 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 119 | struct greater { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 120 | bool operator()(const T& x, const T& y) const; |
| 121 | }; |
| 122 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 123 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 124 | struct less { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 125 | bool operator()(const T& x, const T& y) const; |
| 126 | }; |
| 127 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 128 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 129 | struct greater_equal { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 130 | bool operator()(const T& x, const T& y) const; |
| 131 | }; |
| 132 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 133 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 134 | struct less_equal { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 135 | bool operator()(const T& x, const T& y) const; |
| 136 | }; |
| 137 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 138 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 139 | struct logical_and { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 140 | bool operator()(const T& x, const T& y) const; |
| 141 | }; |
| 142 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 143 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 144 | struct logical_or { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 145 | bool operator()(const T& x, const T& y) const; |
| 146 | }; |
| 147 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 148 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 149 | struct logical_not { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 150 | bool operator()(const T& x) const; |
| 151 | }; |
| 152 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 153 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 154 | struct bit_and { |
Arthur O'Dwyer | 0e77445 | 2021-03-07 20:22:03 -0500 | [diff] [blame] | 155 | T operator()(const T& x, const T& y) const; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 159 | struct bit_or { |
Arthur O'Dwyer | 0e77445 | 2021-03-07 20:22:03 -0500 | [diff] [blame] | 160 | T operator()(const T& x, const T& y) const; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | template <class T> // <class T=void> in C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 164 | struct bit_xor { |
Arthur O'Dwyer | 0e77445 | 2021-03-07 20:22:03 -0500 | [diff] [blame] | 165 | T operator()(const T& x, const T& y) const; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | template <class T=void> // C++14 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 169 | struct bit_not { |
Arthur O'Dwyer | 0e77445 | 2021-03-07 20:22:03 -0500 | [diff] [blame] | 170 | T operator()(const T& x) const; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 171 | }; |
| 172 | |
Christopher Di Bella | e68ec58 | 2021-03-18 17:21:35 +0000 | [diff] [blame] | 173 | struct identity; // C++20 |
| 174 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 175 | template <class Predicate> |
Arthur O'Dwyer | a6b5107 | 2021-05-24 18:36:17 -0400 | [diff] [blame] | 176 | class unary_negate // deprecated in C++17, removed in C++20 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 177 | : public unary_function<typename Predicate::argument_type, bool> |
| 178 | { |
| 179 | public: |
| 180 | explicit unary_negate(const Predicate& pred); |
| 181 | bool operator()(const typename Predicate::argument_type& x) const; |
| 182 | }; |
| 183 | |
Arthur O'Dwyer | a6b5107 | 2021-05-24 18:36:17 -0400 | [diff] [blame] | 184 | template <class Predicate> // deprecated in C++17, removed in C++20 |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 185 | unary_negate<Predicate> not1(const Predicate& pred); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 186 | |
| 187 | template <class Predicate> |
Arthur O'Dwyer | a6b5107 | 2021-05-24 18:36:17 -0400 | [diff] [blame] | 188 | class binary_negate // deprecated in C++17, removed in C++20 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 189 | : public binary_function<typename Predicate::first_argument_type, |
| 190 | typename Predicate::second_argument_type, |
| 191 | bool> |
| 192 | { |
| 193 | public: |
| 194 | explicit binary_negate(const Predicate& pred); |
| 195 | bool operator()(const typename Predicate::first_argument_type& x, |
| 196 | const typename Predicate::second_argument_type& y) const; |
| 197 | }; |
| 198 | |
Arthur O'Dwyer | a6b5107 | 2021-05-24 18:36:17 -0400 | [diff] [blame] | 199 | template <class Predicate> // deprecated in C++17, removed in C++20 |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 200 | binary_negate<Predicate> not2(const Predicate& pred); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 201 | |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 202 | template <class F> |
| 203 | constexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20 |
Eric Fiselier | 934f63b | 2016-06-02 01:25:41 +0000 | [diff] [blame] | 204 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 205 | template<class T> struct is_bind_expression; |
| 206 | template<class T> struct is_placeholder; |
| 207 | |
Marshall Clow | 2d2d7f1 | 2016-09-22 00:23:15 +0000 | [diff] [blame] | 208 | // See C++14 20.9.9, Function object binders |
Marshall Clow | f1bf62f | 2018-01-02 17:17:01 +0000 | [diff] [blame] | 209 | template <class T> inline constexpr bool is_bind_expression_v |
Marshall Clow | 2d2d7f1 | 2016-09-22 00:23:15 +0000 | [diff] [blame] | 210 | = is_bind_expression<T>::value; // C++17 |
Marshall Clow | f1bf62f | 2018-01-02 17:17:01 +0000 | [diff] [blame] | 211 | template <class T> inline constexpr int is_placeholder_v |
Marshall Clow | 2d2d7f1 | 2016-09-22 00:23:15 +0000 | [diff] [blame] | 212 | = is_placeholder<T>::value; // C++17 |
| 213 | |
| 214 | |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 215 | template<class Fn, class... BoundArgs> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 216 | constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20 |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 217 | template<class R, class Fn, class... BoundArgs> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 218 | constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 219 | |
Louis Dionne | af34f12 | 2019-04-03 17:54:37 +0000 | [diff] [blame] | 220 | template<class F, class... Args> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 221 | constexpr // constexpr in C++20 |
Louis Dionne | af34f12 | 2019-04-03 17:54:37 +0000 | [diff] [blame] | 222 | invoke_result_t<F, Args...> invoke(F&& f, Args&&... args) // C++17 |
| 223 | noexcept(is_nothrow_invocable_v<F, Args...>); |
| 224 | |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 225 | namespace placeholders { |
| 226 | // M is the implementation-defined number of placeholders |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 227 | extern unspecified _1; |
| 228 | extern unspecified _2; |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 229 | . |
| 230 | . |
| 231 | . |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 232 | extern unspecified _Mp; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | template <class Operation> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 236 | class binder1st // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 237 | : public unary_function<typename Operation::second_argument_type, |
| 238 | typename Operation::result_type> |
| 239 | { |
| 240 | protected: |
| 241 | Operation op; |
| 242 | typename Operation::first_argument_type value; |
| 243 | public: |
| 244 | binder1st(const Operation& x, const typename Operation::first_argument_type y); |
| 245 | typename Operation::result_type operator()( typename Operation::second_argument_type& x) const; |
| 246 | typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const; |
| 247 | }; |
| 248 | |
| 249 | template <class Operation, class T> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 250 | binder1st<Operation> bind1st(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 251 | |
| 252 | template <class Operation> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 253 | class binder2nd // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 254 | : public unary_function<typename Operation::first_argument_type, |
| 255 | typename Operation::result_type> |
| 256 | { |
| 257 | protected: |
| 258 | Operation op; |
| 259 | typename Operation::second_argument_type value; |
| 260 | public: |
| 261 | binder2nd(const Operation& x, const typename Operation::second_argument_type y); |
| 262 | typename Operation::result_type operator()( typename Operation::first_argument_type& x) const; |
| 263 | typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const; |
| 264 | }; |
| 265 | |
| 266 | template <class Operation, class T> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 267 | binder2nd<Operation> bind2nd(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 268 | |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 269 | template <class Arg, class Result> // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 270 | class pointer_to_unary_function : public unary_function<Arg, Result> |
| 271 | { |
| 272 | public: |
| 273 | explicit pointer_to_unary_function(Result (*f)(Arg)); |
| 274 | Result operator()(Arg x) const; |
| 275 | }; |
| 276 | |
| 277 | template <class Arg, class Result> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 278 | pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg)); // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 279 | |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 280 | template <class Arg1, class Arg2, class Result> // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 281 | class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result> |
| 282 | { |
| 283 | public: |
| 284 | explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); |
| 285 | Result operator()(Arg1 x, Arg2 y) const; |
| 286 | }; |
| 287 | |
| 288 | template <class Arg1, class Arg2, class Result> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 289 | pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2)); // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 290 | |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 291 | template<class S, class T> // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 292 | class mem_fun_t : public unary_function<T*, S> |
| 293 | { |
| 294 | public: |
| 295 | explicit mem_fun_t(S (T::*p)()); |
| 296 | S operator()(T* p) const; |
| 297 | }; |
| 298 | |
| 299 | template<class S, class T, class A> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 300 | class mem_fun1_t : public binary_function<T*, A, S> // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 301 | { |
| 302 | public: |
| 303 | explicit mem_fun1_t(S (T::*p)(A)); |
| 304 | S operator()(T* p, A x) const; |
| 305 | }; |
| 306 | |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 307 | template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)()); // deprecated in C++11, removed in C++17 |
| 308 | template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 309 | |
| 310 | template<class S, class T> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 311 | class mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 312 | { |
| 313 | public: |
| 314 | explicit mem_fun_ref_t(S (T::*p)()); |
| 315 | S operator()(T& p) const; |
| 316 | }; |
| 317 | |
| 318 | template<class S, class T, class A> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 319 | class mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 320 | { |
| 321 | public: |
| 322 | explicit mem_fun1_ref_t(S (T::*p)(A)); |
| 323 | S operator()(T& p, A x) const; |
| 324 | }; |
| 325 | |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 326 | template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); // deprecated in C++11, removed in C++17 |
| 327 | template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 328 | |
| 329 | template <class S, class T> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 330 | class const_mem_fun_t : public unary_function<const T*, S> // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 331 | { |
| 332 | public: |
| 333 | explicit const_mem_fun_t(S (T::*p)() const); |
| 334 | S operator()(const T* p) const; |
| 335 | }; |
| 336 | |
| 337 | template <class S, class T, class A> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 338 | class const_mem_fun1_t : public binary_function<const T*, A, S> // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 339 | { |
| 340 | public: |
| 341 | explicit const_mem_fun1_t(S (T::*p)(A) const); |
| 342 | S operator()(const T* p, A x) const; |
| 343 | }; |
| 344 | |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 345 | template <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); // deprecated in C++11, removed in C++17 |
| 346 | template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 347 | |
| 348 | template <class S, class T> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 349 | class const_mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 350 | { |
| 351 | public: |
| 352 | explicit const_mem_fun_ref_t(S (T::*p)() const); |
| 353 | S operator()(const T& p) const; |
| 354 | }; |
| 355 | |
| 356 | template <class S, class T, class A> |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 357 | class const_mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 358 | { |
| 359 | public: |
| 360 | explicit const_mem_fun1_ref_t(S (T::*p)(A) const); |
| 361 | S operator()(const T& p, A x) const; |
| 362 | }; |
| 363 | |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 364 | template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); // deprecated in C++11, removed in C++17 |
| 365 | template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 366 | |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 367 | template<class R, class T> |
| 368 | constexpr unspecified mem_fn(R T::*); // constexpr in C++20 |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 369 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 370 | class bad_function_call |
| 371 | : public exception |
| 372 | { |
| 373 | }; |
| 374 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 375 | template<class> class function; // undefined |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 376 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 377 | template<class R, class... ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 378 | class function<R(ArgTypes...)> |
| 379 | : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and |
| 380 | // ArgTypes contains T1 |
| 381 | : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and |
| 382 | // ArgTypes contains T1 and T2 |
| 383 | { |
| 384 | public: |
| 385 | typedef R result_type; |
| 386 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 387 | // construct/copy/destroy: |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 388 | function() noexcept; |
| 389 | function(nullptr_t) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 390 | function(const function&); |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 391 | function(function&&) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 392 | template<class F> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 393 | function(F); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 394 | template<Allocator Alloc> |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 395 | function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 396 | template<Allocator Alloc> |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 397 | function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 398 | template<Allocator Alloc> |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 399 | function(allocator_arg_t, const Alloc&, const function&); // removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 400 | template<Allocator Alloc> |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 401 | function(allocator_arg_t, const Alloc&, function&&); // removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 402 | template<class F, Allocator Alloc> |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 403 | function(allocator_arg_t, const Alloc&, F); // removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 404 | |
| 405 | function& operator=(const function&); |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 406 | function& operator=(function&&) noexcept; |
Howard Hinnant | 7b85be0 | 2011-05-29 13:53:56 +0000 | [diff] [blame] | 407 | function& operator=(nullptr_t) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 408 | template<class F> |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 409 | function& operator=(F&&); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 410 | template<class F> |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 411 | function& operator=(reference_wrapper<F>) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 412 | |
| 413 | ~function(); |
| 414 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 415 | // function modifiers: |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 416 | void swap(function&) noexcept; |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 417 | template<class F, class Alloc> |
Marshall Clow | fc8fd83 | 2016-01-25 17:29:55 +0000 | [diff] [blame] | 418 | void assign(F&&, const Alloc&); // Removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 419 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 420 | // function capacity: |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 421 | explicit operator bool() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 422 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 423 | // function invocation: |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 424 | R operator()(ArgTypes...) const; |
| 425 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 426 | // function target access: |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 427 | const std::type_info& target_type() const noexcept; |
| 428 | template <typename T> T* target() noexcept; |
| 429 | template <typename T> const T* target() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 430 | }; |
| 431 | |
Louis Dionne | 4af4971 | 2019-07-18 19:50:56 +0000 | [diff] [blame] | 432 | // Deduction guides |
| 433 | template<class R, class ...Args> |
| 434 | function(R(*)(Args...)) -> function<R(Args...)>; // since C++17 |
| 435 | |
| 436 | template<class F> |
| 437 | function(F) -> function<see-below>; // since C++17 |
| 438 | |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 439 | // Null pointer comparisons: |
| 440 | template <class R, class ... ArgTypes> |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 441 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 442 | |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 443 | template <class R, class ... ArgTypes> |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 444 | bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 445 | |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 446 | template <class R, class ... ArgTypes> |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 447 | bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 448 | |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 449 | template <class R, class ... ArgTypes> |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 450 | bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 451 | |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 452 | // specialized algorithms: |
| 453 | template <class R, class ... ArgTypes> |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 454 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 455 | |
| 456 | template <class T> struct hash; |
| 457 | |
| 458 | template <> struct hash<bool>; |
| 459 | template <> struct hash<char>; |
| 460 | template <> struct hash<signed char>; |
| 461 | template <> struct hash<unsigned char>; |
Yuriy Chernyshov | fbb87fa | 2020-12-08 13:39:56 -0500 | [diff] [blame] | 462 | template <> struct hash<char8_t>; // since C++20 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 463 | template <> struct hash<char16_t>; |
| 464 | template <> struct hash<char32_t>; |
| 465 | template <> struct hash<wchar_t>; |
| 466 | template <> struct hash<short>; |
| 467 | template <> struct hash<unsigned short>; |
| 468 | template <> struct hash<int>; |
| 469 | template <> struct hash<unsigned int>; |
| 470 | template <> struct hash<long>; |
| 471 | template <> struct hash<long long>; |
| 472 | template <> struct hash<unsigned long>; |
| 473 | template <> struct hash<unsigned long long>; |
| 474 | |
| 475 | template <> struct hash<float>; |
| 476 | template <> struct hash<double>; |
| 477 | template <> struct hash<long double>; |
| 478 | |
| 479 | template<class T> struct hash<T*>; |
Marshall Clow | cc25222 | 2017-03-23 06:20:18 +0000 | [diff] [blame] | 480 | template <> struct hash<nullptr_t>; // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 481 | |
| 482 | } // std |
| 483 | |
| 484 | POLICY: For non-variadic implementations, the number of arguments is limited |
| 485 | to 3. It is hoped that the need for non-variadic implementations |
| 486 | will be minimal. |
| 487 | |
| 488 | */ |
| 489 | |
| 490 | #include <__config> |
Arthur O'Dwyer | 597cac4 | 2021-05-12 23:04:03 -0400 | [diff] [blame] | 491 | #include <__debug> |
Arthur O'Dwyer | ef18160 | 2021-05-19 11:57:04 -0400 | [diff] [blame] | 492 | #include <__functional_base> |
Louis Dionne | a60dd87 | 2021-06-17 11:30:11 -0400 | [diff] [blame] | 493 | #include <__functional/search.h> |
zoecarver | 9ce102c | 2021-04-22 17:33:04 -0700 | [diff] [blame] | 494 | #include <concepts> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 495 | #include <exception> |
| 496 | #include <memory> |
| 497 | #include <tuple> |
Arthur O'Dwyer | ef18160 | 2021-05-19 11:57:04 -0400 | [diff] [blame] | 498 | #include <type_traits> |
| 499 | #include <typeinfo> |
Eric Fiselier | 698a97b | 2017-01-21 00:02:12 +0000 | [diff] [blame] | 500 | #include <utility> |
Marshall Clow | 0a1e750 | 2018-09-12 19:41:40 +0000 | [diff] [blame] | 501 | #include <version> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 502 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 503 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 504 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 505 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 506 | |
| 507 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 508 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 509 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 510 | #if _LIBCPP_STD_VER > 11 |
| 511 | template <class _Tp = void> |
| 512 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 513 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 514 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 515 | struct _LIBCPP_TEMPLATE_VIS plus |
| 516 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 517 | : binary_function<_Tp, _Tp, _Tp> |
| 518 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 519 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 520 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 521 | typedef _Tp __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 522 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 523 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; |
| 524 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 525 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 526 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 527 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 528 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 529 | {return __x + __y;} |
| 530 | }; |
| 531 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 532 | #if _LIBCPP_STD_VER > 11 |
| 533 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 534 | struct _LIBCPP_TEMPLATE_VIS plus<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 535 | { |
| 536 | template <class _T1, class _T2> |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 537 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 538 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 539 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) |
| 540 | -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) |
| 541 | { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 542 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 543 | }; |
| 544 | #endif |
| 545 | |
| 546 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 547 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 548 | #if _LIBCPP_STD_VER > 11 |
| 549 | template <class _Tp = void> |
| 550 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 551 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 552 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 553 | struct _LIBCPP_TEMPLATE_VIS minus |
| 554 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 555 | : binary_function<_Tp, _Tp, _Tp> |
| 556 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 557 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 558 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 559 | typedef _Tp __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 560 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 561 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; |
| 562 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 563 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 564 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 565 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 566 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 567 | {return __x - __y;} |
| 568 | }; |
| 569 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 570 | #if _LIBCPP_STD_VER > 11 |
| 571 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 572 | struct _LIBCPP_TEMPLATE_VIS minus<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 573 | { |
| 574 | template <class _T1, class _T2> |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 575 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 576 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 577 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) |
| 578 | -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) |
| 579 | { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 580 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 581 | }; |
| 582 | #endif |
| 583 | |
| 584 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 585 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 586 | #if _LIBCPP_STD_VER > 11 |
| 587 | template <class _Tp = void> |
| 588 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 589 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 590 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 591 | struct _LIBCPP_TEMPLATE_VIS multiplies |
| 592 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 593 | : binary_function<_Tp, _Tp, _Tp> |
| 594 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 595 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 596 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 597 | typedef _Tp __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 598 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 599 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; |
| 600 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 601 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 602 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 603 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 604 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 605 | {return __x * __y;} |
| 606 | }; |
| 607 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 608 | #if _LIBCPP_STD_VER > 11 |
| 609 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 610 | struct _LIBCPP_TEMPLATE_VIS multiplies<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 611 | { |
| 612 | template <class _T1, class _T2> |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 613 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 614 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 615 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) |
| 616 | -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) |
| 617 | { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 618 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 619 | }; |
| 620 | #endif |
| 621 | |
| 622 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 623 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 624 | #if _LIBCPP_STD_VER > 11 |
| 625 | template <class _Tp = void> |
| 626 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 627 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 628 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 629 | struct _LIBCPP_TEMPLATE_VIS divides |
| 630 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 631 | : binary_function<_Tp, _Tp, _Tp> |
| 632 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 633 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 634 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 635 | typedef _Tp __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 636 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 637 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; |
| 638 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 639 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 640 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 641 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 642 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 643 | {return __x / __y;} |
| 644 | }; |
| 645 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 646 | #if _LIBCPP_STD_VER > 11 |
| 647 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 648 | struct _LIBCPP_TEMPLATE_VIS divides<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 649 | { |
| 650 | template <class _T1, class _T2> |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 651 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 652 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 653 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) |
| 654 | -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) |
| 655 | { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 656 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 657 | }; |
| 658 | #endif |
| 659 | |
| 660 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 661 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 662 | #if _LIBCPP_STD_VER > 11 |
| 663 | template <class _Tp = void> |
| 664 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 665 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 666 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 667 | struct _LIBCPP_TEMPLATE_VIS modulus |
| 668 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 669 | : binary_function<_Tp, _Tp, _Tp> |
| 670 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 671 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 672 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 673 | typedef _Tp __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 674 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 675 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; |
| 676 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 677 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 678 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 679 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 680 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 681 | {return __x % __y;} |
| 682 | }; |
| 683 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 684 | #if _LIBCPP_STD_VER > 11 |
| 685 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 686 | struct _LIBCPP_TEMPLATE_VIS modulus<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 687 | { |
| 688 | template <class _T1, class _T2> |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 689 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 690 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 691 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) |
| 692 | -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) |
| 693 | { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 694 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 695 | }; |
| 696 | #endif |
| 697 | |
| 698 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 699 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 700 | #if _LIBCPP_STD_VER > 11 |
| 701 | template <class _Tp = void> |
| 702 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 703 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 704 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 705 | struct _LIBCPP_TEMPLATE_VIS negate |
| 706 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 707 | : unary_function<_Tp, _Tp> |
| 708 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 709 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 710 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 711 | typedef _Tp __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 712 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 713 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; |
| 714 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; |
| 715 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 716 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 717 | _Tp operator()(const _Tp& __x) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 718 | {return -__x;} |
| 719 | }; |
| 720 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 721 | #if _LIBCPP_STD_VER > 11 |
| 722 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 723 | struct _LIBCPP_TEMPLATE_VIS negate<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 724 | { |
| 725 | template <class _Tp> |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 726 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 727 | auto operator()(_Tp&& __x) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 728 | _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x))) |
| 729 | -> decltype (- _VSTD::forward<_Tp>(__x)) |
| 730 | { return - _VSTD::forward<_Tp>(__x); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 731 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 732 | }; |
| 733 | #endif |
| 734 | |
| 735 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 736 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 737 | #if _LIBCPP_STD_VER > 11 |
| 738 | template <class _Tp = void> |
| 739 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 740 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 741 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 742 | struct _LIBCPP_TEMPLATE_VIS equal_to |
| 743 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 744 | : binary_function<_Tp, _Tp, bool> |
| 745 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 746 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 747 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 748 | typedef bool __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 749 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 750 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; |
| 751 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 752 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 753 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 754 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 755 | bool operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 756 | {return __x == __y;} |
| 757 | }; |
| 758 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 759 | #if _LIBCPP_STD_VER > 11 |
| 760 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 761 | struct _LIBCPP_TEMPLATE_VIS equal_to<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 762 | { |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 763 | template <class _T1, class _T2> |
| 764 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 765 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 766 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) |
| 767 | -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) |
| 768 | { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 769 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 770 | }; |
| 771 | #endif |
| 772 | |
| 773 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 774 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 775 | #if _LIBCPP_STD_VER > 11 |
| 776 | template <class _Tp = void> |
| 777 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 778 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 779 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 780 | struct _LIBCPP_TEMPLATE_VIS not_equal_to |
| 781 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 782 | : binary_function<_Tp, _Tp, bool> |
| 783 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 784 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 785 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 786 | typedef bool __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 787 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 788 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; |
| 789 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 790 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 791 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 792 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 793 | bool operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 794 | {return __x != __y;} |
| 795 | }; |
| 796 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 797 | #if _LIBCPP_STD_VER > 11 |
| 798 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 799 | struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 800 | { |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 801 | template <class _T1, class _T2> |
| 802 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 803 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 804 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) |
| 805 | -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) |
| 806 | { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 807 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 808 | }; |
| 809 | #endif |
| 810 | |
| 811 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 812 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 813 | #if _LIBCPP_STD_VER > 11 |
| 814 | template <class _Tp = void> |
| 815 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 816 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 817 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 818 | struct _LIBCPP_TEMPLATE_VIS greater |
| 819 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 820 | : binary_function<_Tp, _Tp, bool> |
| 821 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 822 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 823 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 824 | typedef bool __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 825 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 826 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; |
| 827 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 828 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 829 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 830 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 831 | bool operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 832 | {return __x > __y;} |
| 833 | }; |
| 834 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 835 | #if _LIBCPP_STD_VER > 11 |
| 836 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 837 | struct _LIBCPP_TEMPLATE_VIS greater<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 838 | { |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 839 | template <class _T1, class _T2> |
| 840 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 841 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 842 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) |
| 843 | -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) |
| 844 | { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 845 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 846 | }; |
| 847 | #endif |
| 848 | |
| 849 | |
Howard Hinnant | b17caf9 | 2012-02-21 21:02:58 +0000 | [diff] [blame] | 850 | // less in <__functional_base> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 851 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 852 | |
| 853 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 854 | #if _LIBCPP_STD_VER > 11 |
| 855 | template <class _Tp = void> |
| 856 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 857 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 858 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 859 | struct _LIBCPP_TEMPLATE_VIS greater_equal |
| 860 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 861 | : binary_function<_Tp, _Tp, bool> |
| 862 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 863 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 864 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 865 | typedef bool __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 866 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 867 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; |
| 868 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 869 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 870 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 871 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 872 | bool operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 873 | {return __x >= __y;} |
| 874 | }; |
| 875 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 876 | #if _LIBCPP_STD_VER > 11 |
| 877 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 878 | struct _LIBCPP_TEMPLATE_VIS greater_equal<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 879 | { |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 880 | template <class _T1, class _T2> |
| 881 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 882 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 883 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) |
| 884 | -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) |
| 885 | { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 886 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 887 | }; |
| 888 | #endif |
| 889 | |
| 890 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 891 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 892 | #if _LIBCPP_STD_VER > 11 |
| 893 | template <class _Tp = void> |
| 894 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 895 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 896 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 897 | struct _LIBCPP_TEMPLATE_VIS less_equal |
| 898 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 899 | : binary_function<_Tp, _Tp, bool> |
| 900 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 901 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 902 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 903 | typedef bool __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 904 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 905 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; |
| 906 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 907 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 908 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 909 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 910 | bool operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 911 | {return __x <= __y;} |
| 912 | }; |
| 913 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 914 | #if _LIBCPP_STD_VER > 11 |
| 915 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 916 | struct _LIBCPP_TEMPLATE_VIS less_equal<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 917 | { |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 918 | template <class _T1, class _T2> |
| 919 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 920 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 921 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) |
| 922 | -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) |
| 923 | { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 924 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 925 | }; |
| 926 | #endif |
| 927 | |
| 928 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 929 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 930 | #if _LIBCPP_STD_VER > 11 |
| 931 | template <class _Tp = void> |
| 932 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 933 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 934 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 935 | struct _LIBCPP_TEMPLATE_VIS logical_and |
| 936 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 937 | : binary_function<_Tp, _Tp, bool> |
| 938 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 939 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 940 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 941 | typedef bool __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 942 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 943 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; |
| 944 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 945 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 946 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 947 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 948 | bool operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 949 | {return __x && __y;} |
| 950 | }; |
| 951 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 952 | #if _LIBCPP_STD_VER > 11 |
| 953 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 954 | struct _LIBCPP_TEMPLATE_VIS logical_and<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 955 | { |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 956 | template <class _T1, class _T2> |
| 957 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 958 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 959 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) |
| 960 | -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) |
| 961 | { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 962 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 963 | }; |
| 964 | #endif |
| 965 | |
| 966 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 967 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 968 | #if _LIBCPP_STD_VER > 11 |
| 969 | template <class _Tp = void> |
| 970 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 971 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 972 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 973 | struct _LIBCPP_TEMPLATE_VIS logical_or |
| 974 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 975 | : binary_function<_Tp, _Tp, bool> |
| 976 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 977 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 978 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 979 | typedef bool __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 980 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 981 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; |
| 982 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 983 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 984 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 985 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 986 | bool operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 987 | {return __x || __y;} |
| 988 | }; |
| 989 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 990 | #if _LIBCPP_STD_VER > 11 |
| 991 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 992 | struct _LIBCPP_TEMPLATE_VIS logical_or<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 993 | { |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 994 | template <class _T1, class _T2> |
| 995 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 996 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 997 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) |
| 998 | -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) |
| 999 | { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1000 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1001 | }; |
| 1002 | #endif |
| 1003 | |
| 1004 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1005 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1006 | #if _LIBCPP_STD_VER > 11 |
| 1007 | template <class _Tp = void> |
| 1008 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1009 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1010 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1011 | struct _LIBCPP_TEMPLATE_VIS logical_not |
| 1012 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 1013 | : unary_function<_Tp, bool> |
| 1014 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1015 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1016 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1017 | typedef bool __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1018 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 1019 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; |
| 1020 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; |
| 1021 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1022 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 1023 | bool operator()(const _Tp& __x) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1024 | {return !__x;} |
| 1025 | }; |
| 1026 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1027 | #if _LIBCPP_STD_VER > 11 |
| 1028 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1029 | struct _LIBCPP_TEMPLATE_VIS logical_not<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1030 | { |
| 1031 | template <class _Tp> |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1032 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 1033 | auto operator()(_Tp&& __x) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 1034 | _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x))) |
| 1035 | -> decltype (!_VSTD::forward<_Tp>(__x)) |
| 1036 | { return !_VSTD::forward<_Tp>(__x); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1037 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1038 | }; |
| 1039 | #endif |
| 1040 | |
| 1041 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1042 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1043 | #if _LIBCPP_STD_VER > 11 |
| 1044 | template <class _Tp = void> |
| 1045 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1046 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1047 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1048 | struct _LIBCPP_TEMPLATE_VIS bit_and |
| 1049 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 1050 | : binary_function<_Tp, _Tp, _Tp> |
| 1051 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1052 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1053 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1054 | typedef _Tp __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1055 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 1056 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; |
| 1057 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 1058 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 1059 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1060 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 1061 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1062 | {return __x & __y;} |
| 1063 | }; |
| 1064 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1065 | #if _LIBCPP_STD_VER > 11 |
| 1066 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1067 | struct _LIBCPP_TEMPLATE_VIS bit_and<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1068 | { |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1069 | template <class _T1, class _T2> |
| 1070 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1071 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 1072 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) |
| 1073 | -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) |
| 1074 | { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1075 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1076 | }; |
| 1077 | #endif |
| 1078 | |
| 1079 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1080 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1081 | #if _LIBCPP_STD_VER > 11 |
| 1082 | template <class _Tp = void> |
| 1083 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1084 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1085 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1086 | struct _LIBCPP_TEMPLATE_VIS bit_or |
| 1087 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 1088 | : binary_function<_Tp, _Tp, _Tp> |
| 1089 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1090 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1091 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1092 | typedef _Tp __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1093 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 1094 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; |
| 1095 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 1096 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 1097 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1098 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 1099 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1100 | {return __x | __y;} |
| 1101 | }; |
| 1102 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1103 | #if _LIBCPP_STD_VER > 11 |
| 1104 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1105 | struct _LIBCPP_TEMPLATE_VIS bit_or<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1106 | { |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1107 | template <class _T1, class _T2> |
| 1108 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1109 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 1110 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) |
| 1111 | -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) |
| 1112 | { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1113 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1114 | }; |
| 1115 | #endif |
| 1116 | |
| 1117 | |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1118 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1119 | #if _LIBCPP_STD_VER > 11 |
| 1120 | template <class _Tp = void> |
| 1121 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1122 | template <class _Tp> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1123 | #endif |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1124 | struct _LIBCPP_TEMPLATE_VIS bit_xor |
| 1125 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 1126 | : binary_function<_Tp, _Tp, _Tp> |
| 1127 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1128 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1129 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1130 | typedef _Tp __result_type; // used by valarray |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1131 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 1132 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; |
| 1133 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; |
| 1134 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; |
| 1135 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1136 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 1137 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1138 | {return __x ^ __y;} |
| 1139 | }; |
| 1140 | |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1141 | #if _LIBCPP_STD_VER > 11 |
| 1142 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1143 | struct _LIBCPP_TEMPLATE_VIS bit_xor<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1144 | { |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1145 | template <class _T1, class _T2> |
| 1146 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1147 | auto operator()(_T1&& __t, _T2&& __u) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 1148 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) |
| 1149 | -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) |
| 1150 | { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1151 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1152 | }; |
| 1153 | #endif |
| 1154 | |
| 1155 | |
| 1156 | #if _LIBCPP_STD_VER > 11 |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1157 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1158 | template <class _Tp = void> |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1159 | struct _LIBCPP_TEMPLATE_VIS bit_not |
| 1160 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
| 1161 | : unary_function<_Tp, _Tp> |
| 1162 | #endif |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1163 | { |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1164 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 1165 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 1166 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; |
| 1167 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; |
| 1168 | #endif |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1169 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 1170 | _Tp operator()(const _Tp& __x) const |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1171 | {return ~__x;} |
| 1172 | }; |
| 1173 | |
| 1174 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1175 | struct _LIBCPP_TEMPLATE_VIS bit_not<void> |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1176 | { |
| 1177 | template <class _Tp> |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1178 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 1179 | auto operator()(_Tp&& __x) const |
Marshall Clow | 012ca34 | 2015-02-25 12:20:52 +0000 | [diff] [blame] | 1180 | _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x))) |
| 1181 | -> decltype (~_VSTD::forward<_Tp>(__x)) |
| 1182 | { return ~_VSTD::forward<_Tp>(__x); } |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1183 | typedef void is_transparent; |
Marshall Clow | 974bae2 | 2013-07-29 14:21:53 +0000 | [diff] [blame] | 1184 | }; |
| 1185 | #endif |
| 1186 | |
Arthur O'Dwyer | a6b5107 | 2021-05-24 18:36:17 -0400 | [diff] [blame] | 1187 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1188 | template <class _Predicate> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1189 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1190 | : public unary_function<typename _Predicate::argument_type, bool> |
| 1191 | { |
| 1192 | _Predicate __pred_; |
| 1193 | public: |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1194 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 1195 | explicit unary_negate(const _Predicate& __pred) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1196 | : __pred_(__pred) {} |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1197 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 1198 | bool operator()(const typename _Predicate::argument_type& __x) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1199 | {return !__pred_(__x);} |
| 1200 | }; |
| 1201 | |
| 1202 | template <class _Predicate> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1203 | _LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1204 | unary_negate<_Predicate> |
| 1205 | not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} |
| 1206 | |
| 1207 | template <class _Predicate> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1208 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1209 | : public binary_function<typename _Predicate::first_argument_type, |
| 1210 | typename _Predicate::second_argument_type, |
| 1211 | bool> |
| 1212 | { |
| 1213 | _Predicate __pred_; |
| 1214 | public: |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 1215 | _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Marshall Clow | d18ee65 | 2013-09-28 19:06:12 +0000 | [diff] [blame] | 1216 | binary_negate(const _Predicate& __pred) : __pred_(__pred) {} |
| 1217 | |
| 1218 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 1219 | bool operator()(const typename _Predicate::first_argument_type& __x, |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1220 | const typename _Predicate::second_argument_type& __y) const |
| 1221 | {return !__pred_(__x, __y);} |
| 1222 | }; |
| 1223 | |
| 1224 | template <class _Predicate> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1225 | _LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1226 | binary_negate<_Predicate> |
| 1227 | not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} |
Arthur O'Dwyer | a6b5107 | 2021-05-24 18:36:17 -0400 | [diff] [blame] | 1228 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1229 | |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 1230 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1231 | template <class __Operation> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1232 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1233 | : public unary_function<typename __Operation::second_argument_type, |
| 1234 | typename __Operation::result_type> |
| 1235 | { |
| 1236 | protected: |
| 1237 | __Operation op; |
| 1238 | typename __Operation::first_argument_type value; |
| 1239 | public: |
| 1240 | _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, |
| 1241 | const typename __Operation::first_argument_type __y) |
| 1242 | : op(__x), value(__y) {} |
| 1243 | _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() |
| 1244 | (typename __Operation::second_argument_type& __x) const |
| 1245 | {return op(value, __x);} |
| 1246 | _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() |
| 1247 | (const typename __Operation::second_argument_type& __x) const |
| 1248 | {return op(value, __x);} |
| 1249 | }; |
| 1250 | |
| 1251 | template <class __Operation, class _Tp> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1252 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1253 | binder1st<__Operation> |
| 1254 | bind1st(const __Operation& __op, const _Tp& __x) |
| 1255 | {return binder1st<__Operation>(__op, __x);} |
| 1256 | |
| 1257 | template <class __Operation> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1258 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1259 | : public unary_function<typename __Operation::first_argument_type, |
| 1260 | typename __Operation::result_type> |
| 1261 | { |
| 1262 | protected: |
| 1263 | __Operation op; |
| 1264 | typename __Operation::second_argument_type value; |
| 1265 | public: |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 1266 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1267 | binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) |
| 1268 | : op(__x), value(__y) {} |
| 1269 | _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() |
| 1270 | ( typename __Operation::first_argument_type& __x) const |
| 1271 | {return op(__x, value);} |
| 1272 | _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() |
| 1273 | (const typename __Operation::first_argument_type& __x) const |
| 1274 | {return op(__x, value);} |
| 1275 | }; |
| 1276 | |
| 1277 | template <class __Operation, class _Tp> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1278 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1279 | binder2nd<__Operation> |
| 1280 | bind2nd(const __Operation& __op, const _Tp& __x) |
| 1281 | {return binder2nd<__Operation>(__op, __x);} |
| 1282 | |
| 1283 | template <class _Arg, class _Result> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1284 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 1285 | : public unary_function<_Arg, _Result> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1286 | { |
| 1287 | _Result (*__f_)(_Arg); |
| 1288 | public: |
| 1289 | _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg)) |
| 1290 | : __f_(__f) {} |
| 1291 | _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const |
| 1292 | {return __f_(__x);} |
| 1293 | }; |
| 1294 | |
| 1295 | template <class _Arg, class _Result> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1296 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1297 | pointer_to_unary_function<_Arg,_Result> |
| 1298 | ptr_fun(_Result (*__f)(_Arg)) |
| 1299 | {return pointer_to_unary_function<_Arg,_Result>(__f);} |
| 1300 | |
| 1301 | template <class _Arg1, class _Arg2, class _Result> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1302 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 1303 | : public binary_function<_Arg1, _Arg2, _Result> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1304 | { |
| 1305 | _Result (*__f_)(_Arg1, _Arg2); |
| 1306 | public: |
| 1307 | _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) |
| 1308 | : __f_(__f) {} |
| 1309 | _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const |
| 1310 | {return __f_(__x, __y);} |
| 1311 | }; |
| 1312 | |
| 1313 | template <class _Arg1, class _Arg2, class _Result> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1314 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1315 | pointer_to_binary_function<_Arg1,_Arg2,_Result> |
| 1316 | ptr_fun(_Result (*__f)(_Arg1,_Arg2)) |
| 1317 | {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} |
| 1318 | |
| 1319 | template<class _Sp, class _Tp> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1320 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t |
| 1321 | : public unary_function<_Tp*, _Sp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1322 | { |
| 1323 | _Sp (_Tp::*__p_)(); |
| 1324 | public: |
| 1325 | _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)()) |
| 1326 | : __p_(__p) {} |
| 1327 | _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const |
| 1328 | {return (__p->*__p_)();} |
| 1329 | }; |
| 1330 | |
| 1331 | template<class _Sp, class _Tp, class _Ap> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1332 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t |
| 1333 | : public binary_function<_Tp*, _Ap, _Sp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1334 | { |
| 1335 | _Sp (_Tp::*__p_)(_Ap); |
| 1336 | public: |
| 1337 | _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) |
| 1338 | : __p_(__p) {} |
| 1339 | _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const |
| 1340 | {return (__p->*__p_)(__x);} |
| 1341 | }; |
| 1342 | |
| 1343 | template<class _Sp, class _Tp> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1344 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1345 | mem_fun_t<_Sp,_Tp> |
| 1346 | mem_fun(_Sp (_Tp::*__f)()) |
| 1347 | {return mem_fun_t<_Sp,_Tp>(__f);} |
| 1348 | |
| 1349 | template<class _Sp, class _Tp, class _Ap> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1350 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1351 | mem_fun1_t<_Sp,_Tp,_Ap> |
| 1352 | mem_fun(_Sp (_Tp::*__f)(_Ap)) |
| 1353 | {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} |
| 1354 | |
| 1355 | template<class _Sp, class _Tp> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1356 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t |
| 1357 | : public unary_function<_Tp, _Sp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1358 | { |
| 1359 | _Sp (_Tp::*__p_)(); |
| 1360 | public: |
| 1361 | _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) |
| 1362 | : __p_(__p) {} |
| 1363 | _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const |
| 1364 | {return (__p.*__p_)();} |
| 1365 | }; |
| 1366 | |
| 1367 | template<class _Sp, class _Tp, class _Ap> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1368 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t |
| 1369 | : public binary_function<_Tp, _Ap, _Sp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1370 | { |
| 1371 | _Sp (_Tp::*__p_)(_Ap); |
| 1372 | public: |
| 1373 | _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) |
| 1374 | : __p_(__p) {} |
| 1375 | _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const |
| 1376 | {return (__p.*__p_)(__x);} |
| 1377 | }; |
| 1378 | |
| 1379 | template<class _Sp, class _Tp> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1380 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1381 | mem_fun_ref_t<_Sp,_Tp> |
| 1382 | mem_fun_ref(_Sp (_Tp::*__f)()) |
| 1383 | {return mem_fun_ref_t<_Sp,_Tp>(__f);} |
| 1384 | |
| 1385 | template<class _Sp, class _Tp, class _Ap> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1386 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1387 | mem_fun1_ref_t<_Sp,_Tp,_Ap> |
| 1388 | mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) |
| 1389 | {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} |
| 1390 | |
| 1391 | template <class _Sp, class _Tp> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1392 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t |
| 1393 | : public unary_function<const _Tp*, _Sp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1394 | { |
| 1395 | _Sp (_Tp::*__p_)() const; |
| 1396 | public: |
| 1397 | _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) |
| 1398 | : __p_(__p) {} |
| 1399 | _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const |
| 1400 | {return (__p->*__p_)();} |
| 1401 | }; |
| 1402 | |
| 1403 | template <class _Sp, class _Tp, class _Ap> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1404 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t |
| 1405 | : public binary_function<const _Tp*, _Ap, _Sp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1406 | { |
| 1407 | _Sp (_Tp::*__p_)(_Ap) const; |
| 1408 | public: |
| 1409 | _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) |
| 1410 | : __p_(__p) {} |
| 1411 | _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const |
| 1412 | {return (__p->*__p_)(__x);} |
| 1413 | }; |
| 1414 | |
| 1415 | template <class _Sp, class _Tp> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1416 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1417 | const_mem_fun_t<_Sp,_Tp> |
| 1418 | mem_fun(_Sp (_Tp::*__f)() const) |
| 1419 | {return const_mem_fun_t<_Sp,_Tp>(__f);} |
| 1420 | |
| 1421 | template <class _Sp, class _Tp, class _Ap> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1422 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1423 | const_mem_fun1_t<_Sp,_Tp,_Ap> |
| 1424 | mem_fun(_Sp (_Tp::*__f)(_Ap) const) |
| 1425 | {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} |
| 1426 | |
| 1427 | template <class _Sp, class _Tp> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1428 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t |
| 1429 | : public unary_function<_Tp, _Sp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1430 | { |
| 1431 | _Sp (_Tp::*__p_)() const; |
| 1432 | public: |
| 1433 | _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) |
| 1434 | : __p_(__p) {} |
| 1435 | _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const |
| 1436 | {return (__p.*__p_)();} |
| 1437 | }; |
| 1438 | |
| 1439 | template <class _Sp, class _Tp, class _Ap> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1440 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 1441 | : public binary_function<_Tp, _Ap, _Sp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1442 | { |
| 1443 | _Sp (_Tp::*__p_)(_Ap) const; |
| 1444 | public: |
| 1445 | _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) |
| 1446 | : __p_(__p) {} |
| 1447 | _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const |
| 1448 | {return (__p.*__p_)(__x);} |
| 1449 | }; |
| 1450 | |
| 1451 | template <class _Sp, class _Tp> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1452 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1453 | const_mem_fun_ref_t<_Sp,_Tp> |
| 1454 | mem_fun_ref(_Sp (_Tp::*__f)() const) |
| 1455 | {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} |
| 1456 | |
| 1457 | template <class _Sp, class _Tp, class _Ap> |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 1458 | _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1459 | const_mem_fun1_ref_t<_Sp,_Tp,_Ap> |
| 1460 | mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) |
| 1461 | {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} |
Marshall Clow | 26a027c | 2017-04-13 18:25:32 +0000 | [diff] [blame] | 1462 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1463 | |
Eric Fiselier | a6f61c6 | 2015-07-22 04:14:38 +0000 | [diff] [blame] | 1464 | //////////////////////////////////////////////////////////////////////////////// |
| 1465 | // MEMFUN |
| 1466 | //============================================================================== |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1467 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1468 | template <class _Tp> |
| 1469 | class __mem_fn |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1470 | #if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1471 | : public __weak_result_type<_Tp> |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1472 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1473 | { |
| 1474 | public: |
| 1475 | // types |
| 1476 | typedef _Tp type; |
| 1477 | private: |
| 1478 | type __f_; |
| 1479 | |
| 1480 | public: |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 1481 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1482 | __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1483 | |
Eric Fiselier | a9ae7a6 | 2017-04-19 01:28:47 +0000 | [diff] [blame] | 1484 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1485 | // invoke |
| 1486 | template <class... _ArgTypes> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 1487 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1488 | typename __invoke_return<type, _ArgTypes...>::type |
| 1489 | operator() (_ArgTypes&&... __args) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1490 | return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1491 | } |
| 1492 | #else |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1493 | |
| 1494 | template <class _A0> |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1495 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1496 | typename __invoke_return0<type, _A0>::type |
| 1497 | operator() (_A0& __a0) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1498 | return _VSTD::__invoke(__f_, __a0); |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1499 | } |
| 1500 | |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1501 | template <class _A0> |
| 1502 | _LIBCPP_INLINE_VISIBILITY |
| 1503 | typename __invoke_return0<type, _A0 const>::type |
| 1504 | operator() (_A0 const& __a0) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1505 | return _VSTD::__invoke(__f_, __a0); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1506 | } |
| 1507 | |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1508 | template <class _A0, class _A1> |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1509 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1510 | typename __invoke_return1<type, _A0, _A1>::type |
| 1511 | operator() (_A0& __a0, _A1& __a1) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1512 | return _VSTD::__invoke(__f_, __a0, __a1); |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1513 | } |
| 1514 | |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1515 | template <class _A0, class _A1> |
| 1516 | _LIBCPP_INLINE_VISIBILITY |
| 1517 | typename __invoke_return1<type, _A0 const, _A1>::type |
| 1518 | operator() (_A0 const& __a0, _A1& __a1) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1519 | return _VSTD::__invoke(__f_, __a0, __a1); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1520 | } |
| 1521 | |
| 1522 | template <class _A0, class _A1> |
| 1523 | _LIBCPP_INLINE_VISIBILITY |
| 1524 | typename __invoke_return1<type, _A0, _A1 const>::type |
| 1525 | operator() (_A0& __a0, _A1 const& __a1) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1526 | return _VSTD::__invoke(__f_, __a0, __a1); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1527 | } |
| 1528 | |
| 1529 | template <class _A0, class _A1> |
| 1530 | _LIBCPP_INLINE_VISIBILITY |
| 1531 | typename __invoke_return1<type, _A0 const, _A1 const>::type |
| 1532 | operator() (_A0 const& __a0, _A1 const& __a1) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1533 | return _VSTD::__invoke(__f_, __a0, __a1); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1534 | } |
| 1535 | |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1536 | template <class _A0, class _A1, class _A2> |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1537 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1538 | typename __invoke_return2<type, _A0, _A1, _A2>::type |
| 1539 | operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1540 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1541 | } |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1542 | |
| 1543 | template <class _A0, class _A1, class _A2> |
| 1544 | _LIBCPP_INLINE_VISIBILITY |
| 1545 | typename __invoke_return2<type, _A0 const, _A1, _A2>::type |
| 1546 | operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1547 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1548 | } |
| 1549 | |
| 1550 | template <class _A0, class _A1, class _A2> |
| 1551 | _LIBCPP_INLINE_VISIBILITY |
| 1552 | typename __invoke_return2<type, _A0, _A1 const, _A2>::type |
| 1553 | operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1554 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1555 | } |
| 1556 | |
| 1557 | template <class _A0, class _A1, class _A2> |
| 1558 | _LIBCPP_INLINE_VISIBILITY |
| 1559 | typename __invoke_return2<type, _A0, _A1, _A2 const>::type |
| 1560 | operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1561 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1562 | } |
| 1563 | |
| 1564 | template <class _A0, class _A1, class _A2> |
| 1565 | _LIBCPP_INLINE_VISIBILITY |
| 1566 | typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type |
| 1567 | operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1568 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1569 | } |
| 1570 | |
| 1571 | template <class _A0, class _A1, class _A2> |
| 1572 | _LIBCPP_INLINE_VISIBILITY |
| 1573 | typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type |
| 1574 | operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1575 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1576 | } |
| 1577 | |
| 1578 | template <class _A0, class _A1, class _A2> |
| 1579 | _LIBCPP_INLINE_VISIBILITY |
| 1580 | typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type |
| 1581 | operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1582 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1583 | } |
| 1584 | |
| 1585 | template <class _A0, class _A1, class _A2> |
| 1586 | _LIBCPP_INLINE_VISIBILITY |
| 1587 | typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type |
| 1588 | operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 1589 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); |
Eric Fiselier | ce1813a | 2015-08-26 20:15:02 +0000 | [diff] [blame] | 1590 | } |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 1591 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1592 | }; |
| 1593 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1594 | template<class _Rp, class _Tp> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 1595 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1596 | __mem_fn<_Rp _Tp::*> |
Marshall Clow | ad8ff21 | 2015-10-25 20:12:16 +0000 | [diff] [blame] | 1597 | mem_fn(_Rp _Tp::* __pm) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1598 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1599 | return __mem_fn<_Rp _Tp::*>(__pm); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1600 | } |
| 1601 | |
Eric Fiselier | a6f61c6 | 2015-07-22 04:14:38 +0000 | [diff] [blame] | 1602 | //////////////////////////////////////////////////////////////////////////////// |
| 1603 | // FUNCTION |
| 1604 | //============================================================================== |
| 1605 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1606 | // bad_function_call |
| 1607 | |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 1608 | class _LIBCPP_EXCEPTION_ABI bad_function_call |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1609 | : public exception |
| 1610 | { |
Shoaib Meenai | c130eaf | 2017-03-28 19:33:31 +0000 | [diff] [blame] | 1611 | #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION |
| 1612 | public: |
| 1613 | virtual ~bad_function_call() _NOEXCEPT; |
| 1614 | |
| 1615 | virtual const char* what() const _NOEXCEPT; |
| 1616 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1617 | }; |
| 1618 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 1619 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 1620 | void __throw_bad_function_call() |
| 1621 | { |
| 1622 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1623 | throw bad_function_call(); |
| 1624 | #else |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 1625 | _VSTD::abort(); |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 1626 | #endif |
| 1627 | } |
| 1628 | |
Louis Dionne | 44d1f81 | 2020-03-09 11:16:22 -0400 | [diff] [blame] | 1629 | #if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && __has_attribute(deprecated) |
| 1630 | # define _LIBCPP_DEPRECATED_CXX03_FUNCTION \ |
| 1631 | __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type"))) |
| 1632 | #else |
| 1633 | # define _LIBCPP_DEPRECATED_CXX03_FUNCTION /* nothing */ |
| 1634 | #endif |
| 1635 | |
| 1636 | template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1637 | |
| 1638 | namespace __function |
| 1639 | { |
| 1640 | |
Eric Fiselier | a6f61c6 | 2015-07-22 04:14:38 +0000 | [diff] [blame] | 1641 | template<class _Rp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1642 | struct __maybe_derive_from_unary_function |
| 1643 | { |
| 1644 | }; |
| 1645 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1646 | template<class _Rp, class _A1> |
| 1647 | struct __maybe_derive_from_unary_function<_Rp(_A1)> |
| 1648 | : public unary_function<_A1, _Rp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1649 | { |
| 1650 | }; |
| 1651 | |
Eric Fiselier | a6f61c6 | 2015-07-22 04:14:38 +0000 | [diff] [blame] | 1652 | template<class _Rp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1653 | struct __maybe_derive_from_binary_function |
| 1654 | { |
| 1655 | }; |
| 1656 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1657 | template<class _Rp, class _A1, class _A2> |
| 1658 | struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> |
| 1659 | : public binary_function<_A1, _A2, _Rp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1660 | { |
| 1661 | }; |
| 1662 | |
Eric Fiselier | a584a1e | 2015-08-18 19:41:51 +0000 | [diff] [blame] | 1663 | template <class _Fp> |
| 1664 | _LIBCPP_INLINE_VISIBILITY |
| 1665 | bool __not_null(_Fp const&) { return true; } |
| 1666 | |
| 1667 | template <class _Fp> |
| 1668 | _LIBCPP_INLINE_VISIBILITY |
| 1669 | bool __not_null(_Fp* __ptr) { return __ptr; } |
| 1670 | |
| 1671 | template <class _Ret, class _Class> |
| 1672 | _LIBCPP_INLINE_VISIBILITY |
| 1673 | bool __not_null(_Ret _Class::*__ptr) { return __ptr; } |
| 1674 | |
| 1675 | template <class _Fp> |
| 1676 | _LIBCPP_INLINE_VISIBILITY |
| 1677 | bool __not_null(function<_Fp> const& __f) { return !!__f; } |
| 1678 | |
Louis Dionne | e2391d7 | 2020-04-22 13:58:17 -0400 | [diff] [blame] | 1679 | #ifdef _LIBCPP_HAS_EXTENSION_BLOCKS |
| 1680 | template <class _Rp, class ..._Args> |
| 1681 | _LIBCPP_INLINE_VISIBILITY |
| 1682 | bool __not_null(_Rp (^__p)(_Args...)) { return __p; } |
| 1683 | #endif |
| 1684 | |
Eric Fiselier | a6f61c6 | 2015-07-22 04:14:38 +0000 | [diff] [blame] | 1685 | } // namespace __function |
| 1686 | |
Eric Fiselier | a9ae7a6 | 2017-04-19 01:28:47 +0000 | [diff] [blame] | 1687 | #ifndef _LIBCPP_CXX03_LANG |
Eric Fiselier | a6f61c6 | 2015-07-22 04:14:38 +0000 | [diff] [blame] | 1688 | |
| 1689 | namespace __function { |
| 1690 | |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1691 | // __alloc_func holds a functor and an allocator. |
| 1692 | |
| 1693 | template <class _Fp, class _Ap, class _FB> class __alloc_func; |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 1694 | template <class _Fp, class _FB> |
| 1695 | class __default_alloc_func; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1696 | |
| 1697 | template <class _Fp, class _Ap, class _Rp, class... _ArgTypes> |
| 1698 | class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> |
| 1699 | { |
| 1700 | __compressed_pair<_Fp, _Ap> __f_; |
| 1701 | |
| 1702 | public: |
Eric Fiselier | 4fc82a2 | 2019-06-12 02:03:31 +0000 | [diff] [blame] | 1703 | typedef _LIBCPP_NODEBUG_TYPE _Fp _Target; |
| 1704 | typedef _LIBCPP_NODEBUG_TYPE _Ap _Alloc; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1705 | |
| 1706 | _LIBCPP_INLINE_VISIBILITY |
| 1707 | const _Target& __target() const { return __f_.first(); } |
| 1708 | |
Thomas Anderson | f88da8d | 2019-01-29 23:19:45 +0000 | [diff] [blame] | 1709 | // WIN32 APIs may define __allocator, so use __get_allocator instead. |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1710 | _LIBCPP_INLINE_VISIBILITY |
Thomas Anderson | f88da8d | 2019-01-29 23:19:45 +0000 | [diff] [blame] | 1711 | const _Alloc& __get_allocator() const { return __f_.second(); } |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1712 | |
| 1713 | _LIBCPP_INLINE_VISIBILITY |
| 1714 | explicit __alloc_func(_Target&& __f) |
| 1715 | : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), |
| 1716 | _VSTD::forward_as_tuple()) |
| 1717 | { |
| 1718 | } |
| 1719 | |
| 1720 | _LIBCPP_INLINE_VISIBILITY |
| 1721 | explicit __alloc_func(const _Target& __f, const _Alloc& __a) |
| 1722 | : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), |
| 1723 | _VSTD::forward_as_tuple(__a)) |
| 1724 | { |
| 1725 | } |
| 1726 | |
| 1727 | _LIBCPP_INLINE_VISIBILITY |
| 1728 | explicit __alloc_func(const _Target& __f, _Alloc&& __a) |
| 1729 | : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), |
| 1730 | _VSTD::forward_as_tuple(_VSTD::move(__a))) |
| 1731 | { |
| 1732 | } |
| 1733 | |
| 1734 | _LIBCPP_INLINE_VISIBILITY |
| 1735 | explicit __alloc_func(_Target&& __f, _Alloc&& __a) |
| 1736 | : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), |
| 1737 | _VSTD::forward_as_tuple(_VSTD::move(__a))) |
| 1738 | { |
| 1739 | } |
| 1740 | |
| 1741 | _LIBCPP_INLINE_VISIBILITY |
| 1742 | _Rp operator()(_ArgTypes&&... __arg) |
| 1743 | { |
| 1744 | typedef __invoke_void_return_wrapper<_Rp> _Invoker; |
| 1745 | return _Invoker::__call(__f_.first(), |
| 1746 | _VSTD::forward<_ArgTypes>(__arg)...); |
| 1747 | } |
| 1748 | |
| 1749 | _LIBCPP_INLINE_VISIBILITY |
| 1750 | __alloc_func* __clone() const |
| 1751 | { |
| 1752 | typedef allocator_traits<_Alloc> __alloc_traits; |
| 1753 | typedef |
| 1754 | typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type |
| 1755 | _AA; |
| 1756 | _AA __a(__f_.second()); |
| 1757 | typedef __allocator_destructor<_AA> _Dp; |
| 1758 | unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); |
| 1759 | ::new ((void*)__hold.get()) __alloc_func(__f_.first(), _Alloc(__a)); |
| 1760 | return __hold.release(); |
| 1761 | } |
| 1762 | |
| 1763 | _LIBCPP_INLINE_VISIBILITY |
| 1764 | void destroy() _NOEXCEPT { __f_.~__compressed_pair<_Target, _Alloc>(); } |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 1765 | |
| 1766 | static void __destroy_and_delete(__alloc_func* __f) { |
| 1767 | typedef allocator_traits<_Alloc> __alloc_traits; |
| 1768 | typedef typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type |
| 1769 | _FunAlloc; |
| 1770 | _FunAlloc __a(__f->__get_allocator()); |
| 1771 | __f->destroy(); |
| 1772 | __a.deallocate(__f, 1); |
| 1773 | } |
| 1774 | }; |
| 1775 | |
| 1776 | template <class _Fp, class _Rp, class... _ArgTypes> |
| 1777 | class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> { |
| 1778 | _Fp __f_; |
| 1779 | |
| 1780 | public: |
Eric Fiselier | 4fc82a2 | 2019-06-12 02:03:31 +0000 | [diff] [blame] | 1781 | typedef _LIBCPP_NODEBUG_TYPE _Fp _Target; |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 1782 | |
| 1783 | _LIBCPP_INLINE_VISIBILITY |
| 1784 | const _Target& __target() const { return __f_; } |
| 1785 | |
| 1786 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 07b2249 | 2020-11-27 11:02:06 -0500 | [diff] [blame] | 1787 | explicit __default_alloc_func(_Target&& __f) : __f_(_VSTD::move(__f)) {} |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 1788 | |
| 1789 | _LIBCPP_INLINE_VISIBILITY |
| 1790 | explicit __default_alloc_func(const _Target& __f) : __f_(__f) {} |
| 1791 | |
| 1792 | _LIBCPP_INLINE_VISIBILITY |
| 1793 | _Rp operator()(_ArgTypes&&... __arg) { |
| 1794 | typedef __invoke_void_return_wrapper<_Rp> _Invoker; |
| 1795 | return _Invoker::__call(__f_, _VSTD::forward<_ArgTypes>(__arg)...); |
| 1796 | } |
| 1797 | |
| 1798 | _LIBCPP_INLINE_VISIBILITY |
| 1799 | __default_alloc_func* __clone() const { |
| 1800 | __builtin_new_allocator::__holder_t __hold = |
| 1801 | __builtin_new_allocator::__allocate_type<__default_alloc_func>(1); |
| 1802 | __default_alloc_func* __res = |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 1803 | ::new ((void*)__hold.get()) __default_alloc_func(__f_); |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 1804 | (void)__hold.release(); |
| 1805 | return __res; |
| 1806 | } |
| 1807 | |
| 1808 | _LIBCPP_INLINE_VISIBILITY |
| 1809 | void destroy() _NOEXCEPT { __f_.~_Target(); } |
| 1810 | |
| 1811 | static void __destroy_and_delete(__default_alloc_func* __f) { |
| 1812 | __f->destroy(); |
| 1813 | __builtin_new_allocator::__deallocate_type<__default_alloc_func>(__f, 1); |
| 1814 | } |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1815 | }; |
| 1816 | |
| 1817 | // __base provides an abstract interface for copyable functors. |
| 1818 | |
Yunlian Jiang | 06c6f27 | 2020-03-18 17:06:18 -0400 | [diff] [blame] | 1819 | template<class _Fp> class _LIBCPP_TEMPLATE_VIS __base; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1820 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1821 | template<class _Rp, class ..._ArgTypes> |
| 1822 | class __base<_Rp(_ArgTypes...)> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1823 | { |
| 1824 | __base(const __base&); |
| 1825 | __base& operator=(const __base&); |
| 1826 | public: |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 1827 | _LIBCPP_INLINE_VISIBILITY __base() {} |
| 1828 | _LIBCPP_INLINE_VISIBILITY virtual ~__base() {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1829 | virtual __base* __clone() const = 0; |
| 1830 | virtual void __clone(__base*) const = 0; |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 1831 | virtual void destroy() _NOEXCEPT = 0; |
| 1832 | virtual void destroy_deallocate() _NOEXCEPT = 0; |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1833 | virtual _Rp operator()(_ArgTypes&& ...) = 0; |
Howard Hinnant | 72f7358 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 1834 | #ifndef _LIBCPP_NO_RTTI |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 1835 | virtual const void* target(const type_info&) const _NOEXCEPT = 0; |
| 1836 | virtual const std::type_info& target_type() const _NOEXCEPT = 0; |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1837 | #endif // _LIBCPP_NO_RTTI |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1838 | }; |
| 1839 | |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1840 | // __func implements __base for a given functor type. |
| 1841 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1842 | template<class _FD, class _Alloc, class _FB> class __func; |
| 1843 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1844 | template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> |
| 1845 | class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> |
| 1846 | : public __base<_Rp(_ArgTypes...)> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1847 | { |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1848 | __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> __f_; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1849 | public: |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 1850 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 4828c4a | 2012-02-28 19:47:38 +0000 | [diff] [blame] | 1851 | explicit __func(_Fp&& __f) |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1852 | : __f_(_VSTD::move(__f)) {} |
| 1853 | |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 1854 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 4828c4a | 2012-02-28 19:47:38 +0000 | [diff] [blame] | 1855 | explicit __func(const _Fp& __f, const _Alloc& __a) |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1856 | : __f_(__f, __a) {} |
Howard Hinnant | 4828c4a | 2012-02-28 19:47:38 +0000 | [diff] [blame] | 1857 | |
| 1858 | _LIBCPP_INLINE_VISIBILITY |
| 1859 | explicit __func(const _Fp& __f, _Alloc&& __a) |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1860 | : __f_(__f, _VSTD::move(__a)) {} |
Howard Hinnant | 4828c4a | 2012-02-28 19:47:38 +0000 | [diff] [blame] | 1861 | |
| 1862 | _LIBCPP_INLINE_VISIBILITY |
| 1863 | explicit __func(_Fp&& __f, _Alloc&& __a) |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1864 | : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} |
| 1865 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1866 | virtual __base<_Rp(_ArgTypes...)>* __clone() const; |
| 1867 | virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 1868 | virtual void destroy() _NOEXCEPT; |
| 1869 | virtual void destroy_deallocate() _NOEXCEPT; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1870 | virtual _Rp operator()(_ArgTypes&&... __arg); |
Howard Hinnant | 72f7358 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 1871 | #ifndef _LIBCPP_NO_RTTI |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 1872 | virtual const void* target(const type_info&) const _NOEXCEPT; |
| 1873 | virtual const std::type_info& target_type() const _NOEXCEPT; |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1874 | #endif // _LIBCPP_NO_RTTI |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1875 | }; |
| 1876 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1877 | template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> |
| 1878 | __base<_Rp(_ArgTypes...)>* |
| 1879 | __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1880 | { |
Eric Fiselier | b5826ad | 2015-03-18 22:56:50 +0000 | [diff] [blame] | 1881 | typedef allocator_traits<_Alloc> __alloc_traits; |
Marshall Clow | 940e01c | 2015-04-07 05:21:38 +0000 | [diff] [blame] | 1882 | typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; |
Thomas Anderson | f88da8d | 2019-01-29 23:19:45 +0000 | [diff] [blame] | 1883 | _Ap __a(__f_.__get_allocator()); |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1884 | typedef __allocator_destructor<_Ap> _Dp; |
| 1885 | unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1886 | ::new ((void*)__hold.get()) __func(__f_.__target(), _Alloc(__a)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1887 | return __hold.release(); |
| 1888 | } |
| 1889 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1890 | template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1891 | void |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1892 | __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1893 | { |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 1894 | ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1895 | } |
| 1896 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1897 | template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1898 | void |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1899 | __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1900 | { |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1901 | __f_.destroy(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1902 | } |
| 1903 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1904 | template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1905 | void |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1906 | __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1907 | { |
Eric Fiselier | b5826ad | 2015-03-18 22:56:50 +0000 | [diff] [blame] | 1908 | typedef allocator_traits<_Alloc> __alloc_traits; |
Marshall Clow | 940e01c | 2015-04-07 05:21:38 +0000 | [diff] [blame] | 1909 | typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; |
Thomas Anderson | f88da8d | 2019-01-29 23:19:45 +0000 | [diff] [blame] | 1910 | _Ap __a(__f_.__get_allocator()); |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1911 | __f_.destroy(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1912 | __a.deallocate(this, 1); |
| 1913 | } |
| 1914 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1915 | template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> |
| 1916 | _Rp |
| 1917 | __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1918 | { |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1919 | return __f_(_VSTD::forward<_ArgTypes>(__arg)...); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1920 | } |
| 1921 | |
Howard Hinnant | 72f7358 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 1922 | #ifndef _LIBCPP_NO_RTTI |
| 1923 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1924 | template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1925 | const void* |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1926 | __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1927 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1928 | if (__ti == typeid(_Fp)) |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1929 | return &__f_.__target(); |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 1930 | return nullptr; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1931 | } |
| 1932 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1933 | template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1934 | const std::type_info& |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1935 | __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1936 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1937 | return typeid(_Fp); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1938 | } |
| 1939 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1940 | #endif // _LIBCPP_NO_RTTI |
Howard Hinnant | 72f7358 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 1941 | |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1942 | // __value_func creates a value-type from a __func. |
| 1943 | |
| 1944 | template <class _Fp> class __value_func; |
| 1945 | |
| 1946 | template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)> |
| 1947 | { |
| 1948 | typename aligned_storage<3 * sizeof(void*)>::type __buf_; |
| 1949 | |
| 1950 | typedef __base<_Rp(_ArgTypes...)> __func; |
| 1951 | __func* __f_; |
| 1952 | |
| 1953 | _LIBCPP_NO_CFI static __func* __as_base(void* p) |
| 1954 | { |
| 1955 | return reinterpret_cast<__func*>(p); |
| 1956 | } |
| 1957 | |
| 1958 | public: |
| 1959 | _LIBCPP_INLINE_VISIBILITY |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 1960 | __value_func() _NOEXCEPT : __f_(nullptr) {} |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1961 | |
| 1962 | template <class _Fp, class _Alloc> |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 1963 | _LIBCPP_INLINE_VISIBILITY __value_func(_Fp&& __f, const _Alloc& __a) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 1964 | : __f_(nullptr) |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1965 | { |
| 1966 | typedef allocator_traits<_Alloc> __alloc_traits; |
| 1967 | typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun; |
| 1968 | typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type |
| 1969 | _FunAlloc; |
| 1970 | |
| 1971 | if (__function::__not_null(__f)) |
| 1972 | { |
| 1973 | _FunAlloc __af(__a); |
| 1974 | if (sizeof(_Fun) <= sizeof(__buf_) && |
| 1975 | is_nothrow_copy_constructible<_Fp>::value && |
| 1976 | is_nothrow_copy_constructible<_FunAlloc>::value) |
| 1977 | { |
| 1978 | __f_ = |
| 1979 | ::new ((void*)&__buf_) _Fun(_VSTD::move(__f), _Alloc(__af)); |
| 1980 | } |
| 1981 | else |
| 1982 | { |
| 1983 | typedef __allocator_destructor<_FunAlloc> _Dp; |
| 1984 | unique_ptr<__func, _Dp> __hold(__af.allocate(1), _Dp(__af, 1)); |
| 1985 | ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f), _Alloc(__a)); |
| 1986 | __f_ = __hold.release(); |
| 1987 | } |
| 1988 | } |
| 1989 | } |
| 1990 | |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 1991 | template <class _Fp, |
| 1992 | class = typename enable_if<!is_same<typename decay<_Fp>::type, __value_func>::value>::type> |
| 1993 | _LIBCPP_INLINE_VISIBILITY explicit __value_func(_Fp&& __f) |
Arthur O'Dwyer | 07b2249 | 2020-11-27 11:02:06 -0500 | [diff] [blame] | 1994 | : __value_func(_VSTD::forward<_Fp>(__f), allocator<_Fp>()) {} |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 1995 | |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 1996 | _LIBCPP_INLINE_VISIBILITY |
| 1997 | __value_func(const __value_func& __f) |
| 1998 | { |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 1999 | if (__f.__f_ == nullptr) |
| 2000 | __f_ = nullptr; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2001 | else if ((void*)__f.__f_ == &__f.__buf_) |
| 2002 | { |
| 2003 | __f_ = __as_base(&__buf_); |
| 2004 | __f.__f_->__clone(__f_); |
| 2005 | } |
| 2006 | else |
| 2007 | __f_ = __f.__f_->__clone(); |
| 2008 | } |
| 2009 | |
| 2010 | _LIBCPP_INLINE_VISIBILITY |
| 2011 | __value_func(__value_func&& __f) _NOEXCEPT |
| 2012 | { |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2013 | if (__f.__f_ == nullptr) |
| 2014 | __f_ = nullptr; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2015 | else if ((void*)__f.__f_ == &__f.__buf_) |
| 2016 | { |
| 2017 | __f_ = __as_base(&__buf_); |
| 2018 | __f.__f_->__clone(__f_); |
| 2019 | } |
| 2020 | else |
| 2021 | { |
| 2022 | __f_ = __f.__f_; |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2023 | __f.__f_ = nullptr; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2024 | } |
| 2025 | } |
| 2026 | |
| 2027 | _LIBCPP_INLINE_VISIBILITY |
| 2028 | ~__value_func() |
| 2029 | { |
| 2030 | if ((void*)__f_ == &__buf_) |
| 2031 | __f_->destroy(); |
| 2032 | else if (__f_) |
| 2033 | __f_->destroy_deallocate(); |
| 2034 | } |
| 2035 | |
| 2036 | _LIBCPP_INLINE_VISIBILITY |
| 2037 | __value_func& operator=(__value_func&& __f) |
| 2038 | { |
| 2039 | *this = nullptr; |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2040 | if (__f.__f_ == nullptr) |
| 2041 | __f_ = nullptr; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2042 | else if ((void*)__f.__f_ == &__f.__buf_) |
| 2043 | { |
| 2044 | __f_ = __as_base(&__buf_); |
| 2045 | __f.__f_->__clone(__f_); |
| 2046 | } |
| 2047 | else |
| 2048 | { |
| 2049 | __f_ = __f.__f_; |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2050 | __f.__f_ = nullptr; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2051 | } |
| 2052 | return *this; |
| 2053 | } |
| 2054 | |
| 2055 | _LIBCPP_INLINE_VISIBILITY |
| 2056 | __value_func& operator=(nullptr_t) |
| 2057 | { |
| 2058 | __func* __f = __f_; |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2059 | __f_ = nullptr; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2060 | if ((void*)__f == &__buf_) |
| 2061 | __f->destroy(); |
| 2062 | else if (__f) |
| 2063 | __f->destroy_deallocate(); |
| 2064 | return *this; |
| 2065 | } |
| 2066 | |
| 2067 | _LIBCPP_INLINE_VISIBILITY |
| 2068 | _Rp operator()(_ArgTypes&&... __args) const |
| 2069 | { |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2070 | if (__f_ == nullptr) |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2071 | __throw_bad_function_call(); |
| 2072 | return (*__f_)(_VSTD::forward<_ArgTypes>(__args)...); |
| 2073 | } |
| 2074 | |
| 2075 | _LIBCPP_INLINE_VISIBILITY |
| 2076 | void swap(__value_func& __f) _NOEXCEPT |
| 2077 | { |
| 2078 | if (&__f == this) |
| 2079 | return; |
| 2080 | if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) |
| 2081 | { |
| 2082 | typename aligned_storage<sizeof(__buf_)>::type __tempbuf; |
| 2083 | __func* __t = __as_base(&__tempbuf); |
| 2084 | __f_->__clone(__t); |
| 2085 | __f_->destroy(); |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2086 | __f_ = nullptr; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2087 | __f.__f_->__clone(__as_base(&__buf_)); |
| 2088 | __f.__f_->destroy(); |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2089 | __f.__f_ = nullptr; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2090 | __f_ = __as_base(&__buf_); |
| 2091 | __t->__clone(__as_base(&__f.__buf_)); |
| 2092 | __t->destroy(); |
| 2093 | __f.__f_ = __as_base(&__f.__buf_); |
| 2094 | } |
| 2095 | else if ((void*)__f_ == &__buf_) |
| 2096 | { |
| 2097 | __f_->__clone(__as_base(&__f.__buf_)); |
| 2098 | __f_->destroy(); |
| 2099 | __f_ = __f.__f_; |
| 2100 | __f.__f_ = __as_base(&__f.__buf_); |
| 2101 | } |
| 2102 | else if ((void*)__f.__f_ == &__f.__buf_) |
| 2103 | { |
| 2104 | __f.__f_->__clone(__as_base(&__buf_)); |
| 2105 | __f.__f_->destroy(); |
| 2106 | __f.__f_ = __f_; |
| 2107 | __f_ = __as_base(&__buf_); |
| 2108 | } |
| 2109 | else |
| 2110 | _VSTD::swap(__f_, __f.__f_); |
| 2111 | } |
| 2112 | |
| 2113 | _LIBCPP_INLINE_VISIBILITY |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2114 | _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT { return __f_ != nullptr; } |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2115 | |
| 2116 | #ifndef _LIBCPP_NO_RTTI |
| 2117 | _LIBCPP_INLINE_VISIBILITY |
| 2118 | const std::type_info& target_type() const _NOEXCEPT |
| 2119 | { |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2120 | if (__f_ == nullptr) |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2121 | return typeid(void); |
| 2122 | return __f_->target_type(); |
| 2123 | } |
| 2124 | |
| 2125 | template <typename _Tp> |
| 2126 | _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT |
| 2127 | { |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2128 | if (__f_ == nullptr) |
| 2129 | return nullptr; |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2130 | return (const _Tp*)__f_->target(typeid(_Tp)); |
| 2131 | } |
| 2132 | #endif // _LIBCPP_NO_RTTI |
| 2133 | }; |
| 2134 | |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2135 | // Storage for a functor object, to be used with __policy to manage copy and |
| 2136 | // destruction. |
| 2137 | union __policy_storage |
| 2138 | { |
| 2139 | mutable char __small[sizeof(void*) * 2]; |
| 2140 | void* __large; |
| 2141 | }; |
| 2142 | |
| 2143 | // True if _Fun can safely be held in __policy_storage.__small. |
| 2144 | template <typename _Fun> |
| 2145 | struct __use_small_storage |
Arthur O'Dwyer | d8dddf5 | 2021-05-10 13:13:04 -0400 | [diff] [blame] | 2146 | : public integral_constant< |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2147 | bool, sizeof(_Fun) <= sizeof(__policy_storage) && |
Eric Fiselier | 0f0ed9d | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 2148 | _LIBCPP_ALIGNOF(_Fun) <= _LIBCPP_ALIGNOF(__policy_storage) && |
Arthur O'Dwyer | d8dddf5 | 2021-05-10 13:13:04 -0400 | [diff] [blame] | 2149 | is_trivially_copy_constructible<_Fun>::value && |
| 2150 | is_trivially_destructible<_Fun>::value> {}; |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2151 | |
| 2152 | // Policy contains information about how to copy, destroy, and move the |
| 2153 | // underlying functor. You can think of it as a vtable of sorts. |
| 2154 | struct __policy |
| 2155 | { |
| 2156 | // Used to copy or destroy __large values. null for trivial objects. |
| 2157 | void* (*const __clone)(const void*); |
| 2158 | void (*const __destroy)(void*); |
| 2159 | |
| 2160 | // True if this is the null policy (no value). |
| 2161 | const bool __is_null; |
| 2162 | |
| 2163 | // The target type. May be null if RTTI is disabled. |
| 2164 | const std::type_info* const __type_info; |
| 2165 | |
| 2166 | // Returns a pointer to a static policy object suitable for the functor |
| 2167 | // type. |
| 2168 | template <typename _Fun> |
| 2169 | _LIBCPP_INLINE_VISIBILITY static const __policy* __create() |
| 2170 | { |
| 2171 | return __choose_policy<_Fun>(__use_small_storage<_Fun>()); |
| 2172 | } |
| 2173 | |
| 2174 | _LIBCPP_INLINE_VISIBILITY |
| 2175 | static const __policy* __create_empty() |
| 2176 | { |
| 2177 | static const _LIBCPP_CONSTEXPR __policy __policy_ = {nullptr, nullptr, |
| 2178 | true, |
| 2179 | #ifndef _LIBCPP_NO_RTTI |
| 2180 | &typeid(void) |
| 2181 | #else |
| 2182 | nullptr |
| 2183 | #endif |
| 2184 | }; |
| 2185 | return &__policy_; |
| 2186 | } |
| 2187 | |
| 2188 | private: |
| 2189 | template <typename _Fun> static void* __large_clone(const void* __s) |
| 2190 | { |
| 2191 | const _Fun* __f = static_cast<const _Fun*>(__s); |
| 2192 | return __f->__clone(); |
| 2193 | } |
| 2194 | |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 2195 | template <typename _Fun> |
| 2196 | static void __large_destroy(void* __s) { |
| 2197 | _Fun::__destroy_and_delete(static_cast<_Fun*>(__s)); |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2198 | } |
| 2199 | |
| 2200 | template <typename _Fun> |
| 2201 | _LIBCPP_INLINE_VISIBILITY static const __policy* |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 2202 | __choose_policy(/* is_small = */ false_type) { |
| 2203 | static const _LIBCPP_CONSTEXPR __policy __policy_ = { |
| 2204 | &__large_clone<_Fun>, &__large_destroy<_Fun>, false, |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2205 | #ifndef _LIBCPP_NO_RTTI |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 2206 | &typeid(typename _Fun::_Target) |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2207 | #else |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 2208 | nullptr |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2209 | #endif |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 2210 | }; |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2211 | return &__policy_; |
| 2212 | } |
| 2213 | |
| 2214 | template <typename _Fun> |
| 2215 | _LIBCPP_INLINE_VISIBILITY static const __policy* |
| 2216 | __choose_policy(/* is_small = */ true_type) |
| 2217 | { |
| 2218 | static const _LIBCPP_CONSTEXPR __policy __policy_ = { |
| 2219 | nullptr, nullptr, false, |
| 2220 | #ifndef _LIBCPP_NO_RTTI |
| 2221 | &typeid(typename _Fun::_Target) |
| 2222 | #else |
| 2223 | nullptr |
| 2224 | #endif |
| 2225 | }; |
| 2226 | return &__policy_; |
| 2227 | } |
| 2228 | }; |
| 2229 | |
| 2230 | // Used to choose between perfect forwarding or pass-by-value. Pass-by-value is |
| 2231 | // faster for types that can be passed in registers. |
| 2232 | template <typename _Tp> |
| 2233 | using __fast_forward = |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 2234 | typename conditional<is_scalar<_Tp>::value, _Tp, _Tp&&>::type; |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2235 | |
| 2236 | // __policy_invoker calls an instance of __alloc_func held in __policy_storage. |
| 2237 | |
| 2238 | template <class _Fp> struct __policy_invoker; |
| 2239 | |
| 2240 | template <class _Rp, class... _ArgTypes> |
| 2241 | struct __policy_invoker<_Rp(_ArgTypes...)> |
| 2242 | { |
| 2243 | typedef _Rp (*__Call)(const __policy_storage*, |
| 2244 | __fast_forward<_ArgTypes>...); |
| 2245 | |
| 2246 | __Call __call_; |
| 2247 | |
| 2248 | // Creates an invoker that throws bad_function_call. |
| 2249 | _LIBCPP_INLINE_VISIBILITY |
| 2250 | __policy_invoker() : __call_(&__call_empty) {} |
| 2251 | |
| 2252 | // Creates an invoker that calls the given instance of __func. |
| 2253 | template <typename _Fun> |
| 2254 | _LIBCPP_INLINE_VISIBILITY static __policy_invoker __create() |
| 2255 | { |
| 2256 | return __policy_invoker(&__call_impl<_Fun>); |
| 2257 | } |
| 2258 | |
| 2259 | private: |
| 2260 | _LIBCPP_INLINE_VISIBILITY |
| 2261 | explicit __policy_invoker(__Call __c) : __call_(__c) {} |
| 2262 | |
| 2263 | static _Rp __call_empty(const __policy_storage*, |
| 2264 | __fast_forward<_ArgTypes>...) |
| 2265 | { |
| 2266 | __throw_bad_function_call(); |
| 2267 | } |
| 2268 | |
| 2269 | template <typename _Fun> |
| 2270 | static _Rp __call_impl(const __policy_storage* __buf, |
| 2271 | __fast_forward<_ArgTypes>... __args) |
| 2272 | { |
| 2273 | _Fun* __f = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value |
| 2274 | ? &__buf->__small |
| 2275 | : __buf->__large); |
| 2276 | return (*__f)(_VSTD::forward<_ArgTypes>(__args)...); |
| 2277 | } |
| 2278 | }; |
| 2279 | |
| 2280 | // __policy_func uses a __policy and __policy_invoker to create a type-erased, |
| 2281 | // copyable functor. |
| 2282 | |
| 2283 | template <class _Fp> class __policy_func; |
| 2284 | |
| 2285 | template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)> |
| 2286 | { |
| 2287 | // Inline storage for small objects. |
| 2288 | __policy_storage __buf_; |
| 2289 | |
| 2290 | // Calls the value stored in __buf_. This could technically be part of |
| 2291 | // policy, but storing it here eliminates a level of indirection inside |
| 2292 | // operator(). |
| 2293 | typedef __function::__policy_invoker<_Rp(_ArgTypes...)> __invoker; |
| 2294 | __invoker __invoker_; |
| 2295 | |
| 2296 | // The policy that describes how to move / copy / destroy __buf_. Never |
| 2297 | // null, even if the function is empty. |
| 2298 | const __policy* __policy_; |
| 2299 | |
| 2300 | public: |
| 2301 | _LIBCPP_INLINE_VISIBILITY |
| 2302 | __policy_func() : __policy_(__policy::__create_empty()) {} |
| 2303 | |
| 2304 | template <class _Fp, class _Alloc> |
| 2305 | _LIBCPP_INLINE_VISIBILITY __policy_func(_Fp&& __f, const _Alloc& __a) |
| 2306 | : __policy_(__policy::__create_empty()) |
| 2307 | { |
| 2308 | typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun; |
| 2309 | typedef allocator_traits<_Alloc> __alloc_traits; |
| 2310 | typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type |
| 2311 | _FunAlloc; |
| 2312 | |
| 2313 | if (__function::__not_null(__f)) |
| 2314 | { |
| 2315 | __invoker_ = __invoker::template __create<_Fun>(); |
| 2316 | __policy_ = __policy::__create<_Fun>(); |
| 2317 | |
| 2318 | _FunAlloc __af(__a); |
| 2319 | if (__use_small_storage<_Fun>()) |
| 2320 | { |
| 2321 | ::new ((void*)&__buf_.__small) |
| 2322 | _Fun(_VSTD::move(__f), _Alloc(__af)); |
| 2323 | } |
| 2324 | else |
| 2325 | { |
| 2326 | typedef __allocator_destructor<_FunAlloc> _Dp; |
| 2327 | unique_ptr<_Fun, _Dp> __hold(__af.allocate(1), _Dp(__af, 1)); |
| 2328 | ::new ((void*)__hold.get()) |
| 2329 | _Fun(_VSTD::move(__f), _Alloc(__af)); |
| 2330 | __buf_.__large = __hold.release(); |
| 2331 | } |
| 2332 | } |
| 2333 | } |
| 2334 | |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 2335 | template <class _Fp, class = typename enable_if<!is_same<typename decay<_Fp>::type, __policy_func>::value>::type> |
| 2336 | _LIBCPP_INLINE_VISIBILITY explicit __policy_func(_Fp&& __f) |
| 2337 | : __policy_(__policy::__create_empty()) { |
| 2338 | typedef __default_alloc_func<_Fp, _Rp(_ArgTypes...)> _Fun; |
| 2339 | |
| 2340 | if (__function::__not_null(__f)) { |
| 2341 | __invoker_ = __invoker::template __create<_Fun>(); |
| 2342 | __policy_ = __policy::__create<_Fun>(); |
| 2343 | if (__use_small_storage<_Fun>()) { |
| 2344 | ::new ((void*)&__buf_.__small) _Fun(_VSTD::move(__f)); |
| 2345 | } else { |
| 2346 | __builtin_new_allocator::__holder_t __hold = |
| 2347 | __builtin_new_allocator::__allocate_type<_Fun>(1); |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2348 | __buf_.__large = ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f)); |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 2349 | (void)__hold.release(); |
| 2350 | } |
| 2351 | } |
| 2352 | } |
| 2353 | |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2354 | _LIBCPP_INLINE_VISIBILITY |
| 2355 | __policy_func(const __policy_func& __f) |
| 2356 | : __buf_(__f.__buf_), __invoker_(__f.__invoker_), |
| 2357 | __policy_(__f.__policy_) |
| 2358 | { |
| 2359 | if (__policy_->__clone) |
| 2360 | __buf_.__large = __policy_->__clone(__f.__buf_.__large); |
| 2361 | } |
| 2362 | |
| 2363 | _LIBCPP_INLINE_VISIBILITY |
| 2364 | __policy_func(__policy_func&& __f) |
| 2365 | : __buf_(__f.__buf_), __invoker_(__f.__invoker_), |
| 2366 | __policy_(__f.__policy_) |
| 2367 | { |
| 2368 | if (__policy_->__destroy) |
| 2369 | { |
| 2370 | __f.__policy_ = __policy::__create_empty(); |
| 2371 | __f.__invoker_ = __invoker(); |
| 2372 | } |
| 2373 | } |
| 2374 | |
| 2375 | _LIBCPP_INLINE_VISIBILITY |
| 2376 | ~__policy_func() |
| 2377 | { |
| 2378 | if (__policy_->__destroy) |
| 2379 | __policy_->__destroy(__buf_.__large); |
| 2380 | } |
| 2381 | |
| 2382 | _LIBCPP_INLINE_VISIBILITY |
| 2383 | __policy_func& operator=(__policy_func&& __f) |
| 2384 | { |
| 2385 | *this = nullptr; |
| 2386 | __buf_ = __f.__buf_; |
| 2387 | __invoker_ = __f.__invoker_; |
| 2388 | __policy_ = __f.__policy_; |
| 2389 | __f.__policy_ = __policy::__create_empty(); |
| 2390 | __f.__invoker_ = __invoker(); |
| 2391 | return *this; |
| 2392 | } |
| 2393 | |
| 2394 | _LIBCPP_INLINE_VISIBILITY |
| 2395 | __policy_func& operator=(nullptr_t) |
| 2396 | { |
| 2397 | const __policy* __p = __policy_; |
| 2398 | __policy_ = __policy::__create_empty(); |
| 2399 | __invoker_ = __invoker(); |
| 2400 | if (__p->__destroy) |
| 2401 | __p->__destroy(__buf_.__large); |
| 2402 | return *this; |
| 2403 | } |
| 2404 | |
| 2405 | _LIBCPP_INLINE_VISIBILITY |
| 2406 | _Rp operator()(_ArgTypes&&... __args) const |
| 2407 | { |
| 2408 | return __invoker_.__call_(_VSTD::addressof(__buf_), |
| 2409 | _VSTD::forward<_ArgTypes>(__args)...); |
| 2410 | } |
| 2411 | |
| 2412 | _LIBCPP_INLINE_VISIBILITY |
| 2413 | void swap(__policy_func& __f) |
| 2414 | { |
| 2415 | _VSTD::swap(__invoker_, __f.__invoker_); |
| 2416 | _VSTD::swap(__policy_, __f.__policy_); |
| 2417 | _VSTD::swap(__buf_, __f.__buf_); |
| 2418 | } |
| 2419 | |
| 2420 | _LIBCPP_INLINE_VISIBILITY |
| 2421 | explicit operator bool() const _NOEXCEPT |
| 2422 | { |
| 2423 | return !__policy_->__is_null; |
| 2424 | } |
| 2425 | |
| 2426 | #ifndef _LIBCPP_NO_RTTI |
| 2427 | _LIBCPP_INLINE_VISIBILITY |
| 2428 | const std::type_info& target_type() const _NOEXCEPT |
| 2429 | { |
| 2430 | return *__policy_->__type_info; |
| 2431 | } |
| 2432 | |
| 2433 | template <typename _Tp> |
| 2434 | _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT |
| 2435 | { |
| 2436 | if (__policy_->__is_null || typeid(_Tp) != *__policy_->__type_info) |
| 2437 | return nullptr; |
| 2438 | if (__policy_->__clone) // Out of line storage. |
| 2439 | return reinterpret_cast<const _Tp*>(__buf_.__large); |
| 2440 | else |
| 2441 | return reinterpret_cast<const _Tp*>(&__buf_.__small); |
| 2442 | } |
| 2443 | #endif // _LIBCPP_NO_RTTI |
| 2444 | }; |
| 2445 | |
Louis Dionne | 3a63292 | 2020-04-23 16:47:52 -0400 | [diff] [blame] | 2446 | #if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC) |
Louis Dionne | e2391d7 | 2020-04-22 13:58:17 -0400 | [diff] [blame] | 2447 | |
Louis Dionne | 91cf444 | 2020-07-31 12:56:36 -0400 | [diff] [blame] | 2448 | extern "C" void *_Block_copy(const void *); |
| 2449 | extern "C" void _Block_release(const void *); |
| 2450 | |
Louis Dionne | e2391d7 | 2020-04-22 13:58:17 -0400 | [diff] [blame] | 2451 | template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes> |
| 2452 | class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> |
| 2453 | : public __base<_Rp(_ArgTypes...)> |
| 2454 | { |
| 2455 | typedef _Rp1(^__block_type)(_ArgTypes1...); |
| 2456 | __block_type __f_; |
| 2457 | |
| 2458 | public: |
| 2459 | _LIBCPP_INLINE_VISIBILITY |
| 2460 | explicit __func(__block_type const& __f) |
Louis Dionne | 91cf444 | 2020-07-31 12:56:36 -0400 | [diff] [blame] | 2461 | : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) |
Louis Dionne | e2391d7 | 2020-04-22 13:58:17 -0400 | [diff] [blame] | 2462 | { } |
| 2463 | |
| 2464 | // [TODO] add && to save on a retain |
| 2465 | |
| 2466 | _LIBCPP_INLINE_VISIBILITY |
| 2467 | explicit __func(__block_type __f, const _Alloc& /* unused */) |
Louis Dionne | 91cf444 | 2020-07-31 12:56:36 -0400 | [diff] [blame] | 2468 | : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) |
Louis Dionne | e2391d7 | 2020-04-22 13:58:17 -0400 | [diff] [blame] | 2469 | { } |
| 2470 | |
| 2471 | virtual __base<_Rp(_ArgTypes...)>* __clone() const { |
| 2472 | _LIBCPP_ASSERT(false, |
| 2473 | "Block pointers are just pointers, so they should always fit into " |
| 2474 | "std::function's small buffer optimization. This function should " |
| 2475 | "never be invoked."); |
| 2476 | return nullptr; |
| 2477 | } |
| 2478 | |
| 2479 | virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const { |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2480 | ::new ((void*)__p) __func(__f_); |
Louis Dionne | e2391d7 | 2020-04-22 13:58:17 -0400 | [diff] [blame] | 2481 | } |
| 2482 | |
| 2483 | virtual void destroy() _NOEXCEPT { |
| 2484 | if (__f_) |
Louis Dionne | 91cf444 | 2020-07-31 12:56:36 -0400 | [diff] [blame] | 2485 | _Block_release(__f_); |
Louis Dionne | e2391d7 | 2020-04-22 13:58:17 -0400 | [diff] [blame] | 2486 | __f_ = 0; |
| 2487 | } |
| 2488 | |
| 2489 | virtual void destroy_deallocate() _NOEXCEPT { |
| 2490 | _LIBCPP_ASSERT(false, |
| 2491 | "Block pointers are just pointers, so they should always fit into " |
| 2492 | "std::function's small buffer optimization. This function should " |
| 2493 | "never be invoked."); |
| 2494 | } |
| 2495 | |
| 2496 | virtual _Rp operator()(_ArgTypes&& ... __arg) { |
Arthur O'Dwyer | 6814ff7 | 2020-12-08 16:15:01 -0500 | [diff] [blame] | 2497 | return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...); |
Louis Dionne | e2391d7 | 2020-04-22 13:58:17 -0400 | [diff] [blame] | 2498 | } |
| 2499 | |
| 2500 | #ifndef _LIBCPP_NO_RTTI |
| 2501 | virtual const void* target(type_info const& __ti) const _NOEXCEPT { |
| 2502 | if (__ti == typeid(__func::__block_type)) |
| 2503 | return &__f_; |
| 2504 | return (const void*)nullptr; |
| 2505 | } |
| 2506 | |
| 2507 | virtual const std::type_info& target_type() const _NOEXCEPT { |
| 2508 | return typeid(__func::__block_type); |
| 2509 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2510 | #endif // _LIBCPP_NO_RTTI |
Louis Dionne | e2391d7 | 2020-04-22 13:58:17 -0400 | [diff] [blame] | 2511 | }; |
| 2512 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2513 | #endif // _LIBCPP_HAS_EXTENSION_BLOCKS && !_LIBCPP_HAS_OBJC_ARC |
Louis Dionne | e2391d7 | 2020-04-22 13:58:17 -0400 | [diff] [blame] | 2514 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2515 | } // __function |
| 2516 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2517 | template<class _Rp, class ..._ArgTypes> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 2518 | class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 2519 | #if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2520 | : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, |
| 2521 | public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 2522 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2523 | { |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2524 | #ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2525 | typedef __function::__value_func<_Rp(_ArgTypes...)> __func; |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 2526 | #else |
| 2527 | typedef __function::__policy_func<_Rp(_ArgTypes...)> __func; |
| 2528 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2529 | |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2530 | __func __f_; |
Evgeniy Stepanov | 076b237 | 2016-02-10 21:53:28 +0000 | [diff] [blame] | 2531 | |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 2532 | template <class _Fp, bool = _And< |
| 2533 | _IsNotSame<__uncvref_t<_Fp>, function>, |
zoecarver | 3e722f2 | 2020-05-19 17:15:28 -0700 | [diff] [blame] | 2534 | __invokable<_Fp, _ArgTypes...> |
Eric Fiselier | 43c04f7 | 2017-09-10 23:41:20 +0000 | [diff] [blame] | 2535 | >::value> |
| 2536 | struct __callable; |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2537 | template <class _Fp> |
| 2538 | struct __callable<_Fp, true> |
Howard Hinnant | 9575593 | 2011-05-31 21:45:26 +0000 | [diff] [blame] | 2539 | { |
Arthur O'Dwyer | 4ba8e3d | 2021-01-11 16:29:17 -0500 | [diff] [blame] | 2540 | static const bool value = is_void<_Rp>::value || |
| 2541 | __is_core_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type, |
| 2542 | _Rp>::value; |
Howard Hinnant | 9575593 | 2011-05-31 21:45:26 +0000 | [diff] [blame] | 2543 | }; |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2544 | template <class _Fp> |
| 2545 | struct __callable<_Fp, false> |
Howard Hinnant | 9575593 | 2011-05-31 21:45:26 +0000 | [diff] [blame] | 2546 | { |
| 2547 | static const bool value = false; |
| 2548 | }; |
Eric Fiselier | 43c04f7 | 2017-09-10 23:41:20 +0000 | [diff] [blame] | 2549 | |
| 2550 | template <class _Fp> |
zoecarver | 3e722f2 | 2020-05-19 17:15:28 -0700 | [diff] [blame] | 2551 | using _EnableIfLValueCallable = typename enable_if<__callable<_Fp&>::value>::type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2552 | public: |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2553 | typedef _Rp result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2554 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2555 | // construct/copy/destroy: |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 2556 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2557 | function() _NOEXCEPT { } |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 2558 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2559 | function(nullptr_t) _NOEXCEPT {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2560 | function(const function&); |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 2561 | function(function&&) _NOEXCEPT; |
zoecarver | 3e722f2 | 2020-05-19 17:15:28 -0700 | [diff] [blame] | 2562 | template<class _Fp, class = _EnableIfLValueCallable<_Fp>> |
Eric Fiselier | f3e18cf | 2016-07-20 05:21:00 +0000 | [diff] [blame] | 2563 | function(_Fp); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2564 | |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 2565 | #if _LIBCPP_STD_VER <= 14 |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2566 | template<class _Alloc> |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 2567 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2568 | function(allocator_arg_t, const _Alloc&) _NOEXCEPT {} |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2569 | template<class _Alloc> |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 2570 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2571 | function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT {} |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2572 | template<class _Alloc> |
| 2573 | function(allocator_arg_t, const _Alloc&, const function&); |
| 2574 | template<class _Alloc> |
| 2575 | function(allocator_arg_t, const _Alloc&, function&&); |
zoecarver | 3e722f2 | 2020-05-19 17:15:28 -0700 | [diff] [blame] | 2576 | template<class _Fp, class _Alloc, class = _EnableIfLValueCallable<_Fp>> |
Eric Fiselier | f3e18cf | 2016-07-20 05:21:00 +0000 | [diff] [blame] | 2577 | function(allocator_arg_t, const _Alloc& __a, _Fp __f); |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 2578 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2579 | |
| 2580 | function& operator=(const function&); |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 2581 | function& operator=(function&&) _NOEXCEPT; |
| 2582 | function& operator=(nullptr_t) _NOEXCEPT; |
zoecarver | 3e722f2 | 2020-05-19 17:15:28 -0700 | [diff] [blame] | 2583 | template<class _Fp, class = _EnableIfLValueCallable<typename decay<_Fp>::type>> |
Eric Fiselier | 43c04f7 | 2017-09-10 23:41:20 +0000 | [diff] [blame] | 2584 | function& operator=(_Fp&&); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2585 | |
| 2586 | ~function(); |
| 2587 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2588 | // function modifiers: |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 2589 | void swap(function&) _NOEXCEPT; |
Marshall Clow | fc8fd83 | 2016-01-25 17:29:55 +0000 | [diff] [blame] | 2590 | |
| 2591 | #if _LIBCPP_STD_VER <= 14 |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2592 | template<class _Fp, class _Alloc> |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 2593 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2594 | void assign(_Fp&& __f, const _Alloc& __a) |
| 2595 | {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} |
Marshall Clow | fc8fd83 | 2016-01-25 17:29:55 +0000 | [diff] [blame] | 2596 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2597 | |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2598 | // function capacity: |
Howard Hinnant | 4ff5743 | 2010-09-21 22:55:27 +0000 | [diff] [blame] | 2599 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2600 | _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT { |
| 2601 | return static_cast<bool>(__f_); |
| 2602 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2603 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2604 | // deleted overloads close possible hole in the type system |
| 2605 | template<class _R2, class... _ArgTypes2> |
Howard Hinnant | 5e9a1cf | 2010-09-11 15:33:21 +0000 | [diff] [blame] | 2606 | bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2607 | template<class _R2, class... _ArgTypes2> |
Howard Hinnant | 5e9a1cf | 2010-09-11 15:33:21 +0000 | [diff] [blame] | 2608 | bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2609 | public: |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2610 | // function invocation: |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2611 | _Rp operator()(_ArgTypes...) const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2612 | |
Howard Hinnant | 72f7358 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 2613 | #ifndef _LIBCPP_NO_RTTI |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2614 | // function target access: |
Howard Hinnant | f7724cd | 2011-05-28 17:59:48 +0000 | [diff] [blame] | 2615 | const std::type_info& target_type() const _NOEXCEPT; |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2616 | template <typename _Tp> _Tp* target() _NOEXCEPT; |
| 2617 | template <typename _Tp> const _Tp* target() const _NOEXCEPT; |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2618 | #endif // _LIBCPP_NO_RTTI |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2619 | }; |
| 2620 | |
Louis Dionne | 4af4971 | 2019-07-18 19:50:56 +0000 | [diff] [blame] | 2621 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES |
| 2622 | template<class _Rp, class ..._Ap> |
| 2623 | function(_Rp(*)(_Ap...)) -> function<_Rp(_Ap...)>; |
| 2624 | |
| 2625 | template<class _Fp> |
| 2626 | struct __strip_signature; |
| 2627 | |
| 2628 | template<class _Rp, class _Gp, class ..._Ap> |
| 2629 | struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); }; |
| 2630 | template<class _Rp, class _Gp, class ..._Ap> |
| 2631 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); }; |
| 2632 | template<class _Rp, class _Gp, class ..._Ap> |
| 2633 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); }; |
| 2634 | template<class _Rp, class _Gp, class ..._Ap> |
| 2635 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type = _Rp(_Ap...); }; |
| 2636 | |
| 2637 | template<class _Rp, class _Gp, class ..._Ap> |
| 2638 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type = _Rp(_Ap...); }; |
| 2639 | template<class _Rp, class _Gp, class ..._Ap> |
| 2640 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type = _Rp(_Ap...); }; |
| 2641 | template<class _Rp, class _Gp, class ..._Ap> |
| 2642 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type = _Rp(_Ap...); }; |
| 2643 | template<class _Rp, class _Gp, class ..._Ap> |
| 2644 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type = _Rp(_Ap...); }; |
| 2645 | |
| 2646 | template<class _Rp, class _Gp, class ..._Ap> |
| 2647 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type = _Rp(_Ap...); }; |
| 2648 | template<class _Rp, class _Gp, class ..._Ap> |
| 2649 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type = _Rp(_Ap...); }; |
| 2650 | template<class _Rp, class _Gp, class ..._Ap> |
| 2651 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type = _Rp(_Ap...); }; |
| 2652 | template<class _Rp, class _Gp, class ..._Ap> |
| 2653 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type = _Rp(_Ap...); }; |
| 2654 | |
| 2655 | template<class _Rp, class _Gp, class ..._Ap> |
| 2656 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type = _Rp(_Ap...); }; |
| 2657 | template<class _Rp, class _Gp, class ..._Ap> |
| 2658 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type = _Rp(_Ap...); }; |
| 2659 | template<class _Rp, class _Gp, class ..._Ap> |
| 2660 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type = _Rp(_Ap...); }; |
| 2661 | template<class _Rp, class _Gp, class ..._Ap> |
| 2662 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type = _Rp(_Ap...); }; |
| 2663 | |
| 2664 | template<class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type> |
| 2665 | function(_Fp) -> function<_Stripped>; |
| 2666 | #endif // !_LIBCPP_HAS_NO_DEDUCTION_GUIDES |
| 2667 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2668 | template<class _Rp, class ..._ArgTypes> |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2669 | function<_Rp(_ArgTypes...)>::function(const function& __f) : __f_(__f.__f_) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2670 | |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 2671 | #if _LIBCPP_STD_VER <= 14 |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2672 | template<class _Rp, class ..._ArgTypes> |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2673 | template <class _Alloc> |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2674 | function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2675 | const function& __f) : __f_(__f.__f_) {} |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 2676 | #endif |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2677 | |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2678 | template <class _Rp, class... _ArgTypes> |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2679 | function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2680 | : __f_(_VSTD::move(__f.__f_)) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2681 | |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 2682 | #if _LIBCPP_STD_VER <= 14 |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2683 | template<class _Rp, class ..._ArgTypes> |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2684 | template <class _Alloc> |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2685 | function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2686 | function&& __f) |
| 2687 | : __f_(_VSTD::move(__f.__f_)) {} |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 2688 | #endif |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2689 | |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2690 | template <class _Rp, class... _ArgTypes> |
Eric Fiselier | f3e18cf | 2016-07-20 05:21:00 +0000 | [diff] [blame] | 2691 | template <class _Fp, class> |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 2692 | function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(_VSTD::move(__f)) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2693 | |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 2694 | #if _LIBCPP_STD_VER <= 14 |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2695 | template <class _Rp, class... _ArgTypes> |
Eric Fiselier | f3e18cf | 2016-07-20 05:21:00 +0000 | [diff] [blame] | 2696 | template <class _Fp, class _Alloc, class> |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2697 | function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a, |
| 2698 | _Fp __f) |
| 2699 | : __f_(_VSTD::move(__f), __a) {} |
Marshall Clow | 3148f42 | 2016-10-13 21:06:03 +0000 | [diff] [blame] | 2700 | #endif |
Howard Hinnant | f06d926 | 2010-08-20 19:36:46 +0000 | [diff] [blame] | 2701 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2702 | template<class _Rp, class ..._ArgTypes> |
| 2703 | function<_Rp(_ArgTypes...)>& |
| 2704 | function<_Rp(_ArgTypes...)>::operator=(const function& __f) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2705 | { |
| 2706 | function(__f).swap(*this); |
| 2707 | return *this; |
| 2708 | } |
| 2709 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2710 | template<class _Rp, class ..._ArgTypes> |
| 2711 | function<_Rp(_ArgTypes...)>& |
| 2712 | function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2713 | { |
Arthur O'Dwyer | 07b2249 | 2020-11-27 11:02:06 -0500 | [diff] [blame] | 2714 | __f_ = _VSTD::move(__f.__f_); |
Argyrios Kyrtzidis | af90465 | 2012-10-13 02:03:45 +0000 | [diff] [blame] | 2715 | return *this; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2716 | } |
| 2717 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2718 | template<class _Rp, class ..._ArgTypes> |
| 2719 | function<_Rp(_ArgTypes...)>& |
| 2720 | function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2721 | { |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2722 | __f_ = nullptr; |
Argyrios Kyrtzidis | af90465 | 2012-10-13 02:03:45 +0000 | [diff] [blame] | 2723 | return *this; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2724 | } |
| 2725 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2726 | template<class _Rp, class ..._ArgTypes> |
Eric Fiselier | 43c04f7 | 2017-09-10 23:41:20 +0000 | [diff] [blame] | 2727 | template <class _Fp, class> |
| 2728 | function<_Rp(_ArgTypes...)>& |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2729 | function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2730 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2731 | function(_VSTD::forward<_Fp>(__f)).swap(*this); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2732 | return *this; |
| 2733 | } |
| 2734 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2735 | template<class _Rp, class ..._ArgTypes> |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2736 | function<_Rp(_ArgTypes...)>::~function() {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2737 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2738 | template<class _Rp, class ..._ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2739 | void |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2740 | function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2741 | { |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2742 | __f_.swap(__f.__f_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2743 | } |
| 2744 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2745 | template<class _Rp, class ..._ArgTypes> |
| 2746 | _Rp |
| 2747 | function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2748 | { |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2749 | return __f_(_VSTD::forward<_ArgTypes>(__arg)...); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2750 | } |
| 2751 | |
Howard Hinnant | 72f7358 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 2752 | #ifndef _LIBCPP_NO_RTTI |
| 2753 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2754 | template<class _Rp, class ..._ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2755 | const std::type_info& |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2756 | function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2757 | { |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2758 | return __f_.target_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2759 | } |
| 2760 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2761 | template<class _Rp, class ..._ArgTypes> |
| 2762 | template <typename _Tp> |
| 2763 | _Tp* |
| 2764 | function<_Rp(_ArgTypes...)>::target() _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2765 | { |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2766 | return (_Tp*)(__f_.template target<_Tp>()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2767 | } |
| 2768 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2769 | template<class _Rp, class ..._ArgTypes> |
| 2770 | template <typename _Tp> |
| 2771 | const _Tp* |
| 2772 | function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2773 | { |
Eric Fiselier | 125798e | 2018-12-10 18:14:09 +0000 | [diff] [blame] | 2774 | return __f_.template target<_Tp>(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2775 | } |
| 2776 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2777 | #endif // _LIBCPP_NO_RTTI |
Howard Hinnant | 72f7358 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 2778 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2779 | template <class _Rp, class... _ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2780 | inline _LIBCPP_INLINE_VISIBILITY |
| 2781 | bool |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2782 | operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2783 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2784 | template <class _Rp, class... _ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2785 | inline _LIBCPP_INLINE_VISIBILITY |
| 2786 | bool |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2787 | operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2788 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2789 | template <class _Rp, class... _ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2790 | inline _LIBCPP_INLINE_VISIBILITY |
| 2791 | bool |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2792 | operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2793 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2794 | template <class _Rp, class... _ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2795 | inline _LIBCPP_INLINE_VISIBILITY |
| 2796 | bool |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2797 | operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2798 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2799 | template <class _Rp, class... _ArgTypes> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2800 | inline _LIBCPP_INLINE_VISIBILITY |
| 2801 | void |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2802 | swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2803 | {return __x.swap(__y);} |
| 2804 | |
Eric Fiselier | a9ae7a6 | 2017-04-19 01:28:47 +0000 | [diff] [blame] | 2805 | #else // _LIBCPP_CXX03_LANG |
Eric Fiselier | 2cc4833 | 2015-07-22 22:43:27 +0000 | [diff] [blame] | 2806 | |
| 2807 | #include <__functional_03> |
| 2808 | |
| 2809 | #endif |
Eric Fiselier | a6f61c6 | 2015-07-22 04:14:38 +0000 | [diff] [blame] | 2810 | |
| 2811 | //////////////////////////////////////////////////////////////////////////////// |
| 2812 | // BIND |
| 2813 | //============================================================================== |
| 2814 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2815 | template<class _Tp> struct __is_bind_expression : public false_type {}; |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 2816 | template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2817 | : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; |
| 2818 | |
Marshall Clow | 2d2d7f1 | 2016-09-22 00:23:15 +0000 | [diff] [blame] | 2819 | #if _LIBCPP_STD_VER > 14 |
| 2820 | template <class _Tp> |
Marshall Clow | f1bf62f | 2018-01-02 17:17:01 +0000 | [diff] [blame] | 2821 | _LIBCPP_INLINE_VAR constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; |
Marshall Clow | 2d2d7f1 | 2016-09-22 00:23:15 +0000 | [diff] [blame] | 2822 | #endif |
| 2823 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2824 | template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 2825 | template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2826 | : public __is_placeholder<typename remove_cv<_Tp>::type> {}; |
| 2827 | |
Marshall Clow | 2d2d7f1 | 2016-09-22 00:23:15 +0000 | [diff] [blame] | 2828 | #if _LIBCPP_STD_VER > 14 |
| 2829 | template <class _Tp> |
Marshall Clow | f1bf62f | 2018-01-02 17:17:01 +0000 | [diff] [blame] | 2830 | _LIBCPP_INLINE_VAR constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; |
Marshall Clow | 2d2d7f1 | 2016-09-22 00:23:15 +0000 | [diff] [blame] | 2831 | #endif |
| 2832 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2833 | namespace placeholders |
| 2834 | { |
| 2835 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2836 | template <int _Np> struct __ph {}; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2837 | |
Louis Dionne | 5e0eadd | 2018-08-01 02:08:59 +0000 | [diff] [blame] | 2838 | #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) |
Eric Fiselier | b7f51d6 | 2016-06-26 21:01:34 +0000 | [diff] [blame] | 2839 | _LIBCPP_FUNC_VIS extern const __ph<1> _1; |
| 2840 | _LIBCPP_FUNC_VIS extern const __ph<2> _2; |
| 2841 | _LIBCPP_FUNC_VIS extern const __ph<3> _3; |
| 2842 | _LIBCPP_FUNC_VIS extern const __ph<4> _4; |
| 2843 | _LIBCPP_FUNC_VIS extern const __ph<5> _5; |
| 2844 | _LIBCPP_FUNC_VIS extern const __ph<6> _6; |
| 2845 | _LIBCPP_FUNC_VIS extern const __ph<7> _7; |
| 2846 | _LIBCPP_FUNC_VIS extern const __ph<8> _8; |
| 2847 | _LIBCPP_FUNC_VIS extern const __ph<9> _9; |
| 2848 | _LIBCPP_FUNC_VIS extern const __ph<10> _10; |
| 2849 | #else |
Marshall Clow | 396b213 | 2018-01-02 19:01:45 +0000 | [diff] [blame] | 2850 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<1> _1{}; |
| 2851 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<2> _2{}; |
| 2852 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<3> _3{}; |
| 2853 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<4> _4{}; |
| 2854 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<5> _5{}; |
| 2855 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<6> _6{}; |
| 2856 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<7> _7{}; |
| 2857 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<8> _8{}; |
| 2858 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<9> _9{}; |
| 2859 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{}; |
Louis Dionne | 5e0eadd | 2018-08-01 02:08:59 +0000 | [diff] [blame] | 2860 | #endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2861 | |
| 2862 | } // placeholders |
| 2863 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2864 | template<int _Np> |
| 2865 | struct __is_placeholder<placeholders::__ph<_Np> > |
| 2866 | : public integral_constant<int, _Np> {}; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2867 | |
Eric Fiselier | a6f61c6 | 2015-07-22 04:14:38 +0000 | [diff] [blame] | 2868 | |
Eric Fiselier | a9ae7a6 | 2017-04-19 01:28:47 +0000 | [diff] [blame] | 2869 | #ifndef _LIBCPP_CXX03_LANG |
Eric Fiselier | a6f61c6 | 2015-07-22 04:14:38 +0000 | [diff] [blame] | 2870 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2871 | template <class _Tp, class _Uj> |
| 2872 | inline _LIBCPP_INLINE_VISIBILITY |
| 2873 | _Tp& |
| 2874 | __mu(reference_wrapper<_Tp> __t, _Uj&) |
| 2875 | { |
| 2876 | return __t.get(); |
| 2877 | } |
| 2878 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2879 | template <class _Ti, class ..._Uj, size_t ..._Indx> |
| 2880 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c1132eb | 2011-05-19 19:41:47 +0000 | [diff] [blame] | 2881 | typename __invoke_of<_Ti&, _Uj...>::type |
| 2882 | __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2883 | { |
Marshall Clow | 60e4aa7 | 2014-06-24 00:46:19 +0000 | [diff] [blame] | 2884 | return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2885 | } |
| 2886 | |
| 2887 | template <class _Ti, class ..._Uj> |
| 2888 | inline _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 3906a13 | 2019-06-23 20:28:29 +0000 | [diff] [blame] | 2889 | typename _EnableIf |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2890 | < |
| 2891 | is_bind_expression<_Ti>::value, |
Eric Fiselier | f3a1cea | 2014-12-23 05:54:34 +0000 | [diff] [blame] | 2892 | __invoke_of<_Ti&, _Uj...> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2893 | >::type |
| 2894 | __mu(_Ti& __ti, tuple<_Uj...>& __uj) |
| 2895 | { |
| 2896 | typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; |
Arthur O'Dwyer | 34465da | 2020-12-15 19:32:29 -0500 | [diff] [blame] | 2897 | return _VSTD::__mu_expand(__ti, __uj, __indices()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2898 | } |
| 2899 | |
| 2900 | template <bool IsPh, class _Ti, class _Uj> |
| 2901 | struct __mu_return2 {}; |
| 2902 | |
| 2903 | template <class _Ti, class _Uj> |
| 2904 | struct __mu_return2<true, _Ti, _Uj> |
| 2905 | { |
| 2906 | typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type; |
| 2907 | }; |
| 2908 | |
| 2909 | template <class _Ti, class _Uj> |
| 2910 | inline _LIBCPP_INLINE_VISIBILITY |
| 2911 | typename enable_if |
| 2912 | < |
| 2913 | 0 < is_placeholder<_Ti>::value, |
| 2914 | typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type |
| 2915 | >::type |
| 2916 | __mu(_Ti&, _Uj& __uj) |
| 2917 | { |
| 2918 | const size_t _Indx = is_placeholder<_Ti>::value - 1; |
Marshall Clow | 60e4aa7 | 2014-06-24 00:46:19 +0000 | [diff] [blame] | 2919 | return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2920 | } |
| 2921 | |
| 2922 | template <class _Ti, class _Uj> |
| 2923 | inline _LIBCPP_INLINE_VISIBILITY |
| 2924 | typename enable_if |
| 2925 | < |
| 2926 | !is_bind_expression<_Ti>::value && |
| 2927 | is_placeholder<_Ti>::value == 0 && |
| 2928 | !__is_reference_wrapper<_Ti>::value, |
| 2929 | _Ti& |
| 2930 | >::type |
Howard Hinnant | 28b2488 | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 2931 | __mu(_Ti& __ti, _Uj&) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2932 | { |
| 2933 | return __ti; |
| 2934 | } |
| 2935 | |
Howard Hinnant | 0415d79 | 2011-05-22 15:07:43 +0000 | [diff] [blame] | 2936 | template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, |
| 2937 | class _TupleUj> |
Louis Dionne | cbbd7b1 | 2018-09-23 16:44:50 +0000 | [diff] [blame] | 2938 | struct __mu_return_impl; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2939 | |
Howard Hinnant | 51dae7a | 2013-06-30 19:48:15 +0000 | [diff] [blame] | 2940 | template <bool _Invokable, class _Ti, class ..._Uj> |
Louis Dionne | cbbd7b1 | 2018-09-23 16:44:50 +0000 | [diff] [blame] | 2941 | struct __mu_return_invokable // false |
Howard Hinnant | 51dae7a | 2013-06-30 19:48:15 +0000 | [diff] [blame] | 2942 | { |
| 2943 | typedef __nat type; |
| 2944 | }; |
| 2945 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2946 | template <class _Ti, class ..._Uj> |
Louis Dionne | cbbd7b1 | 2018-09-23 16:44:50 +0000 | [diff] [blame] | 2947 | struct __mu_return_invokable<true, _Ti, _Uj...> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2948 | { |
Howard Hinnant | c1132eb | 2011-05-19 19:41:47 +0000 | [diff] [blame] | 2949 | typedef typename __invoke_of<_Ti&, _Uj...>::type type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2950 | }; |
| 2951 | |
Howard Hinnant | 51dae7a | 2013-06-30 19:48:15 +0000 | [diff] [blame] | 2952 | template <class _Ti, class ..._Uj> |
Louis Dionne | cbbd7b1 | 2018-09-23 16:44:50 +0000 | [diff] [blame] | 2953 | struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> > |
| 2954 | : public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> |
Howard Hinnant | 51dae7a | 2013-06-30 19:48:15 +0000 | [diff] [blame] | 2955 | { |
| 2956 | }; |
| 2957 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2958 | template <class _Ti, class _TupleUj> |
Louis Dionne | cbbd7b1 | 2018-09-23 16:44:50 +0000 | [diff] [blame] | 2959 | struct __mu_return_impl<_Ti, false, false, true, _TupleUj> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2960 | { |
| 2961 | typedef typename tuple_element<is_placeholder<_Ti>::value - 1, |
| 2962 | _TupleUj>::type&& type; |
| 2963 | }; |
| 2964 | |
| 2965 | template <class _Ti, class _TupleUj> |
Louis Dionne | cbbd7b1 | 2018-09-23 16:44:50 +0000 | [diff] [blame] | 2966 | struct __mu_return_impl<_Ti, true, false, false, _TupleUj> |
Howard Hinnant | 0415d79 | 2011-05-22 15:07:43 +0000 | [diff] [blame] | 2967 | { |
| 2968 | typedef typename _Ti::type& type; |
| 2969 | }; |
| 2970 | |
| 2971 | template <class _Ti, class _TupleUj> |
Louis Dionne | cbbd7b1 | 2018-09-23 16:44:50 +0000 | [diff] [blame] | 2972 | struct __mu_return_impl<_Ti, false, false, false, _TupleUj> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2973 | { |
| 2974 | typedef _Ti& type; |
| 2975 | }; |
| 2976 | |
| 2977 | template <class _Ti, class _TupleUj> |
| 2978 | struct __mu_return |
Louis Dionne | cbbd7b1 | 2018-09-23 16:44:50 +0000 | [diff] [blame] | 2979 | : public __mu_return_impl<_Ti, |
| 2980 | __is_reference_wrapper<_Ti>::value, |
| 2981 | is_bind_expression<_Ti>::value, |
| 2982 | 0 < is_placeholder<_Ti>::value && |
| 2983 | is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, |
| 2984 | _TupleUj> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2985 | { |
| 2986 | }; |
| 2987 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2988 | template <class _Fp, class _BoundArgs, class _TupleUj> |
Eric Fiselier | 99fffba | 2015-05-19 22:27:18 +0000 | [diff] [blame] | 2989 | struct __is_valid_bind_return |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 2990 | { |
| 2991 | static const bool value = false; |
| 2992 | }; |
| 2993 | |
| 2994 | template <class _Fp, class ..._BoundArgs, class _TupleUj> |
Eric Fiselier | 99fffba | 2015-05-19 22:27:18 +0000 | [diff] [blame] | 2995 | struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 2996 | { |
| 2997 | static const bool value = __invokable<_Fp, |
| 2998 | typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; |
| 2999 | }; |
| 3000 | |
| 3001 | template <class _Fp, class ..._BoundArgs, class _TupleUj> |
Eric Fiselier | 99fffba | 2015-05-19 22:27:18 +0000 | [diff] [blame] | 3002 | struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3003 | { |
| 3004 | static const bool value = __invokable<_Fp, |
| 3005 | typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value; |
| 3006 | }; |
| 3007 | |
| 3008 | template <class _Fp, class _BoundArgs, class _TupleUj, |
Eric Fiselier | 99fffba | 2015-05-19 22:27:18 +0000 | [diff] [blame] | 3009 | bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3010 | struct __bind_return; |
| 3011 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3012 | template <class _Fp, class ..._BoundArgs, class _TupleUj> |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3013 | struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3014 | { |
Howard Hinnant | c1132eb | 2011-05-19 19:41:47 +0000 | [diff] [blame] | 3015 | typedef typename __invoke_of |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3016 | < |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3017 | _Fp&, |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3018 | typename __mu_return |
| 3019 | < |
| 3020 | _BoundArgs, |
| 3021 | _TupleUj |
| 3022 | >::type... |
| 3023 | >::type type; |
| 3024 | }; |
| 3025 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3026 | template <class _Fp, class ..._BoundArgs, class _TupleUj> |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3027 | struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3028 | { |
Howard Hinnant | c1132eb | 2011-05-19 19:41:47 +0000 | [diff] [blame] | 3029 | typedef typename __invoke_of |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3030 | < |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3031 | _Fp&, |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3032 | typename __mu_return |
| 3033 | < |
| 3034 | const _BoundArgs, |
| 3035 | _TupleUj |
| 3036 | >::type... |
| 3037 | >::type type; |
| 3038 | }; |
| 3039 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3040 | template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3041 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3042 | typename __bind_return<_Fp, _BoundArgs, _Args>::type |
| 3043 | __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3044 | _Args&& __args) |
| 3045 | { |
Eric Fiselier | 17264eb | 2017-05-03 21:02:19 +0000 | [diff] [blame] | 3046 | return _VSTD::__invoke(__f, _VSTD::__mu(_VSTD::get<_Indx>(__bound_args), __args)...); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3047 | } |
| 3048 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3049 | template<class _Fp, class ..._BoundArgs> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3050 | class __bind |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 3051 | #if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3052 | : public __weak_result_type<typename decay<_Fp>::type> |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 3053 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3054 | { |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3055 | protected: |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3056 | typedef typename decay<_Fp>::type _Fd; |
Howard Hinnant | c1132eb | 2011-05-19 19:41:47 +0000 | [diff] [blame] | 3057 | typedef tuple<typename decay<_BoundArgs>::type...> _Td; |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3058 | private: |
Howard Hinnant | c1132eb | 2011-05-19 19:41:47 +0000 | [diff] [blame] | 3059 | _Fd __f_; |
| 3060 | _Td __bound_args_; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3061 | |
| 3062 | typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; |
| 3063 | public: |
Howard Hinnant | 0337ade | 2012-05-04 17:21:02 +0000 | [diff] [blame] | 3064 | template <class _Gp, class ..._BA, |
| 3065 | class = typename enable_if |
| 3066 | < |
Howard Hinnant | f292a92 | 2013-07-01 00:01:51 +0000 | [diff] [blame] | 3067 | is_constructible<_Fd, _Gp>::value && |
| 3068 | !is_same<typename remove_reference<_Gp>::type, |
| 3069 | __bind>::value |
Howard Hinnant | 0337ade | 2012-05-04 17:21:02 +0000 | [diff] [blame] | 3070 | >::type> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 3071 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3072 | explicit __bind(_Gp&& __f, _BA&& ...__bound_args) |
| 3073 | : __f_(_VSTD::forward<_Gp>(__f)), |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3074 | __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3075 | |
| 3076 | template <class ..._Args> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 3077 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Howard Hinnant | c1132eb | 2011-05-19 19:41:47 +0000 | [diff] [blame] | 3078 | typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3079 | operator()(_Args&& ...__args) |
| 3080 | { |
Eric Fiselier | 17264eb | 2017-05-03 21:02:19 +0000 | [diff] [blame] | 3081 | return _VSTD::__apply_functor(__f_, __bound_args_, __indices(), |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3082 | tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3083 | } |
| 3084 | |
| 3085 | template <class ..._Args> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 3086 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3087 | typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3088 | operator()(_Args&& ...__args) const |
| 3089 | { |
Eric Fiselier | 17264eb | 2017-05-03 21:02:19 +0000 | [diff] [blame] | 3090 | return _VSTD::__apply_functor(__f_, __bound_args_, __indices(), |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3091 | tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3092 | } |
| 3093 | }; |
| 3094 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3095 | template<class _Fp, class ..._BoundArgs> |
| 3096 | struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3097 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3098 | template<class _Rp, class _Fp, class ..._BoundArgs> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3099 | class __bind_r |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3100 | : public __bind<_Fp, _BoundArgs...> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3101 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3102 | typedef __bind<_Fp, _BoundArgs...> base; |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3103 | typedef typename base::_Fd _Fd; |
| 3104 | typedef typename base::_Td _Td; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3105 | public: |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3106 | typedef _Rp result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3107 | |
Howard Hinnant | 7091e65 | 2011-07-02 18:22:36 +0000 | [diff] [blame] | 3108 | |
Howard Hinnant | f292a92 | 2013-07-01 00:01:51 +0000 | [diff] [blame] | 3109 | template <class _Gp, class ..._BA, |
| 3110 | class = typename enable_if |
| 3111 | < |
| 3112 | is_constructible<_Fd, _Gp>::value && |
| 3113 | !is_same<typename remove_reference<_Gp>::type, |
| 3114 | __bind_r>::value |
| 3115 | >::type> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 3116 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3117 | explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) |
| 3118 | : base(_VSTD::forward<_Gp>(__f), |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3119 | _VSTD::forward<_BA>(__bound_args)...) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3120 | |
| 3121 | template <class ..._Args> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 3122 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3123 | typename enable_if |
| 3124 | < |
| 3125 | is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, |
Eric Fiselier | 7a8710a | 2015-07-10 23:29:18 +0000 | [diff] [blame] | 3126 | result_type>::value || is_void<_Rp>::value, |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3127 | result_type |
| 3128 | >::type |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3129 | operator()(_Args&& ...__args) |
| 3130 | { |
Eric Fiselier | 7a8710a | 2015-07-10 23:29:18 +0000 | [diff] [blame] | 3131 | typedef __invoke_void_return_wrapper<_Rp> _Invoker; |
| 3132 | return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3133 | } |
| 3134 | |
| 3135 | template <class ..._Args> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 3136 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3137 | typename enable_if |
| 3138 | < |
| 3139 | is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type, |
Eric Fiselier | 7a8710a | 2015-07-10 23:29:18 +0000 | [diff] [blame] | 3140 | result_type>::value || is_void<_Rp>::value, |
Howard Hinnant | de3a5f0 | 2013-02-21 18:16:55 +0000 | [diff] [blame] | 3141 | result_type |
| 3142 | >::type |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3143 | operator()(_Args&& ...__args) const |
| 3144 | { |
Eric Fiselier | 7a8710a | 2015-07-10 23:29:18 +0000 | [diff] [blame] | 3145 | typedef __invoke_void_return_wrapper<_Rp> _Invoker; |
| 3146 | return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3147 | } |
| 3148 | }; |
| 3149 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3150 | template<class _Rp, class _Fp, class ..._BoundArgs> |
| 3151 | struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3152 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3153 | template<class _Fp, class ..._BoundArgs> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 3154 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3155 | __bind<_Fp, _BoundArgs...> |
| 3156 | bind(_Fp&& __f, _BoundArgs&&... __bound_args) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3157 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3158 | typedef __bind<_Fp, _BoundArgs...> type; |
| 3159 | return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3160 | } |
| 3161 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3162 | template<class _Rp, class _Fp, class ..._BoundArgs> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 3163 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3164 | __bind_r<_Rp, _Fp, _BoundArgs...> |
| 3165 | bind(_Fp&& __f, _BoundArgs&&... __bound_args) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3166 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3167 | typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; |
| 3168 | return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3169 | } |
| 3170 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3171 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3172 | |
Eric Fiselier | 0d974f1 | 2015-07-14 20:16:15 +0000 | [diff] [blame] | 3173 | #if _LIBCPP_STD_VER > 14 |
Eric Fiselier | 934f63b | 2016-06-02 01:25:41 +0000 | [diff] [blame] | 3174 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3175 | template<class _Op, class _Tuple, |
| 3176 | class _Idxs = typename __make_tuple_indices<tuple_size<_Tuple>::value>::type> |
| 3177 | struct __perfect_forward_impl; |
Eric Fiselier | 934f63b | 2016-06-02 01:25:41 +0000 | [diff] [blame] | 3178 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3179 | template<class _Op, class... _Bound, size_t... _Idxs> |
| 3180 | struct __perfect_forward_impl<_Op, __tuple_types<_Bound...>, __tuple_indices<_Idxs...>> |
| 3181 | { |
| 3182 | tuple<_Bound...> __bound_; |
Eric Fiselier | 934f63b | 2016-06-02 01:25:41 +0000 | [diff] [blame] | 3183 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3184 | template<class... _Args> |
| 3185 | _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) & |
| 3186 | noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))) |
| 3187 | -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)) |
| 3188 | {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);} |
Eric Fiselier | 934f63b | 2016-06-02 01:25:41 +0000 | [diff] [blame] | 3189 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3190 | template<class... _Args> |
| 3191 | _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const& |
| 3192 | noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))) |
| 3193 | -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)) |
| 3194 | {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);} |
Eric Fiselier | e8303a3 | 2016-06-27 00:40:41 +0000 | [diff] [blame] | 3195 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3196 | template<class... _Args> |
| 3197 | _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) && |
| 3198 | noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., |
| 3199 | _VSTD::forward<_Args>(__args)...))) |
| 3200 | -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., |
| 3201 | _VSTD::forward<_Args>(__args)...)) |
| 3202 | {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., |
| 3203 | _VSTD::forward<_Args>(__args)...);} |
Eric Fiselier | 934f63b | 2016-06-02 01:25:41 +0000 | [diff] [blame] | 3204 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3205 | template<class... _Args> |
| 3206 | _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const&& |
| 3207 | noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., |
| 3208 | _VSTD::forward<_Args>(__args)...))) |
| 3209 | -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., |
| 3210 | _VSTD::forward<_Args>(__args)...)) |
| 3211 | {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., |
| 3212 | _VSTD::forward<_Args>(__args)...);} |
Eric Fiselier | e8303a3 | 2016-06-27 00:40:41 +0000 | [diff] [blame] | 3213 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3214 | template<class _Fn = typename tuple_element<0, tuple<_Bound...>>::type, |
| 3215 | class = _EnableIf<is_copy_constructible_v<_Fn>>> |
| 3216 | constexpr __perfect_forward_impl(__perfect_forward_impl const& __other) |
| 3217 | : __bound_(__other.__bound_) {} |
Eric Fiselier | e8303a3 | 2016-06-27 00:40:41 +0000 | [diff] [blame] | 3218 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3219 | template<class _Fn = typename tuple_element<0, tuple<_Bound...>>::type, |
| 3220 | class = _EnableIf<is_move_constructible_v<_Fn>>> |
| 3221 | constexpr __perfect_forward_impl(__perfect_forward_impl && __other) |
| 3222 | : __bound_(_VSTD::move(__other.__bound_)) {} |
Eric Fiselier | 934f63b | 2016-06-02 01:25:41 +0000 | [diff] [blame] | 3223 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3224 | template<class... _BoundArgs> |
| 3225 | explicit constexpr __perfect_forward_impl(_BoundArgs&&... __bound) : |
| 3226 | __bound_(_VSTD::forward<_BoundArgs>(__bound)...) { } |
Eric Fiselier | 934f63b | 2016-06-02 01:25:41 +0000 | [diff] [blame] | 3227 | }; |
| 3228 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3229 | template<class _Op, class... _Args> |
| 3230 | using __perfect_forward = |
| 3231 | __perfect_forward_impl<_Op, __tuple_types<decay_t<_Args>...>>; |
| 3232 | |
| 3233 | struct __not_fn_op |
| 3234 | { |
| 3235 | template<class... _Args> |
| 3236 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 auto __call(_Args&&... __args) |
| 3237 | noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) |
| 3238 | -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...)) |
| 3239 | { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); } |
| 3240 | }; |
| 3241 | |
| 3242 | template<class _Fn, |
| 3243 | class = _EnableIf<is_constructible_v<decay_t<_Fn>, _Fn> && |
| 3244 | is_move_constructible_v<_Fn>>> |
| 3245 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) |
| 3246 | { |
| 3247 | return __perfect_forward<__not_fn_op, _Fn>(_VSTD::forward<_Fn>(__f)); |
Eric Fiselier | 934f63b | 2016-06-02 01:25:41 +0000 | [diff] [blame] | 3248 | } |
| 3249 | |
zoecarver | 3595cac | 2021-03-02 16:17:22 -0800 | [diff] [blame] | 3250 | #endif // _LIBCPP_STD_VER > 14 |
| 3251 | |
| 3252 | #if _LIBCPP_STD_VER > 17 |
| 3253 | |
| 3254 | struct __bind_front_op |
| 3255 | { |
| 3256 | template<class... _Args> |
| 3257 | constexpr static auto __call(_Args&&... __args) |
| 3258 | noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) |
| 3259 | -> decltype( _VSTD::invoke(_VSTD::forward<_Args>(__args)...)) |
| 3260 | { return _VSTD::invoke(_VSTD::forward<_Args>(__args)...); } |
| 3261 | }; |
| 3262 | |
| 3263 | template<class _Fn, class... _Args, |
| 3264 | class = _EnableIf<conjunction<is_constructible<decay_t<_Fn>, _Fn>, |
| 3265 | is_move_constructible<decay_t<_Fn>>, |
| 3266 | is_constructible<decay_t<_Args>, _Args>..., |
| 3267 | is_move_constructible<decay_t<_Args>>... |
| 3268 | >::value>> |
| 3269 | constexpr auto bind_front(_Fn&& __f, _Args&&... __args) |
| 3270 | { |
| 3271 | return __perfect_forward<__bind_front_op, _Fn, _Args...>(_VSTD::forward<_Fn>(__f), |
| 3272 | _VSTD::forward<_Args>(__args)...); |
| 3273 | } |
| 3274 | |
| 3275 | #endif // _LIBCPP_STD_VER > 17 |
Eric Fiselier | 0d974f1 | 2015-07-14 20:16:15 +0000 | [diff] [blame] | 3276 | |
Howard Hinnant | 36b31ae | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3277 | // struct hash<T*> in <memory> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3278 | |
Marshall Clow | a40686b | 2018-01-08 19:18:00 +0000 | [diff] [blame] | 3279 | #if _LIBCPP_STD_VER > 14 |
| 3280 | |
| 3281 | // default searcher |
| 3282 | template<class _ForwardIterator, class _BinaryPredicate = equal_to<>> |
Martin Storsjö | 4d6f221 | 2021-04-06 10:55:33 +0300 | [diff] [blame] | 3283 | class _LIBCPP_TEMPLATE_VIS default_searcher { |
Marshall Clow | a40686b | 2018-01-08 19:18:00 +0000 | [diff] [blame] | 3284 | public: |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 3285 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 3286 | default_searcher(_ForwardIterator __f, _ForwardIterator __l, |
Marshall Clow | a40686b | 2018-01-08 19:18:00 +0000 | [diff] [blame] | 3287 | _BinaryPredicate __p = _BinaryPredicate()) |
| 3288 | : __first_(__f), __last_(__l), __pred_(__p) {} |
| 3289 | |
| 3290 | template <typename _ForwardIterator2> |
Arthur O'Dwyer | 81449d3 | 2020-12-25 14:48:39 -0500 | [diff] [blame] | 3291 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Marshall Clow | a40686b | 2018-01-08 19:18:00 +0000 | [diff] [blame] | 3292 | pair<_ForwardIterator2, _ForwardIterator2> |
| 3293 | operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const |
| 3294 | { |
| 3295 | return _VSTD::__search(__f, __l, __first_, __last_, __pred_, |
Arthur O'Dwyer | d8dddf5 | 2021-05-10 13:13:04 -0400 | [diff] [blame] | 3296 | typename iterator_traits<_ForwardIterator>::iterator_category(), |
| 3297 | typename iterator_traits<_ForwardIterator2>::iterator_category()); |
Marshall Clow | a40686b | 2018-01-08 19:18:00 +0000 | [diff] [blame] | 3298 | } |
| 3299 | |
| 3300 | private: |
| 3301 | _ForwardIterator __first_; |
| 3302 | _ForwardIterator __last_; |
| 3303 | _BinaryPredicate __pred_; |
Eric Fiselier | 80663c5 | 2019-08-04 07:13:43 +0000 | [diff] [blame] | 3304 | }; |
Marshall Clow | a40686b | 2018-01-08 19:18:00 +0000 | [diff] [blame] | 3305 | |
| 3306 | #endif // _LIBCPP_STD_VER > 14 |
| 3307 | |
Louis Dionne | db1892a | 2018-12-03 14:03:27 +0000 | [diff] [blame] | 3308 | #if _LIBCPP_STD_VER > 17 |
| 3309 | template <class _Tp> |
| 3310 | using unwrap_reference_t = typename unwrap_reference<_Tp>::type; |
| 3311 | |
| 3312 | template <class _Tp> |
| 3313 | using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; |
| 3314 | #endif // > C++17 |
| 3315 | |
Christopher Di Bella | e68ec58 | 2021-03-18 17:21:35 +0000 | [diff] [blame] | 3316 | #if _LIBCPP_STD_VER > 17 |
| 3317 | // [func.identity] |
| 3318 | struct identity { |
| 3319 | template<class _Tp> |
Arthur O'Dwyer | 108facb | 2021-04-05 14:56:03 -0400 | [diff] [blame] | 3320 | _LIBCPP_NODISCARD_EXT constexpr _Tp&& operator()(_Tp&& __t) const noexcept |
Christopher Di Bella | e68ec58 | 2021-03-18 17:21:35 +0000 | [diff] [blame] | 3321 | { |
| 3322 | return _VSTD::forward<_Tp>(__t); |
| 3323 | } |
| 3324 | |
| 3325 | using is_transparent = void; |
| 3326 | }; |
| 3327 | #endif // _LIBCPP_STD_VER > 17 |
| 3328 | |
zoecarver | 9ce102c | 2021-04-22 17:33:04 -0700 | [diff] [blame] | 3329 | #if !defined(_LIBCPP_HAS_NO_RANGES) |
| 3330 | |
| 3331 | namespace ranges { |
| 3332 | |
| 3333 | struct equal_to { |
| 3334 | template <class _Tp, class _Up> |
| 3335 | requires equality_comparable_with<_Tp, _Up> |
| 3336 | [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const |
| 3337 | noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)))) { |
| 3338 | return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u); |
| 3339 | } |
| 3340 | |
| 3341 | using is_transparent = void; |
| 3342 | }; |
| 3343 | |
| 3344 | struct not_equal_to { |
| 3345 | template <class _Tp, class _Up> |
| 3346 | requires equality_comparable_with<_Tp, _Up> |
| 3347 | [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const |
| 3348 | noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u))))) { |
| 3349 | return !(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)); |
| 3350 | } |
| 3351 | |
| 3352 | using is_transparent = void; |
| 3353 | }; |
| 3354 | |
| 3355 | struct greater { |
| 3356 | template <class _Tp, class _Up> |
| 3357 | requires totally_ordered_with<_Tp, _Up> |
| 3358 | [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const |
| 3359 | noexcept(noexcept(bool(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)))) { |
| 3360 | return _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t); |
| 3361 | } |
| 3362 | |
| 3363 | using is_transparent = void; |
| 3364 | }; |
| 3365 | |
| 3366 | struct less { |
| 3367 | template <class _Tp, class _Up> |
| 3368 | requires totally_ordered_with<_Tp, _Up> |
| 3369 | [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const |
| 3370 | noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)))) { |
| 3371 | return _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u); |
| 3372 | } |
| 3373 | |
| 3374 | using is_transparent = void; |
| 3375 | }; |
| 3376 | |
| 3377 | struct greater_equal { |
| 3378 | template <class _Tp, class _Up> |
| 3379 | requires totally_ordered_with<_Tp, _Up> |
| 3380 | [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const |
| 3381 | noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u))))) { |
| 3382 | return !(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)); |
| 3383 | } |
| 3384 | |
| 3385 | using is_transparent = void; |
| 3386 | }; |
| 3387 | |
| 3388 | struct less_equal { |
| 3389 | template <class _Tp, class _Up> |
| 3390 | requires totally_ordered_with<_Tp, _Up> |
| 3391 | [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const |
| 3392 | noexcept(noexcept(bool(!(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t))))) { |
| 3393 | return !(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)); |
| 3394 | } |
| 3395 | |
| 3396 | using is_transparent = void; |
| 3397 | }; |
| 3398 | |
| 3399 | } // namespace ranges |
| 3400 | |
| 3401 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) |
| 3402 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3403 | _LIBCPP_END_NAMESPACE_STD |
| 3404 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3405 | #endif // _LIBCPP_FUNCTIONAL |