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