Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | 9bd9388 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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_VALARRAY |
| 11 | #define _LIBCPP_VALARRAY |
| 12 | |
| 13 | /* |
| 14 | valarray synopsis |
| 15 | |
| 16 | namespace std |
| 17 | { |
| 18 | |
| 19 | template<class T> |
| 20 | class valarray |
| 21 | { |
| 22 | public: |
| 23 | typedef T value_type; |
| 24 | |
| 25 | // construct/destroy: |
| 26 | valarray(); |
| 27 | explicit valarray(size_t n); |
| 28 | valarray(const value_type& x, size_t n); |
| 29 | valarray(const value_type* px, size_t n); |
| 30 | valarray(const valarray& v); |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 31 | valarray(valarray&& v) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 32 | valarray(const slice_array<value_type>& sa); |
| 33 | valarray(const gslice_array<value_type>& ga); |
| 34 | valarray(const mask_array<value_type>& ma); |
| 35 | valarray(const indirect_array<value_type>& ia); |
| 36 | valarray(initializer_list<value_type> il); |
| 37 | ~valarray(); |
| 38 | |
| 39 | // assignment: |
| 40 | valarray& operator=(const valarray& v); |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 41 | valarray& operator=(valarray&& v) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 42 | valarray& operator=(initializer_list<value_type> il); |
| 43 | valarray& operator=(const value_type& x); |
| 44 | valarray& operator=(const slice_array<value_type>& sa); |
| 45 | valarray& operator=(const gslice_array<value_type>& ga); |
| 46 | valarray& operator=(const mask_array<value_type>& ma); |
| 47 | valarray& operator=(const indirect_array<value_type>& ia); |
| 48 | |
| 49 | // element access: |
| 50 | const value_type& operator[](size_t i) const; |
| 51 | value_type& operator[](size_t i); |
| 52 | |
| 53 | // subset operations: |
| 54 | valarray operator[](slice s) const; |
| 55 | slice_array<value_type> operator[](slice s); |
| 56 | valarray operator[](const gslice& gs) const; |
| 57 | gslice_array<value_type> operator[](const gslice& gs); |
| 58 | valarray operator[](const valarray<bool>& vb) const; |
| 59 | mask_array<value_type> operator[](const valarray<bool>& vb); |
| 60 | valarray operator[](const valarray<size_t>& vs) const; |
| 61 | indirect_array<value_type> operator[](const valarray<size_t>& vs); |
| 62 | |
| 63 | // unary operators: |
| 64 | valarray operator+() const; |
| 65 | valarray operator-() const; |
| 66 | valarray operator~() const; |
| 67 | valarray<bool> operator!() const; |
| 68 | |
| 69 | // computed assignment: |
| 70 | valarray& operator*= (const value_type& x); |
| 71 | valarray& operator/= (const value_type& x); |
| 72 | valarray& operator%= (const value_type& x); |
| 73 | valarray& operator+= (const value_type& x); |
| 74 | valarray& operator-= (const value_type& x); |
| 75 | valarray& operator^= (const value_type& x); |
| 76 | valarray& operator&= (const value_type& x); |
| 77 | valarray& operator|= (const value_type& x); |
| 78 | valarray& operator<<=(const value_type& x); |
| 79 | valarray& operator>>=(const value_type& x); |
| 80 | |
| 81 | valarray& operator*= (const valarray& v); |
| 82 | valarray& operator/= (const valarray& v); |
| 83 | valarray& operator%= (const valarray& v); |
| 84 | valarray& operator+= (const valarray& v); |
| 85 | valarray& operator-= (const valarray& v); |
| 86 | valarray& operator^= (const valarray& v); |
| 87 | valarray& operator|= (const valarray& v); |
| 88 | valarray& operator&= (const valarray& v); |
| 89 | valarray& operator<<=(const valarray& v); |
| 90 | valarray& operator>>=(const valarray& v); |
| 91 | |
| 92 | // member functions: |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 93 | void swap(valarray& v) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 94 | |
| 95 | size_t size() const; |
| 96 | |
| 97 | value_type sum() const; |
| 98 | value_type min() const; |
| 99 | value_type max() const; |
| 100 | |
| 101 | valarray shift (int i) const; |
| 102 | valarray cshift(int i) const; |
| 103 | valarray apply(value_type f(value_type)) const; |
| 104 | valarray apply(value_type f(const value_type&)) const; |
| 105 | void resize(size_t n, value_type x = value_type()); |
| 106 | }; |
| 107 | |
Konstantin Varlamov | ebb3119 | 2021-10-28 00:36:19 -0700 | [diff] [blame] | 108 | template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>; |
| 109 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 110 | class slice |
| 111 | { |
| 112 | public: |
| 113 | slice(); |
| 114 | slice(size_t start, size_t size, size_t stride); |
| 115 | |
| 116 | size_t start() const; |
| 117 | size_t size() const; |
| 118 | size_t stride() const; |
| 119 | }; |
| 120 | |
| 121 | template <class T> |
| 122 | class slice_array |
| 123 | { |
| 124 | public: |
| 125 | typedef T value_type; |
| 126 | |
| 127 | const slice_array& operator=(const slice_array& sa) const; |
| 128 | void operator= (const valarray<value_type>& v) const; |
| 129 | void operator*= (const valarray<value_type>& v) const; |
| 130 | void operator/= (const valarray<value_type>& v) const; |
| 131 | void operator%= (const valarray<value_type>& v) const; |
| 132 | void operator+= (const valarray<value_type>& v) const; |
| 133 | void operator-= (const valarray<value_type>& v) const; |
| 134 | void operator^= (const valarray<value_type>& v) const; |
| 135 | void operator&= (const valarray<value_type>& v) const; |
| 136 | void operator|= (const valarray<value_type>& v) const; |
| 137 | void operator<<=(const valarray<value_type>& v) const; |
| 138 | void operator>>=(const valarray<value_type>& v) const; |
| 139 | |
| 140 | void operator=(const value_type& x) const; |
zoecarver | 79fa750 | 2020-12-02 10:49:20 -0800 | [diff] [blame] | 141 | void operator=(const valarray<T>& val_arr) const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 142 | |
| 143 | slice_array() = delete; |
| 144 | }; |
| 145 | |
| 146 | class gslice |
| 147 | { |
| 148 | public: |
| 149 | gslice(); |
| 150 | gslice(size_t start, const valarray<size_t>& size, |
| 151 | const valarray<size_t>& stride); |
| 152 | |
| 153 | size_t start() const; |
| 154 | valarray<size_t> size() const; |
| 155 | valarray<size_t> stride() const; |
| 156 | }; |
| 157 | |
| 158 | template <class T> |
| 159 | class gslice_array |
| 160 | { |
| 161 | public: |
| 162 | typedef T value_type; |
| 163 | |
| 164 | void operator= (const valarray<value_type>& v) const; |
| 165 | void operator*= (const valarray<value_type>& v) const; |
| 166 | void operator/= (const valarray<value_type>& v) const; |
| 167 | void operator%= (const valarray<value_type>& v) const; |
| 168 | void operator+= (const valarray<value_type>& v) const; |
| 169 | void operator-= (const valarray<value_type>& v) const; |
| 170 | void operator^= (const valarray<value_type>& v) const; |
| 171 | void operator&= (const valarray<value_type>& v) const; |
| 172 | void operator|= (const valarray<value_type>& v) const; |
| 173 | void operator<<=(const valarray<value_type>& v) const; |
| 174 | void operator>>=(const valarray<value_type>& v) const; |
| 175 | |
| 176 | gslice_array(const gslice_array& ga); |
| 177 | ~gslice_array(); |
| 178 | const gslice_array& operator=(const gslice_array& ga) const; |
| 179 | void operator=(const value_type& x) const; |
| 180 | |
| 181 | gslice_array() = delete; |
| 182 | }; |
| 183 | |
| 184 | template <class T> |
| 185 | class mask_array |
| 186 | { |
| 187 | public: |
| 188 | typedef T value_type; |
| 189 | |
| 190 | void operator= (const valarray<value_type>& v) const; |
| 191 | void operator*= (const valarray<value_type>& v) const; |
| 192 | void operator/= (const valarray<value_type>& v) const; |
| 193 | void operator%= (const valarray<value_type>& v) const; |
| 194 | void operator+= (const valarray<value_type>& v) const; |
| 195 | void operator-= (const valarray<value_type>& v) const; |
| 196 | void operator^= (const valarray<value_type>& v) const; |
| 197 | void operator&= (const valarray<value_type>& v) const; |
| 198 | void operator|= (const valarray<value_type>& v) const; |
| 199 | void operator<<=(const valarray<value_type>& v) const; |
| 200 | void operator>>=(const valarray<value_type>& v) const; |
| 201 | |
| 202 | mask_array(const mask_array& ma); |
| 203 | ~mask_array(); |
| 204 | const mask_array& operator=(const mask_array& ma) const; |
| 205 | void operator=(const value_type& x) const; |
| 206 | |
| 207 | mask_array() = delete; |
| 208 | }; |
| 209 | |
| 210 | template <class T> |
| 211 | class indirect_array |
| 212 | { |
| 213 | public: |
| 214 | typedef T value_type; |
| 215 | |
| 216 | void operator= (const valarray<value_type>& v) const; |
| 217 | void operator*= (const valarray<value_type>& v) const; |
| 218 | void operator/= (const valarray<value_type>& v) const; |
| 219 | void operator%= (const valarray<value_type>& v) const; |
| 220 | void operator+= (const valarray<value_type>& v) const; |
| 221 | void operator-= (const valarray<value_type>& v) const; |
| 222 | void operator^= (const valarray<value_type>& v) const; |
| 223 | void operator&= (const valarray<value_type>& v) const; |
| 224 | void operator|= (const valarray<value_type>& v) const; |
| 225 | void operator<<=(const valarray<value_type>& v) const; |
| 226 | void operator>>=(const valarray<value_type>& v) const; |
| 227 | |
| 228 | indirect_array(const indirect_array& ia); |
| 229 | ~indirect_array(); |
| 230 | const indirect_array& operator=(const indirect_array& ia) const; |
| 231 | void operator=(const value_type& x) const; |
| 232 | |
| 233 | indirect_array() = delete; |
| 234 | }; |
| 235 | |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 236 | template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 237 | |
| 238 | template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y); |
| 239 | template<class T> valarray<T> operator* (const valarray<T>& x, const T& y); |
| 240 | template<class T> valarray<T> operator* (const T& x, const valarray<T>& y); |
| 241 | |
| 242 | template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y); |
| 243 | template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y); |
| 244 | template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y); |
| 245 | |
| 246 | template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y); |
| 247 | template<class T> valarray<T> operator% (const valarray<T>& x, const T& y); |
| 248 | template<class T> valarray<T> operator% (const T& x, const valarray<T>& y); |
| 249 | |
| 250 | template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y); |
| 251 | template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y); |
| 252 | template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y); |
| 253 | |
| 254 | template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y); |
| 255 | template<class T> valarray<T> operator- (const valarray<T>& x, const T& y); |
| 256 | template<class T> valarray<T> operator- (const T& x, const valarray<T>& y); |
| 257 | |
| 258 | template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y); |
| 259 | template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y); |
| 260 | template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y); |
| 261 | |
| 262 | template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y); |
| 263 | template<class T> valarray<T> operator& (const valarray<T>& x, const T& y); |
| 264 | template<class T> valarray<T> operator& (const T& x, const valarray<T>& y); |
| 265 | |
| 266 | template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y); |
| 267 | template<class T> valarray<T> operator| (const valarray<T>& x, const T& y); |
| 268 | template<class T> valarray<T> operator| (const T& x, const valarray<T>& y); |
| 269 | |
| 270 | template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y); |
| 271 | template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y); |
| 272 | template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y); |
| 273 | |
| 274 | template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y); |
| 275 | template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y); |
| 276 | template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y); |
| 277 | |
| 278 | template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y); |
| 279 | template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y); |
| 280 | template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y); |
| 281 | |
| 282 | template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y); |
| 283 | template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y); |
| 284 | template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y); |
| 285 | |
| 286 | template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y); |
| 287 | template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y); |
| 288 | template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y); |
| 289 | |
| 290 | template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y); |
| 291 | template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y); |
| 292 | template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y); |
| 293 | |
| 294 | template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y); |
| 295 | template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y); |
| 296 | template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y); |
| 297 | |
| 298 | template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y); |
| 299 | template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y); |
| 300 | template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y); |
| 301 | |
| 302 | template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y); |
| 303 | template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y); |
| 304 | template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y); |
| 305 | |
| 306 | template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y); |
| 307 | template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y); |
| 308 | template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y); |
| 309 | |
| 310 | template<class T> valarray<T> abs (const valarray<T>& x); |
| 311 | template<class T> valarray<T> acos (const valarray<T>& x); |
| 312 | template<class T> valarray<T> asin (const valarray<T>& x); |
| 313 | template<class T> valarray<T> atan (const valarray<T>& x); |
| 314 | |
| 315 | template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y); |
| 316 | template<class T> valarray<T> atan2(const valarray<T>& x, const T& y); |
| 317 | template<class T> valarray<T> atan2(const T& x, const valarray<T>& y); |
| 318 | |
| 319 | template<class T> valarray<T> cos (const valarray<T>& x); |
| 320 | template<class T> valarray<T> cosh (const valarray<T>& x); |
| 321 | template<class T> valarray<T> exp (const valarray<T>& x); |
| 322 | template<class T> valarray<T> log (const valarray<T>& x); |
| 323 | template<class T> valarray<T> log10(const valarray<T>& x); |
| 324 | |
| 325 | template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y); |
| 326 | template<class T> valarray<T> pow(const valarray<T>& x, const T& y); |
| 327 | template<class T> valarray<T> pow(const T& x, const valarray<T>& y); |
| 328 | |
| 329 | template<class T> valarray<T> sin (const valarray<T>& x); |
| 330 | template<class T> valarray<T> sinh (const valarray<T>& x); |
| 331 | template<class T> valarray<T> sqrt (const valarray<T>& x); |
| 332 | template<class T> valarray<T> tan (const valarray<T>& x); |
| 333 | template<class T> valarray<T> tanh (const valarray<T>& x); |
| 334 | |
| 335 | template <class T> unspecified1 begin(valarray<T>& v); |
| 336 | template <class T> unspecified2 begin(const valarray<T>& v); |
| 337 | template <class T> unspecified1 end(valarray<T>& v); |
| 338 | template <class T> unspecified2 end(const valarray<T>& v); |
| 339 | |
| 340 | } // std |
| 341 | |
| 342 | */ |
| 343 | |
Nikolas Klauser | f210d8a | 2022-02-15 18:18:08 +0100 | [diff] [blame] | 344 | #include <__algorithm/copy.h> |
| 345 | #include <__algorithm/count.h> |
| 346 | #include <__algorithm/fill.h> |
| 347 | #include <__algorithm/max_element.h> |
| 348 | #include <__algorithm/min.h> |
| 349 | #include <__algorithm/min_element.h> |
| 350 | #include <__algorithm/unwrap_iter.h> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 351 | #include <__config> |
Arthur O'Dwyer | ef18160 | 2021-05-19 11:57:04 -0400 | [diff] [blame] | 352 | #include <cmath> |
| 353 | #include <cstddef> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 354 | #include <functional> |
Arthur O'Dwyer | ef18160 | 2021-05-19 11:57:04 -0400 | [diff] [blame] | 355 | #include <initializer_list> |
Richard Smith | 1f1c147 | 2014-06-04 19:54:15 +0000 | [diff] [blame] | 356 | #include <new> |
Mark de Wever | ce8f12c | 2021-12-22 18:14:14 +0100 | [diff] [blame] | 357 | #include <version> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 358 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 359 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Arthur O'Dwyer | 6eeaa00 | 2022-02-01 20:16:40 -0500 | [diff] [blame] | 360 | # pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 361 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 362 | |
Eric Fiselier | f4433a3 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 363 | _LIBCPP_PUSH_MACROS |
| 364 | #include <__undef_macros> |
| 365 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 366 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 367 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 368 | template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 369 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 370 | class _LIBCPP_TEMPLATE_VIS slice |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 371 | { |
| 372 | size_t __start_; |
| 373 | size_t __size_; |
| 374 | size_t __stride_; |
| 375 | public: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 376 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 377 | slice() |
| 378 | : __start_(0), |
| 379 | __size_(0), |
| 380 | __stride_(0) |
| 381 | {} |
| 382 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 383 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 384 | slice(size_t __start, size_t __size, size_t __stride) |
| 385 | : __start_(__start), |
| 386 | __size_(__size), |
| 387 | __stride_(__stride) |
| 388 | {} |
| 389 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 390 | _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;} |
| 391 | _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;} |
| 392 | _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 393 | }; |
| 394 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 395 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array; |
Howard Hinnant | 8331b76 | 2013-03-06 23:30:19 +0000 | [diff] [blame] | 396 | class _LIBCPP_TYPE_VIS gslice; |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 397 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array; |
| 398 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array; |
| 399 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 400 | |
| 401 | template <class _Tp> |
Howard Hinnant | a54386e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 402 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 403 | _Tp* |
| 404 | begin(valarray<_Tp>& __v); |
| 405 | |
| 406 | template <class _Tp> |
Howard Hinnant | a54386e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 407 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 408 | const _Tp* |
| 409 | begin(const valarray<_Tp>& __v); |
| 410 | |
| 411 | template <class _Tp> |
Howard Hinnant | a54386e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 412 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 413 | _Tp* |
| 414 | end(valarray<_Tp>& __v); |
| 415 | |
| 416 | template <class _Tp> |
Howard Hinnant | a54386e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 417 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 418 | const _Tp* |
| 419 | end(const valarray<_Tp>& __v); |
| 420 | |
| 421 | template <class _Op, class _A0> |
| 422 | struct _UnaryOp |
| 423 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 424 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 425 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 426 | |
| 427 | _Op __op_; |
| 428 | _A0 __a0_; |
| 429 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 430 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 431 | _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {} |
| 432 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 433 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 434 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 435 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 436 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 437 | size_t size() const {return __a0_.size();} |
| 438 | }; |
| 439 | |
| 440 | template <class _Op, class _A0, class _A1> |
| 441 | struct _BinaryOp |
| 442 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 443 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 444 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 445 | |
| 446 | _Op __op_; |
| 447 | _A0 __a0_; |
| 448 | _A1 __a1_; |
| 449 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 450 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 451 | _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1) |
| 452 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 453 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 454 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 455 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 456 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 457 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 458 | size_t size() const {return __a0_.size();} |
| 459 | }; |
| 460 | |
| 461 | template <class _Tp> |
| 462 | class __scalar_expr |
| 463 | { |
| 464 | public: |
| 465 | typedef _Tp value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 466 | typedef const _Tp& __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 467 | private: |
| 468 | const value_type& __t_; |
| 469 | size_t __s_; |
| 470 | public: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 471 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 472 | explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {} |
| 473 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 474 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 475 | __result_type operator[](size_t) const {return __t_;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 476 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 477 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 478 | size_t size() const {return __s_;} |
| 479 | }; |
| 480 | |
| 481 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 482 | struct __unary_plus |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 483 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 484 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 485 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 486 | _Tp operator()(const _Tp& __x) const |
| 487 | {return +__x;} |
| 488 | }; |
| 489 | |
| 490 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 491 | struct __bit_not |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 492 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 493 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 494 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 495 | _Tp operator()(const _Tp& __x) const |
| 496 | {return ~__x;} |
| 497 | }; |
| 498 | |
| 499 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 500 | struct __bit_shift_left |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 501 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 502 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 503 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 504 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 505 | {return __x << __y;} |
| 506 | }; |
| 507 | |
| 508 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 509 | struct __bit_shift_right |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 510 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 511 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 512 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 513 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 514 | {return __x >> __y;} |
| 515 | }; |
| 516 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 517 | template <class _Tp, class _Fp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 518 | struct __apply_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 519 | { |
| 520 | private: |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 521 | _Fp __f_; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 522 | public: |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 523 | typedef _Tp __result_type; |
| 524 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 525 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 526 | explicit __apply_expr(_Fp __f) : __f_(__f) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 527 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 528 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 529 | _Tp operator()(const _Tp& __x) const |
| 530 | {return __f_(__x);} |
| 531 | }; |
| 532 | |
| 533 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 534 | struct __abs_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 535 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 536 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 537 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 538 | _Tp operator()(const _Tp& __x) const |
| 539 | {return abs(__x);} |
| 540 | }; |
| 541 | |
| 542 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 543 | struct __acos_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 544 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 545 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 546 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 547 | _Tp operator()(const _Tp& __x) const |
| 548 | {return acos(__x);} |
| 549 | }; |
| 550 | |
| 551 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 552 | struct __asin_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 553 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 554 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 555 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 556 | _Tp operator()(const _Tp& __x) const |
| 557 | {return asin(__x);} |
| 558 | }; |
| 559 | |
| 560 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 561 | struct __atan_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 562 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 563 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 564 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 565 | _Tp operator()(const _Tp& __x) const |
| 566 | {return atan(__x);} |
| 567 | }; |
| 568 | |
| 569 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 570 | struct __atan2_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 571 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 572 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 573 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 574 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 575 | {return atan2(__x, __y);} |
| 576 | }; |
| 577 | |
| 578 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 579 | struct __cos_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 580 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 581 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 582 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 583 | _Tp operator()(const _Tp& __x) const |
| 584 | {return cos(__x);} |
| 585 | }; |
| 586 | |
| 587 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 588 | struct __cosh_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 589 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 590 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 591 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 592 | _Tp operator()(const _Tp& __x) const |
| 593 | {return cosh(__x);} |
| 594 | }; |
| 595 | |
| 596 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 597 | struct __exp_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 598 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 599 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 600 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 601 | _Tp operator()(const _Tp& __x) const |
| 602 | {return exp(__x);} |
| 603 | }; |
| 604 | |
| 605 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 606 | struct __log_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 607 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 608 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 609 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 610 | _Tp operator()(const _Tp& __x) const |
| 611 | {return log(__x);} |
| 612 | }; |
| 613 | |
| 614 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 615 | struct __log10_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 616 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 617 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 618 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 619 | _Tp operator()(const _Tp& __x) const |
| 620 | {return log10(__x);} |
| 621 | }; |
| 622 | |
| 623 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 624 | struct __pow_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 625 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 626 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 627 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 628 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 629 | {return pow(__x, __y);} |
| 630 | }; |
| 631 | |
| 632 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 633 | struct __sin_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 634 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 635 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 636 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 637 | _Tp operator()(const _Tp& __x) const |
| 638 | {return sin(__x);} |
| 639 | }; |
| 640 | |
| 641 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 642 | struct __sinh_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 643 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 644 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 645 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 646 | _Tp operator()(const _Tp& __x) const |
| 647 | {return sinh(__x);} |
| 648 | }; |
| 649 | |
| 650 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 651 | struct __sqrt_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 652 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 653 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 654 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 655 | _Tp operator()(const _Tp& __x) const |
| 656 | {return sqrt(__x);} |
| 657 | }; |
| 658 | |
| 659 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 660 | struct __tan_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 661 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 662 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 663 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 664 | _Tp operator()(const _Tp& __x) const |
| 665 | {return tan(__x);} |
| 666 | }; |
| 667 | |
| 668 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 669 | struct __tanh_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 670 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 671 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 672 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 673 | _Tp operator()(const _Tp& __x) const |
| 674 | {return tanh(__x);} |
| 675 | }; |
| 676 | |
| 677 | template <class _ValExpr> |
| 678 | class __slice_expr |
| 679 | { |
| 680 | typedef typename remove_reference<_ValExpr>::type _RmExpr; |
| 681 | public: |
| 682 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 683 | typedef value_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 684 | |
| 685 | private: |
| 686 | _ValExpr __expr_; |
| 687 | size_t __start_; |
| 688 | size_t __size_; |
| 689 | size_t __stride_; |
| 690 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 691 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 692 | __slice_expr(const slice& __sl, const _RmExpr& __e) |
| 693 | : __expr_(__e), |
| 694 | __start_(__sl.start()), |
| 695 | __size_(__sl.size()), |
| 696 | __stride_(__sl.stride()) |
| 697 | {} |
| 698 | public: |
| 699 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 700 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 701 | __result_type operator[](size_t __i) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 702 | {return __expr_[__start_ + __i * __stride_];} |
| 703 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 704 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 705 | size_t size() const {return __size_;} |
| 706 | |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 707 | template <class> friend class __val_expr; |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 708 | template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 709 | }; |
| 710 | |
| 711 | template <class _ValExpr> |
| 712 | class __mask_expr; |
| 713 | |
| 714 | template <class _ValExpr> |
| 715 | class __indirect_expr; |
| 716 | |
| 717 | template <class _ValExpr> |
| 718 | class __shift_expr |
| 719 | { |
| 720 | typedef typename remove_reference<_ValExpr>::type _RmExpr; |
| 721 | public: |
| 722 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 723 | typedef value_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 724 | |
| 725 | private: |
| 726 | _ValExpr __expr_; |
| 727 | size_t __size_; |
| 728 | ptrdiff_t __ul_; |
| 729 | ptrdiff_t __sn_; |
| 730 | ptrdiff_t __n_; |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 731 | static const ptrdiff_t _Np = static_cast<ptrdiff_t>( |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 732 | sizeof(ptrdiff_t) * __CHAR_BIT__ - 1); |
| 733 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 734 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 735 | __shift_expr(int __n, const _RmExpr& __e) |
| 736 | : __expr_(__e), |
| 737 | __size_(__e.size()), |
| 738 | __n_(__n) |
| 739 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 740 | ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np); |
| 741 | __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 742 | __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n); |
| 743 | } |
| 744 | public: |
| 745 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 746 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 747 | __result_type operator[](size_t __j) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 748 | { |
Howard Hinnant | 28b2488 | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 749 | ptrdiff_t __i = static_cast<ptrdiff_t>(__j); |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 750 | ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 751 | return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m); |
| 752 | } |
| 753 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 754 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 755 | size_t size() const {return __size_;} |
| 756 | |
| 757 | template <class> friend class __val_expr; |
| 758 | }; |
| 759 | |
| 760 | template <class _ValExpr> |
| 761 | class __cshift_expr |
| 762 | { |
| 763 | typedef typename remove_reference<_ValExpr>::type _RmExpr; |
| 764 | public: |
| 765 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 766 | typedef value_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 767 | |
| 768 | private: |
| 769 | _ValExpr __expr_; |
| 770 | size_t __size_; |
| 771 | size_t __m_; |
| 772 | size_t __o1_; |
| 773 | size_t __o2_; |
| 774 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 775 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 776 | __cshift_expr(int __n, const _RmExpr& __e) |
| 777 | : __expr_(__e), |
| 778 | __size_(__e.size()) |
| 779 | { |
| 780 | __n %= static_cast<int>(__size_); |
| 781 | if (__n >= 0) |
| 782 | { |
| 783 | __m_ = __size_ - __n; |
| 784 | __o1_ = __n; |
| 785 | __o2_ = __n - __size_; |
| 786 | } |
| 787 | else |
| 788 | { |
| 789 | __m_ = -__n; |
| 790 | __o1_ = __n + __size_; |
| 791 | __o2_ = __n; |
| 792 | } |
| 793 | } |
| 794 | public: |
| 795 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 796 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 797 | __result_type operator[](size_t __i) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 798 | { |
| 799 | if (__i < __m_) |
| 800 | return __expr_[__i + __o1_]; |
| 801 | return __expr_[__i + __o2_]; |
| 802 | } |
| 803 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 804 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 805 | size_t size() const {return __size_;} |
| 806 | |
| 807 | template <class> friend class __val_expr; |
| 808 | }; |
| 809 | |
| 810 | template<class _ValExpr> |
| 811 | class __val_expr; |
| 812 | |
| 813 | template<class _ValExpr> |
| 814 | struct __is_val_expr : false_type {}; |
| 815 | |
| 816 | template<class _ValExpr> |
| 817 | struct __is_val_expr<__val_expr<_ValExpr> > : true_type {}; |
| 818 | |
| 819 | template<class _Tp> |
| 820 | struct __is_val_expr<valarray<_Tp> > : true_type {}; |
| 821 | |
| 822 | template<class _Tp> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 823 | class _LIBCPP_TEMPLATE_VIS valarray |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 824 | { |
| 825 | public: |
| 826 | typedef _Tp value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 827 | typedef _Tp __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 828 | |
| 829 | private: |
| 830 | value_type* __begin_; |
| 831 | value_type* __end_; |
| 832 | |
| 833 | public: |
| 834 | // construct/destroy: |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 835 | _LIBCPP_INLINE_VISIBILITY |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 836 | valarray() : __begin_(nullptr), __end_(nullptr) {} |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 837 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Eric Fiselier | e529a80 | 2016-09-16 00:13:55 +0000 | [diff] [blame] | 838 | explicit valarray(size_t __n); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 839 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 840 | valarray(const value_type& __x, size_t __n); |
| 841 | valarray(const value_type* __p, size_t __n); |
| 842 | valarray(const valarray& __v); |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 843 | #ifndef _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 844 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 845 | valarray(valarray&& __v) _NOEXCEPT; |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 846 | valarray(initializer_list<value_type> __il); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 847 | #endif // _LIBCPP_CXX03_LANG |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 848 | valarray(const slice_array<value_type>& __sa); |
| 849 | valarray(const gslice_array<value_type>& __ga); |
| 850 | valarray(const mask_array<value_type>& __ma); |
| 851 | valarray(const indirect_array<value_type>& __ia); |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 852 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 853 | ~valarray(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 854 | |
| 855 | // assignment: |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 856 | valarray& operator=(const valarray& __v); |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 857 | #ifndef _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 858 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 859 | valarray& operator=(valarray&& __v) _NOEXCEPT; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 860 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 861 | valarray& operator=(initializer_list<value_type>); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 862 | #endif // _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 863 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 864 | valarray& operator=(const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 865 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 866 | valarray& operator=(const slice_array<value_type>& __sa); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 867 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 868 | valarray& operator=(const gslice_array<value_type>& __ga); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 869 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 870 | valarray& operator=(const mask_array<value_type>& __ma); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 871 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 872 | valarray& operator=(const indirect_array<value_type>& __ia); |
Howard Hinnant | 329cd41 | 2011-07-27 23:19:59 +0000 | [diff] [blame] | 873 | template <class _ValExpr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 874 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 329cd41 | 2011-07-27 23:19:59 +0000 | [diff] [blame] | 875 | valarray& operator=(const __val_expr<_ValExpr>& __v); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 876 | |
| 877 | // element access: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 878 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 879 | const value_type& operator[](size_t __i) const {return __begin_[__i];} |
| 880 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 881 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 882 | value_type& operator[](size_t __i) {return __begin_[__i];} |
| 883 | |
| 884 | // subset operations: |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 885 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 886 | __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 887 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 888 | slice_array<value_type> operator[](slice __s); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 889 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 890 | __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 891 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 892 | gslice_array<value_type> operator[](const gslice& __gs); |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 893 | #ifndef _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 894 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 895 | __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 896 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 897 | gslice_array<value_type> operator[](gslice&& __gs); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 898 | #endif // _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 899 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 900 | __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 901 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 902 | mask_array<value_type> operator[](const valarray<bool>& __vb); |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 903 | #ifndef _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 904 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 905 | __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 906 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 907 | mask_array<value_type> operator[](valarray<bool>&& __vb); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 908 | #endif // _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 909 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 910 | __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 911 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 912 | indirect_array<value_type> operator[](const valarray<size_t>& __vs); |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 913 | #ifndef _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 914 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 915 | __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 916 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 917 | indirect_array<value_type> operator[](valarray<size_t>&& __vs); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 918 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 919 | |
| 920 | // unary operators: |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 921 | valarray operator+() const; |
| 922 | valarray operator-() const; |
| 923 | valarray operator~() const; |
| 924 | valarray<bool> operator!() const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 925 | |
| 926 | // computed assignment: |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 927 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 928 | valarray& operator*= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 929 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 930 | valarray& operator/= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 931 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 932 | valarray& operator%= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 933 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 934 | valarray& operator+= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 935 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 936 | valarray& operator-= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 937 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 938 | valarray& operator^= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 939 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 940 | valarray& operator&= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 941 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 942 | valarray& operator|= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 943 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 944 | valarray& operator<<=(const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 945 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 946 | valarray& operator>>=(const value_type& __x); |
| 947 | |
| 948 | template <class _Expr> |
| 949 | typename enable_if |
| 950 | < |
| 951 | __is_val_expr<_Expr>::value, |
| 952 | valarray& |
| 953 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 954 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 955 | operator*= (const _Expr& __v); |
| 956 | |
| 957 | template <class _Expr> |
| 958 | typename enable_if |
| 959 | < |
| 960 | __is_val_expr<_Expr>::value, |
| 961 | valarray& |
| 962 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 963 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 964 | operator/= (const _Expr& __v); |
| 965 | |
| 966 | template <class _Expr> |
| 967 | typename enable_if |
| 968 | < |
| 969 | __is_val_expr<_Expr>::value, |
| 970 | valarray& |
| 971 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 972 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 973 | operator%= (const _Expr& __v); |
| 974 | |
| 975 | template <class _Expr> |
| 976 | typename enable_if |
| 977 | < |
| 978 | __is_val_expr<_Expr>::value, |
| 979 | valarray& |
| 980 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 981 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 982 | operator+= (const _Expr& __v); |
| 983 | |
| 984 | template <class _Expr> |
| 985 | typename enable_if |
| 986 | < |
| 987 | __is_val_expr<_Expr>::value, |
| 988 | valarray& |
| 989 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 990 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 991 | operator-= (const _Expr& __v); |
| 992 | |
| 993 | template <class _Expr> |
| 994 | typename enable_if |
| 995 | < |
| 996 | __is_val_expr<_Expr>::value, |
| 997 | valarray& |
| 998 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 999 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1000 | operator^= (const _Expr& __v); |
| 1001 | |
| 1002 | template <class _Expr> |
| 1003 | typename enable_if |
| 1004 | < |
| 1005 | __is_val_expr<_Expr>::value, |
| 1006 | valarray& |
| 1007 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1008 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1009 | operator|= (const _Expr& __v); |
| 1010 | |
| 1011 | template <class _Expr> |
| 1012 | typename enable_if |
| 1013 | < |
| 1014 | __is_val_expr<_Expr>::value, |
| 1015 | valarray& |
| 1016 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1017 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1018 | operator&= (const _Expr& __v); |
| 1019 | |
| 1020 | template <class _Expr> |
| 1021 | typename enable_if |
| 1022 | < |
| 1023 | __is_val_expr<_Expr>::value, |
| 1024 | valarray& |
| 1025 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1026 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1027 | operator<<= (const _Expr& __v); |
| 1028 | |
| 1029 | template <class _Expr> |
| 1030 | typename enable_if |
| 1031 | < |
| 1032 | __is_val_expr<_Expr>::value, |
| 1033 | valarray& |
| 1034 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1035 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1036 | operator>>= (const _Expr& __v); |
| 1037 | |
| 1038 | // member functions: |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1039 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 1040 | void swap(valarray& __v) _NOEXCEPT; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1041 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1042 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 28b2488 | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 1043 | size_t size() const {return static_cast<size_t>(__end_ - __begin_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1044 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1045 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 1046 | value_type sum() const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1047 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 1048 | value_type min() const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1049 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 1050 | value_type max() const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1051 | |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 1052 | valarray shift (int __i) const; |
| 1053 | valarray cshift(int __i) const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1054 | valarray apply(value_type __f(value_type)) const; |
| 1055 | valarray apply(value_type __f(const value_type&)) const; |
| 1056 | void resize(size_t __n, value_type __x = value_type()); |
| 1057 | |
| 1058 | private: |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1059 | template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; |
| 1060 | template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array; |
| 1061 | template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array; |
| 1062 | template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1063 | template <class> friend class __mask_expr; |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1064 | template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1065 | template <class> friend class __indirect_expr; |
| 1066 | template <class> friend class __val_expr; |
| 1067 | |
| 1068 | template <class _Up> |
| 1069 | friend |
| 1070 | _Up* |
| 1071 | begin(valarray<_Up>& __v); |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1072 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1073 | template <class _Up> |
| 1074 | friend |
| 1075 | const _Up* |
| 1076 | begin(const valarray<_Up>& __v); |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1077 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1078 | template <class _Up> |
| 1079 | friend |
| 1080 | _Up* |
| 1081 | end(valarray<_Up>& __v); |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1082 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1083 | template <class _Up> |
| 1084 | friend |
| 1085 | const _Up* |
| 1086 | end(const valarray<_Up>& __v); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 1087 | |
Eric Fiselier | a119c32 | 2018-10-25 17:43:26 +0000 | [diff] [blame] | 1088 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 1089 | void __clear(size_t __capacity); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 1090 | valarray& __assign_range(const value_type* __f, const value_type* __l); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1091 | }; |
| 1092 | |
Konstantin Varlamov | ebb3119 | 2021-10-28 00:36:19 -0700 | [diff] [blame] | 1093 | #if _LIBCPP_STD_VER > 14 |
| 1094 | template<class _Tp, size_t _Size> |
| 1095 | valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>; |
| 1096 | #endif |
| 1097 | |
Howard Hinnant | a37d3cf | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 1098 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t)) |
| 1099 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1100 | template <class _Op, class _Tp> |
| 1101 | struct _UnaryOp<_Op, valarray<_Tp> > |
| 1102 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1103 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1104 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1105 | |
| 1106 | _Op __op_; |
| 1107 | const valarray<_Tp>& __a0_; |
| 1108 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1109 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1110 | _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {} |
| 1111 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1112 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1113 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1114 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1115 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1116 | size_t size() const {return __a0_.size();} |
| 1117 | }; |
| 1118 | |
| 1119 | template <class _Op, class _Tp, class _A1> |
| 1120 | struct _BinaryOp<_Op, valarray<_Tp>, _A1> |
| 1121 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1122 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1123 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1124 | |
| 1125 | _Op __op_; |
| 1126 | const valarray<_Tp>& __a0_; |
| 1127 | _A1 __a1_; |
| 1128 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1129 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1130 | _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1) |
| 1131 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 1132 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1133 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1134 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1135 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1136 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1137 | size_t size() const {return __a0_.size();} |
| 1138 | }; |
| 1139 | |
| 1140 | template <class _Op, class _A0, class _Tp> |
| 1141 | struct _BinaryOp<_Op, _A0, valarray<_Tp> > |
| 1142 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1143 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1144 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1145 | |
| 1146 | _Op __op_; |
| 1147 | _A0 __a0_; |
| 1148 | const valarray<_Tp>& __a1_; |
| 1149 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1150 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1151 | _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1) |
| 1152 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 1153 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1154 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1155 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1156 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1157 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1158 | size_t size() const {return __a0_.size();} |
| 1159 | }; |
| 1160 | |
| 1161 | template <class _Op, class _Tp> |
| 1162 | struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > |
| 1163 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1164 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1165 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1166 | |
| 1167 | _Op __op_; |
| 1168 | const valarray<_Tp>& __a0_; |
| 1169 | const valarray<_Tp>& __a1_; |
| 1170 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1171 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1172 | _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1) |
| 1173 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 1174 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1175 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1176 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1177 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1178 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1179 | size_t size() const {return __a0_.size();} |
| 1180 | }; |
| 1181 | |
| 1182 | // slice_array |
| 1183 | |
| 1184 | template <class _Tp> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1185 | class _LIBCPP_TEMPLATE_VIS slice_array |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1186 | { |
| 1187 | public: |
| 1188 | typedef _Tp value_type; |
| 1189 | |
| 1190 | private: |
| 1191 | value_type* __vp_; |
| 1192 | size_t __size_; |
| 1193 | size_t __stride_; |
| 1194 | |
| 1195 | public: |
| 1196 | template <class _Expr> |
| 1197 | typename enable_if |
| 1198 | < |
| 1199 | __is_val_expr<_Expr>::value, |
| 1200 | void |
| 1201 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1202 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1203 | operator=(const _Expr& __v) const; |
| 1204 | |
| 1205 | template <class _Expr> |
| 1206 | typename enable_if |
| 1207 | < |
| 1208 | __is_val_expr<_Expr>::value, |
| 1209 | void |
| 1210 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1211 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1212 | operator*=(const _Expr& __v) const; |
| 1213 | |
| 1214 | template <class _Expr> |
| 1215 | typename enable_if |
| 1216 | < |
| 1217 | __is_val_expr<_Expr>::value, |
| 1218 | void |
| 1219 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1220 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1221 | operator/=(const _Expr& __v) const; |
| 1222 | |
| 1223 | template <class _Expr> |
| 1224 | typename enable_if |
| 1225 | < |
| 1226 | __is_val_expr<_Expr>::value, |
| 1227 | void |
| 1228 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1229 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1230 | operator%=(const _Expr& __v) const; |
| 1231 | |
| 1232 | template <class _Expr> |
| 1233 | typename enable_if |
| 1234 | < |
| 1235 | __is_val_expr<_Expr>::value, |
| 1236 | void |
| 1237 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1238 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1239 | operator+=(const _Expr& __v) const; |
| 1240 | |
| 1241 | template <class _Expr> |
| 1242 | typename enable_if |
| 1243 | < |
| 1244 | __is_val_expr<_Expr>::value, |
| 1245 | void |
| 1246 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1247 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1248 | operator-=(const _Expr& __v) const; |
| 1249 | |
| 1250 | template <class _Expr> |
| 1251 | typename enable_if |
| 1252 | < |
| 1253 | __is_val_expr<_Expr>::value, |
| 1254 | void |
| 1255 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1256 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1257 | operator^=(const _Expr& __v) const; |
| 1258 | |
| 1259 | template <class _Expr> |
| 1260 | typename enable_if |
| 1261 | < |
| 1262 | __is_val_expr<_Expr>::value, |
| 1263 | void |
| 1264 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1265 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1266 | operator&=(const _Expr& __v) const; |
| 1267 | |
| 1268 | template <class _Expr> |
| 1269 | typename enable_if |
| 1270 | < |
| 1271 | __is_val_expr<_Expr>::value, |
| 1272 | void |
| 1273 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1274 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1275 | operator|=(const _Expr& __v) const; |
| 1276 | |
| 1277 | template <class _Expr> |
| 1278 | typename enable_if |
| 1279 | < |
| 1280 | __is_val_expr<_Expr>::value, |
| 1281 | void |
| 1282 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1283 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1284 | operator<<=(const _Expr& __v) const; |
| 1285 | |
| 1286 | template <class _Expr> |
| 1287 | typename enable_if |
| 1288 | < |
| 1289 | __is_val_expr<_Expr>::value, |
| 1290 | void |
| 1291 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1292 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1293 | operator>>=(const _Expr& __v) const; |
| 1294 | |
Eric Fiselier | b9f37ca | 2019-12-12 20:48:11 -0500 | [diff] [blame] | 1295 | slice_array(slice_array const&) = default; |
| 1296 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1297 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1298 | const slice_array& operator=(const slice_array& __sa) const; |
| 1299 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1300 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1301 | void operator=(const value_type& __x) const; |
| 1302 | |
zoecarver | 79fa750 | 2020-12-02 10:49:20 -0800 | [diff] [blame] | 1303 | _LIBCPP_INLINE_VISIBILITY |
| 1304 | void operator=(const valarray<value_type>& __va) const; |
| 1305 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1306 | private: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1307 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1308 | slice_array(const slice& __sl, const valarray<value_type>& __v) |
| 1309 | : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), |
| 1310 | __size_(__sl.size()), |
| 1311 | __stride_(__sl.stride()) |
| 1312 | {} |
| 1313 | |
| 1314 | template <class> friend class valarray; |
| 1315 | template <class> friend class sliceExpr; |
| 1316 | }; |
| 1317 | |
| 1318 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1319 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1320 | const slice_array<_Tp>& |
| 1321 | slice_array<_Tp>::operator=(const slice_array& __sa) const |
| 1322 | { |
| 1323 | value_type* __t = __vp_; |
| 1324 | const value_type* __s = __sa.__vp_; |
| 1325 | for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_) |
| 1326 | *__t = *__s; |
Eric Fiselier | 3b80ce9 | 2014-08-12 00:06:58 +0000 | [diff] [blame] | 1327 | return *this; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1328 | } |
| 1329 | |
| 1330 | template <class _Tp> |
| 1331 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1332 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1333 | typename enable_if |
| 1334 | < |
| 1335 | __is_val_expr<_Expr>::value, |
| 1336 | void |
| 1337 | >::type |
| 1338 | slice_array<_Tp>::operator=(const _Expr& __v) const |
| 1339 | { |
| 1340 | value_type* __t = __vp_; |
| 1341 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1342 | *__t = __v[__i]; |
| 1343 | } |
| 1344 | |
| 1345 | template <class _Tp> |
zoecarver | 79fa750 | 2020-12-02 10:49:20 -0800 | [diff] [blame] | 1346 | inline void |
| 1347 | slice_array<_Tp>::operator=(const valarray<value_type>& __va) const |
| 1348 | { |
| 1349 | value_type* __t = __vp_; |
| 1350 | for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_) |
| 1351 | *__t = __va[__i]; |
| 1352 | } |
| 1353 | |
| 1354 | template <class _Tp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1355 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1356 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1357 | typename enable_if |
| 1358 | < |
| 1359 | __is_val_expr<_Expr>::value, |
| 1360 | void |
| 1361 | >::type |
| 1362 | slice_array<_Tp>::operator*=(const _Expr& __v) const |
| 1363 | { |
| 1364 | value_type* __t = __vp_; |
| 1365 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1366 | *__t *= __v[__i]; |
| 1367 | } |
| 1368 | |
| 1369 | template <class _Tp> |
| 1370 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1371 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1372 | typename enable_if |
| 1373 | < |
| 1374 | __is_val_expr<_Expr>::value, |
| 1375 | void |
| 1376 | >::type |
| 1377 | slice_array<_Tp>::operator/=(const _Expr& __v) const |
| 1378 | { |
| 1379 | value_type* __t = __vp_; |
| 1380 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1381 | *__t /= __v[__i]; |
| 1382 | } |
| 1383 | |
| 1384 | template <class _Tp> |
| 1385 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1386 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1387 | typename enable_if |
| 1388 | < |
| 1389 | __is_val_expr<_Expr>::value, |
| 1390 | void |
| 1391 | >::type |
| 1392 | slice_array<_Tp>::operator%=(const _Expr& __v) const |
| 1393 | { |
| 1394 | value_type* __t = __vp_; |
| 1395 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1396 | *__t %= __v[__i]; |
| 1397 | } |
| 1398 | |
| 1399 | template <class _Tp> |
| 1400 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1401 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1402 | typename enable_if |
| 1403 | < |
| 1404 | __is_val_expr<_Expr>::value, |
| 1405 | void |
| 1406 | >::type |
| 1407 | slice_array<_Tp>::operator+=(const _Expr& __v) const |
| 1408 | { |
| 1409 | value_type* __t = __vp_; |
| 1410 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1411 | *__t += __v[__i]; |
| 1412 | } |
| 1413 | |
| 1414 | template <class _Tp> |
| 1415 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1416 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1417 | typename enable_if |
| 1418 | < |
| 1419 | __is_val_expr<_Expr>::value, |
| 1420 | void |
| 1421 | >::type |
| 1422 | slice_array<_Tp>::operator-=(const _Expr& __v) const |
| 1423 | { |
| 1424 | value_type* __t = __vp_; |
| 1425 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1426 | *__t -= __v[__i]; |
| 1427 | } |
| 1428 | |
| 1429 | template <class _Tp> |
| 1430 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1431 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1432 | typename enable_if |
| 1433 | < |
| 1434 | __is_val_expr<_Expr>::value, |
| 1435 | void |
| 1436 | >::type |
| 1437 | slice_array<_Tp>::operator^=(const _Expr& __v) const |
| 1438 | { |
| 1439 | value_type* __t = __vp_; |
| 1440 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1441 | *__t ^= __v[__i]; |
| 1442 | } |
| 1443 | |
| 1444 | template <class _Tp> |
| 1445 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1446 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1447 | typename enable_if |
| 1448 | < |
| 1449 | __is_val_expr<_Expr>::value, |
| 1450 | void |
| 1451 | >::type |
| 1452 | slice_array<_Tp>::operator&=(const _Expr& __v) const |
| 1453 | { |
| 1454 | value_type* __t = __vp_; |
| 1455 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1456 | *__t &= __v[__i]; |
| 1457 | } |
| 1458 | |
| 1459 | template <class _Tp> |
| 1460 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1461 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1462 | typename enable_if |
| 1463 | < |
| 1464 | __is_val_expr<_Expr>::value, |
| 1465 | void |
| 1466 | >::type |
| 1467 | slice_array<_Tp>::operator|=(const _Expr& __v) const |
| 1468 | { |
| 1469 | value_type* __t = __vp_; |
| 1470 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1471 | *__t |= __v[__i]; |
| 1472 | } |
| 1473 | |
| 1474 | template <class _Tp> |
| 1475 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1476 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1477 | typename enable_if |
| 1478 | < |
| 1479 | __is_val_expr<_Expr>::value, |
| 1480 | void |
| 1481 | >::type |
| 1482 | slice_array<_Tp>::operator<<=(const _Expr& __v) const |
| 1483 | { |
| 1484 | value_type* __t = __vp_; |
| 1485 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1486 | *__t <<= __v[__i]; |
| 1487 | } |
| 1488 | |
| 1489 | template <class _Tp> |
| 1490 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1491 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1492 | typename enable_if |
| 1493 | < |
| 1494 | __is_val_expr<_Expr>::value, |
| 1495 | void |
| 1496 | >::type |
| 1497 | slice_array<_Tp>::operator>>=(const _Expr& __v) const |
| 1498 | { |
| 1499 | value_type* __t = __vp_; |
| 1500 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1501 | *__t >>= __v[__i]; |
| 1502 | } |
| 1503 | |
| 1504 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1505 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1506 | void |
| 1507 | slice_array<_Tp>::operator=(const value_type& __x) const |
| 1508 | { |
| 1509 | value_type* __t = __vp_; |
| 1510 | for (size_t __n = __size_; __n; --__n, __t += __stride_) |
| 1511 | *__t = __x; |
| 1512 | } |
| 1513 | |
| 1514 | // gslice |
| 1515 | |
Howard Hinnant | 8331b76 | 2013-03-06 23:30:19 +0000 | [diff] [blame] | 1516 | class _LIBCPP_TYPE_VIS gslice |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1517 | { |
| 1518 | valarray<size_t> __size_; |
| 1519 | valarray<size_t> __stride_; |
| 1520 | valarray<size_t> __1d_; |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1521 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1522 | public: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1523 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1524 | gslice() {} |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 1525 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1526 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1527 | gslice(size_t __start, const valarray<size_t>& __size, |
| 1528 | const valarray<size_t>& __stride) |
| 1529 | : __size_(__size), |
| 1530 | __stride_(__stride) |
| 1531 | {__init(__start);} |
| 1532 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 1533 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1534 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1535 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1536 | gslice(size_t __start, const valarray<size_t>& __size, |
| 1537 | valarray<size_t>&& __stride) |
| 1538 | : __size_(__size), |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 1539 | __stride_(std::move(__stride)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1540 | {__init(__start);} |
| 1541 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1542 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1543 | gslice(size_t __start, valarray<size_t>&& __size, |
| 1544 | const valarray<size_t>& __stride) |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 1545 | : __size_(std::move(__size)), |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1546 | __stride_(__stride) |
| 1547 | {__init(__start);} |
| 1548 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1549 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1550 | gslice(size_t __start, valarray<size_t>&& __size, |
| 1551 | valarray<size_t>&& __stride) |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 1552 | : __size_(std::move(__size)), |
| 1553 | __stride_(std::move(__stride)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1554 | {__init(__start);} |
| 1555 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1556 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1557 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1558 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1559 | size_t start() const {return __1d_.size() ? __1d_[0] : 0;} |
| 1560 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1561 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1562 | valarray<size_t> size() const {return __size_;} |
| 1563 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1564 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1565 | valarray<size_t> stride() const {return __stride_;} |
| 1566 | |
| 1567 | private: |
| 1568 | void __init(size_t __start); |
| 1569 | |
| 1570 | template <class> friend class gslice_array; |
| 1571 | template <class> friend class valarray; |
| 1572 | template <class> friend class __val_expr; |
| 1573 | }; |
| 1574 | |
| 1575 | // gslice_array |
| 1576 | |
| 1577 | template <class _Tp> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1578 | class _LIBCPP_TEMPLATE_VIS gslice_array |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1579 | { |
| 1580 | public: |
| 1581 | typedef _Tp value_type; |
| 1582 | |
| 1583 | private: |
| 1584 | value_type* __vp_; |
| 1585 | valarray<size_t> __1d_; |
| 1586 | |
| 1587 | public: |
| 1588 | template <class _Expr> |
| 1589 | typename enable_if |
| 1590 | < |
| 1591 | __is_val_expr<_Expr>::value, |
| 1592 | void |
| 1593 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1594 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1595 | operator=(const _Expr& __v) const; |
| 1596 | |
| 1597 | template <class _Expr> |
| 1598 | typename enable_if |
| 1599 | < |
| 1600 | __is_val_expr<_Expr>::value, |
| 1601 | void |
| 1602 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1603 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1604 | operator*=(const _Expr& __v) const; |
| 1605 | |
| 1606 | template <class _Expr> |
| 1607 | typename enable_if |
| 1608 | < |
| 1609 | __is_val_expr<_Expr>::value, |
| 1610 | void |
| 1611 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1612 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1613 | operator/=(const _Expr& __v) const; |
| 1614 | |
| 1615 | template <class _Expr> |
| 1616 | typename enable_if |
| 1617 | < |
| 1618 | __is_val_expr<_Expr>::value, |
| 1619 | void |
| 1620 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1621 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1622 | operator%=(const _Expr& __v) const; |
| 1623 | |
| 1624 | template <class _Expr> |
| 1625 | typename enable_if |
| 1626 | < |
| 1627 | __is_val_expr<_Expr>::value, |
| 1628 | void |
| 1629 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1630 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1631 | operator+=(const _Expr& __v) const; |
| 1632 | |
| 1633 | template <class _Expr> |
| 1634 | typename enable_if |
| 1635 | < |
| 1636 | __is_val_expr<_Expr>::value, |
| 1637 | void |
| 1638 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1639 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1640 | operator-=(const _Expr& __v) const; |
| 1641 | |
| 1642 | template <class _Expr> |
| 1643 | typename enable_if |
| 1644 | < |
| 1645 | __is_val_expr<_Expr>::value, |
| 1646 | void |
| 1647 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1648 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1649 | operator^=(const _Expr& __v) const; |
| 1650 | |
| 1651 | template <class _Expr> |
| 1652 | typename enable_if |
| 1653 | < |
| 1654 | __is_val_expr<_Expr>::value, |
| 1655 | void |
| 1656 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1657 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1658 | operator&=(const _Expr& __v) const; |
| 1659 | |
| 1660 | template <class _Expr> |
| 1661 | typename enable_if |
| 1662 | < |
| 1663 | __is_val_expr<_Expr>::value, |
| 1664 | void |
| 1665 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1666 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1667 | operator|=(const _Expr& __v) const; |
| 1668 | |
| 1669 | template <class _Expr> |
| 1670 | typename enable_if |
| 1671 | < |
| 1672 | __is_val_expr<_Expr>::value, |
| 1673 | void |
| 1674 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1675 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1676 | operator<<=(const _Expr& __v) const; |
| 1677 | |
| 1678 | template <class _Expr> |
| 1679 | typename enable_if |
| 1680 | < |
| 1681 | __is_val_expr<_Expr>::value, |
| 1682 | void |
| 1683 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1684 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1685 | operator>>=(const _Expr& __v) const; |
| 1686 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1687 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1688 | const gslice_array& operator=(const gslice_array& __ga) const; |
| 1689 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1690 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1691 | void operator=(const value_type& __x) const; |
| 1692 | |
Eric Fiselier | b9f37ca | 2019-12-12 20:48:11 -0500 | [diff] [blame] | 1693 | gslice_array(const gslice_array&) = default; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1694 | |
| 1695 | private: |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1696 | gslice_array(const gslice& __gs, const valarray<value_type>& __v) |
| 1697 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
| 1698 | __1d_(__gs.__1d_) |
| 1699 | {} |
| 1700 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 1701 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1702 | gslice_array(gslice&& __gs, const valarray<value_type>& __v) |
| 1703 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 1704 | __1d_(std::move(__gs.__1d_)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1705 | {} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1706 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1707 | |
| 1708 | template <class> friend class valarray; |
| 1709 | }; |
| 1710 | |
| 1711 | template <class _Tp> |
| 1712 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1713 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1714 | typename enable_if |
| 1715 | < |
| 1716 | __is_val_expr<_Expr>::value, |
| 1717 | void |
| 1718 | >::type |
| 1719 | gslice_array<_Tp>::operator=(const _Expr& __v) const |
| 1720 | { |
| 1721 | typedef const size_t* _Ip; |
| 1722 | size_t __j = 0; |
| 1723 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1724 | __vp_[*__i] = __v[__j]; |
| 1725 | } |
| 1726 | |
| 1727 | template <class _Tp> |
| 1728 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1729 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1730 | typename enable_if |
| 1731 | < |
| 1732 | __is_val_expr<_Expr>::value, |
| 1733 | void |
| 1734 | >::type |
| 1735 | gslice_array<_Tp>::operator*=(const _Expr& __v) const |
| 1736 | { |
| 1737 | typedef const size_t* _Ip; |
| 1738 | size_t __j = 0; |
| 1739 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1740 | __vp_[*__i] *= __v[__j]; |
| 1741 | } |
| 1742 | |
| 1743 | template <class _Tp> |
| 1744 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1745 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1746 | typename enable_if |
| 1747 | < |
| 1748 | __is_val_expr<_Expr>::value, |
| 1749 | void |
| 1750 | >::type |
| 1751 | gslice_array<_Tp>::operator/=(const _Expr& __v) const |
| 1752 | { |
| 1753 | typedef const size_t* _Ip; |
| 1754 | size_t __j = 0; |
| 1755 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1756 | __vp_[*__i] /= __v[__j]; |
| 1757 | } |
| 1758 | |
| 1759 | template <class _Tp> |
| 1760 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1761 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1762 | typename enable_if |
| 1763 | < |
| 1764 | __is_val_expr<_Expr>::value, |
| 1765 | void |
| 1766 | >::type |
| 1767 | gslice_array<_Tp>::operator%=(const _Expr& __v) const |
| 1768 | { |
| 1769 | typedef const size_t* _Ip; |
| 1770 | size_t __j = 0; |
| 1771 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1772 | __vp_[*__i] %= __v[__j]; |
| 1773 | } |
| 1774 | |
| 1775 | template <class _Tp> |
| 1776 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1777 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1778 | typename enable_if |
| 1779 | < |
| 1780 | __is_val_expr<_Expr>::value, |
| 1781 | void |
| 1782 | >::type |
| 1783 | gslice_array<_Tp>::operator+=(const _Expr& __v) const |
| 1784 | { |
| 1785 | typedef const size_t* _Ip; |
| 1786 | size_t __j = 0; |
| 1787 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1788 | __vp_[*__i] += __v[__j]; |
| 1789 | } |
| 1790 | |
| 1791 | template <class _Tp> |
| 1792 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1793 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1794 | typename enable_if |
| 1795 | < |
| 1796 | __is_val_expr<_Expr>::value, |
| 1797 | void |
| 1798 | >::type |
| 1799 | gslice_array<_Tp>::operator-=(const _Expr& __v) const |
| 1800 | { |
| 1801 | typedef const size_t* _Ip; |
| 1802 | size_t __j = 0; |
| 1803 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1804 | __vp_[*__i] -= __v[__j]; |
| 1805 | } |
| 1806 | |
| 1807 | template <class _Tp> |
| 1808 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1809 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1810 | typename enable_if |
| 1811 | < |
| 1812 | __is_val_expr<_Expr>::value, |
| 1813 | void |
| 1814 | >::type |
| 1815 | gslice_array<_Tp>::operator^=(const _Expr& __v) const |
| 1816 | { |
| 1817 | typedef const size_t* _Ip; |
| 1818 | size_t __j = 0; |
| 1819 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1820 | __vp_[*__i] ^= __v[__j]; |
| 1821 | } |
| 1822 | |
| 1823 | template <class _Tp> |
| 1824 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1825 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1826 | typename enable_if |
| 1827 | < |
| 1828 | __is_val_expr<_Expr>::value, |
| 1829 | void |
| 1830 | >::type |
| 1831 | gslice_array<_Tp>::operator&=(const _Expr& __v) const |
| 1832 | { |
| 1833 | typedef const size_t* _Ip; |
| 1834 | size_t __j = 0; |
| 1835 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1836 | __vp_[*__i] &= __v[__j]; |
| 1837 | } |
| 1838 | |
| 1839 | template <class _Tp> |
| 1840 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1841 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1842 | typename enable_if |
| 1843 | < |
| 1844 | __is_val_expr<_Expr>::value, |
| 1845 | void |
| 1846 | >::type |
| 1847 | gslice_array<_Tp>::operator|=(const _Expr& __v) const |
| 1848 | { |
| 1849 | typedef const size_t* _Ip; |
| 1850 | size_t __j = 0; |
| 1851 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1852 | __vp_[*__i] |= __v[__j]; |
| 1853 | } |
| 1854 | |
| 1855 | template <class _Tp> |
| 1856 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1857 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1858 | typename enable_if |
| 1859 | < |
| 1860 | __is_val_expr<_Expr>::value, |
| 1861 | void |
| 1862 | >::type |
| 1863 | gslice_array<_Tp>::operator<<=(const _Expr& __v) const |
| 1864 | { |
| 1865 | typedef const size_t* _Ip; |
| 1866 | size_t __j = 0; |
| 1867 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1868 | __vp_[*__i] <<= __v[__j]; |
| 1869 | } |
| 1870 | |
| 1871 | template <class _Tp> |
| 1872 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1873 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1874 | typename enable_if |
| 1875 | < |
| 1876 | __is_val_expr<_Expr>::value, |
| 1877 | void |
| 1878 | >::type |
| 1879 | gslice_array<_Tp>::operator>>=(const _Expr& __v) const |
| 1880 | { |
| 1881 | typedef const size_t* _Ip; |
| 1882 | size_t __j = 0; |
| 1883 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1884 | __vp_[*__i] >>= __v[__j]; |
| 1885 | } |
| 1886 | |
| 1887 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1888 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1889 | const gslice_array<_Tp>& |
| 1890 | gslice_array<_Tp>::operator=(const gslice_array& __ga) const |
| 1891 | { |
| 1892 | typedef const size_t* _Ip; |
| 1893 | const value_type* __s = __ga.__vp_; |
| 1894 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; |
| 1895 | __i != __e; ++__i, ++__j) |
| 1896 | __vp_[*__i] = __s[*__j]; |
| 1897 | return *this; |
| 1898 | } |
| 1899 | |
| 1900 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1901 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1902 | void |
| 1903 | gslice_array<_Tp>::operator=(const value_type& __x) const |
| 1904 | { |
| 1905 | typedef const size_t* _Ip; |
| 1906 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) |
| 1907 | __vp_[*__i] = __x; |
| 1908 | } |
| 1909 | |
| 1910 | // mask_array |
| 1911 | |
| 1912 | template <class _Tp> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1913 | class _LIBCPP_TEMPLATE_VIS mask_array |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1914 | { |
| 1915 | public: |
| 1916 | typedef _Tp value_type; |
| 1917 | |
| 1918 | private: |
| 1919 | value_type* __vp_; |
| 1920 | valarray<size_t> __1d_; |
| 1921 | |
| 1922 | public: |
| 1923 | template <class _Expr> |
| 1924 | typename enable_if |
| 1925 | < |
| 1926 | __is_val_expr<_Expr>::value, |
| 1927 | void |
| 1928 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1929 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1930 | operator=(const _Expr& __v) const; |
| 1931 | |
| 1932 | template <class _Expr> |
| 1933 | typename enable_if |
| 1934 | < |
| 1935 | __is_val_expr<_Expr>::value, |
| 1936 | void |
| 1937 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1938 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1939 | operator*=(const _Expr& __v) const; |
| 1940 | |
| 1941 | template <class _Expr> |
| 1942 | typename enable_if |
| 1943 | < |
| 1944 | __is_val_expr<_Expr>::value, |
| 1945 | void |
| 1946 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1947 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1948 | operator/=(const _Expr& __v) const; |
| 1949 | |
| 1950 | template <class _Expr> |
| 1951 | typename enable_if |
| 1952 | < |
| 1953 | __is_val_expr<_Expr>::value, |
| 1954 | void |
| 1955 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1956 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1957 | operator%=(const _Expr& __v) const; |
| 1958 | |
| 1959 | template <class _Expr> |
| 1960 | typename enable_if |
| 1961 | < |
| 1962 | __is_val_expr<_Expr>::value, |
| 1963 | void |
| 1964 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1965 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1966 | operator+=(const _Expr& __v) const; |
| 1967 | |
| 1968 | template <class _Expr> |
| 1969 | typename enable_if |
| 1970 | < |
| 1971 | __is_val_expr<_Expr>::value, |
| 1972 | void |
| 1973 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1974 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1975 | operator-=(const _Expr& __v) const; |
| 1976 | |
| 1977 | template <class _Expr> |
| 1978 | typename enable_if |
| 1979 | < |
| 1980 | __is_val_expr<_Expr>::value, |
| 1981 | void |
| 1982 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1983 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1984 | operator^=(const _Expr& __v) const; |
| 1985 | |
| 1986 | template <class _Expr> |
| 1987 | typename enable_if |
| 1988 | < |
| 1989 | __is_val_expr<_Expr>::value, |
| 1990 | void |
| 1991 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1992 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1993 | operator&=(const _Expr& __v) const; |
| 1994 | |
| 1995 | template <class _Expr> |
| 1996 | typename enable_if |
| 1997 | < |
| 1998 | __is_val_expr<_Expr>::value, |
| 1999 | void |
| 2000 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2001 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2002 | operator|=(const _Expr& __v) const; |
| 2003 | |
| 2004 | template <class _Expr> |
| 2005 | typename enable_if |
| 2006 | < |
| 2007 | __is_val_expr<_Expr>::value, |
| 2008 | void |
| 2009 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2010 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2011 | operator<<=(const _Expr& __v) const; |
| 2012 | |
| 2013 | template <class _Expr> |
| 2014 | typename enable_if |
| 2015 | < |
| 2016 | __is_val_expr<_Expr>::value, |
| 2017 | void |
| 2018 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2019 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2020 | operator>>=(const _Expr& __v) const; |
| 2021 | |
Eric Fiselier | b9f37ca | 2019-12-12 20:48:11 -0500 | [diff] [blame] | 2022 | mask_array(const mask_array&) = default; |
| 2023 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2024 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2025 | const mask_array& operator=(const mask_array& __ma) const; |
| 2026 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2027 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2028 | void operator=(const value_type& __x) const; |
| 2029 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2030 | private: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2031 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2032 | mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v) |
| 2033 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
Howard Hinnant | 28b2488 | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 2034 | __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2035 | { |
| 2036 | size_t __j = 0; |
| 2037 | for (size_t __i = 0; __i < __vb.size(); ++__i) |
| 2038 | if (__vb[__i]) |
| 2039 | __1d_[__j++] = __i; |
| 2040 | } |
| 2041 | |
| 2042 | template <class> friend class valarray; |
| 2043 | }; |
| 2044 | |
| 2045 | template <class _Tp> |
| 2046 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2047 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2048 | typename enable_if |
| 2049 | < |
| 2050 | __is_val_expr<_Expr>::value, |
| 2051 | void |
| 2052 | >::type |
| 2053 | mask_array<_Tp>::operator=(const _Expr& __v) const |
| 2054 | { |
| 2055 | size_t __n = __1d_.size(); |
| 2056 | for (size_t __i = 0; __i < __n; ++__i) |
| 2057 | __vp_[__1d_[__i]] = __v[__i]; |
| 2058 | } |
| 2059 | |
| 2060 | template <class _Tp> |
| 2061 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2062 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2063 | typename enable_if |
| 2064 | < |
| 2065 | __is_val_expr<_Expr>::value, |
| 2066 | void |
| 2067 | >::type |
| 2068 | mask_array<_Tp>::operator*=(const _Expr& __v) const |
| 2069 | { |
| 2070 | size_t __n = __1d_.size(); |
| 2071 | for (size_t __i = 0; __i < __n; ++__i) |
| 2072 | __vp_[__1d_[__i]] *= __v[__i]; |
| 2073 | } |
| 2074 | |
| 2075 | template <class _Tp> |
| 2076 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2077 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2078 | typename enable_if |
| 2079 | < |
| 2080 | __is_val_expr<_Expr>::value, |
| 2081 | void |
| 2082 | >::type |
| 2083 | mask_array<_Tp>::operator/=(const _Expr& __v) const |
| 2084 | { |
| 2085 | size_t __n = __1d_.size(); |
| 2086 | for (size_t __i = 0; __i < __n; ++__i) |
| 2087 | __vp_[__1d_[__i]] /= __v[__i]; |
| 2088 | } |
| 2089 | |
| 2090 | template <class _Tp> |
| 2091 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2092 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2093 | typename enable_if |
| 2094 | < |
| 2095 | __is_val_expr<_Expr>::value, |
| 2096 | void |
| 2097 | >::type |
| 2098 | mask_array<_Tp>::operator%=(const _Expr& __v) const |
| 2099 | { |
| 2100 | size_t __n = __1d_.size(); |
| 2101 | for (size_t __i = 0; __i < __n; ++__i) |
| 2102 | __vp_[__1d_[__i]] %= __v[__i]; |
| 2103 | } |
| 2104 | |
| 2105 | template <class _Tp> |
| 2106 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2107 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2108 | typename enable_if |
| 2109 | < |
| 2110 | __is_val_expr<_Expr>::value, |
| 2111 | void |
| 2112 | >::type |
| 2113 | mask_array<_Tp>::operator+=(const _Expr& __v) const |
| 2114 | { |
| 2115 | size_t __n = __1d_.size(); |
| 2116 | for (size_t __i = 0; __i < __n; ++__i) |
| 2117 | __vp_[__1d_[__i]] += __v[__i]; |
| 2118 | } |
| 2119 | |
| 2120 | template <class _Tp> |
| 2121 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2122 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2123 | typename enable_if |
| 2124 | < |
| 2125 | __is_val_expr<_Expr>::value, |
| 2126 | void |
| 2127 | >::type |
| 2128 | mask_array<_Tp>::operator-=(const _Expr& __v) const |
| 2129 | { |
| 2130 | size_t __n = __1d_.size(); |
| 2131 | for (size_t __i = 0; __i < __n; ++__i) |
| 2132 | __vp_[__1d_[__i]] -= __v[__i]; |
| 2133 | } |
| 2134 | |
| 2135 | template <class _Tp> |
| 2136 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2137 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2138 | typename enable_if |
| 2139 | < |
| 2140 | __is_val_expr<_Expr>::value, |
| 2141 | void |
| 2142 | >::type |
| 2143 | mask_array<_Tp>::operator^=(const _Expr& __v) const |
| 2144 | { |
| 2145 | size_t __n = __1d_.size(); |
| 2146 | for (size_t __i = 0; __i < __n; ++__i) |
| 2147 | __vp_[__1d_[__i]] ^= __v[__i]; |
| 2148 | } |
| 2149 | |
| 2150 | template <class _Tp> |
| 2151 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2152 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2153 | typename enable_if |
| 2154 | < |
| 2155 | __is_val_expr<_Expr>::value, |
| 2156 | void |
| 2157 | >::type |
| 2158 | mask_array<_Tp>::operator&=(const _Expr& __v) const |
| 2159 | { |
| 2160 | size_t __n = __1d_.size(); |
| 2161 | for (size_t __i = 0; __i < __n; ++__i) |
| 2162 | __vp_[__1d_[__i]] &= __v[__i]; |
| 2163 | } |
| 2164 | |
| 2165 | template <class _Tp> |
| 2166 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2167 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2168 | typename enable_if |
| 2169 | < |
| 2170 | __is_val_expr<_Expr>::value, |
| 2171 | void |
| 2172 | >::type |
| 2173 | mask_array<_Tp>::operator|=(const _Expr& __v) const |
| 2174 | { |
| 2175 | size_t __n = __1d_.size(); |
| 2176 | for (size_t __i = 0; __i < __n; ++__i) |
| 2177 | __vp_[__1d_[__i]] |= __v[__i]; |
| 2178 | } |
| 2179 | |
| 2180 | template <class _Tp> |
| 2181 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2182 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2183 | typename enable_if |
| 2184 | < |
| 2185 | __is_val_expr<_Expr>::value, |
| 2186 | void |
| 2187 | >::type |
| 2188 | mask_array<_Tp>::operator<<=(const _Expr& __v) const |
| 2189 | { |
| 2190 | size_t __n = __1d_.size(); |
| 2191 | for (size_t __i = 0; __i < __n; ++__i) |
| 2192 | __vp_[__1d_[__i]] <<= __v[__i]; |
| 2193 | } |
| 2194 | |
| 2195 | template <class _Tp> |
| 2196 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2197 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2198 | typename enable_if |
| 2199 | < |
| 2200 | __is_val_expr<_Expr>::value, |
| 2201 | void |
| 2202 | >::type |
| 2203 | mask_array<_Tp>::operator>>=(const _Expr& __v) const |
| 2204 | { |
| 2205 | size_t __n = __1d_.size(); |
| 2206 | for (size_t __i = 0; __i < __n; ++__i) |
| 2207 | __vp_[__1d_[__i]] >>= __v[__i]; |
| 2208 | } |
| 2209 | |
| 2210 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2211 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2212 | const mask_array<_Tp>& |
| 2213 | mask_array<_Tp>::operator=(const mask_array& __ma) const |
| 2214 | { |
| 2215 | size_t __n = __1d_.size(); |
| 2216 | for (size_t __i = 0; __i < __n; ++__i) |
| 2217 | __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]]; |
Eric Fiselier | 3b80ce9 | 2014-08-12 00:06:58 +0000 | [diff] [blame] | 2218 | return *this; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2219 | } |
| 2220 | |
| 2221 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2222 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2223 | void |
| 2224 | mask_array<_Tp>::operator=(const value_type& __x) const |
| 2225 | { |
| 2226 | size_t __n = __1d_.size(); |
| 2227 | for (size_t __i = 0; __i < __n; ++__i) |
| 2228 | __vp_[__1d_[__i]] = __x; |
| 2229 | } |
| 2230 | |
| 2231 | template <class _ValExpr> |
| 2232 | class __mask_expr |
| 2233 | { |
| 2234 | typedef typename remove_reference<_ValExpr>::type _RmExpr; |
| 2235 | public: |
| 2236 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2237 | typedef value_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2238 | |
| 2239 | private: |
| 2240 | _ValExpr __expr_; |
| 2241 | valarray<size_t> __1d_; |
| 2242 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2243 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2244 | __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e) |
| 2245 | : __expr_(__e), |
Howard Hinnant | 28b2488 | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 2246 | __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2247 | { |
| 2248 | size_t __j = 0; |
| 2249 | for (size_t __i = 0; __i < __vb.size(); ++__i) |
| 2250 | if (__vb[__i]) |
| 2251 | __1d_[__j++] = __i; |
| 2252 | } |
| 2253 | |
| 2254 | public: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2255 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2256 | __result_type operator[](size_t __i) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2257 | {return __expr_[__1d_[__i]];} |
| 2258 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2259 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2260 | size_t size() const {return __1d_.size();} |
| 2261 | |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2262 | template <class> friend class __val_expr; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2263 | template <class> friend class valarray; |
| 2264 | }; |
| 2265 | |
| 2266 | // indirect_array |
| 2267 | |
| 2268 | template <class _Tp> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 2269 | class _LIBCPP_TEMPLATE_VIS indirect_array |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2270 | { |
| 2271 | public: |
| 2272 | typedef _Tp value_type; |
| 2273 | |
| 2274 | private: |
| 2275 | value_type* __vp_; |
| 2276 | valarray<size_t> __1d_; |
| 2277 | |
| 2278 | public: |
| 2279 | template <class _Expr> |
| 2280 | typename enable_if |
| 2281 | < |
| 2282 | __is_val_expr<_Expr>::value, |
| 2283 | void |
| 2284 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2285 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2286 | operator=(const _Expr& __v) const; |
| 2287 | |
| 2288 | template <class _Expr> |
| 2289 | typename enable_if |
| 2290 | < |
| 2291 | __is_val_expr<_Expr>::value, |
| 2292 | void |
| 2293 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2294 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2295 | operator*=(const _Expr& __v) const; |
| 2296 | |
| 2297 | template <class _Expr> |
| 2298 | typename enable_if |
| 2299 | < |
| 2300 | __is_val_expr<_Expr>::value, |
| 2301 | void |
| 2302 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2303 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2304 | operator/=(const _Expr& __v) const; |
| 2305 | |
| 2306 | template <class _Expr> |
| 2307 | typename enable_if |
| 2308 | < |
| 2309 | __is_val_expr<_Expr>::value, |
| 2310 | void |
| 2311 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2312 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2313 | operator%=(const _Expr& __v) const; |
| 2314 | |
| 2315 | template <class _Expr> |
| 2316 | typename enable_if |
| 2317 | < |
| 2318 | __is_val_expr<_Expr>::value, |
| 2319 | void |
| 2320 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2321 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2322 | operator+=(const _Expr& __v) const; |
| 2323 | |
| 2324 | template <class _Expr> |
| 2325 | typename enable_if |
| 2326 | < |
| 2327 | __is_val_expr<_Expr>::value, |
| 2328 | void |
| 2329 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2330 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2331 | operator-=(const _Expr& __v) const; |
| 2332 | |
| 2333 | template <class _Expr> |
| 2334 | typename enable_if |
| 2335 | < |
| 2336 | __is_val_expr<_Expr>::value, |
| 2337 | void |
| 2338 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2339 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2340 | operator^=(const _Expr& __v) const; |
| 2341 | |
| 2342 | template <class _Expr> |
| 2343 | typename enable_if |
| 2344 | < |
| 2345 | __is_val_expr<_Expr>::value, |
| 2346 | void |
| 2347 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2348 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2349 | operator&=(const _Expr& __v) const; |
| 2350 | |
| 2351 | template <class _Expr> |
| 2352 | typename enable_if |
| 2353 | < |
| 2354 | __is_val_expr<_Expr>::value, |
| 2355 | void |
| 2356 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2357 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2358 | operator|=(const _Expr& __v) const; |
| 2359 | |
| 2360 | template <class _Expr> |
| 2361 | typename enable_if |
| 2362 | < |
| 2363 | __is_val_expr<_Expr>::value, |
| 2364 | void |
| 2365 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2366 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2367 | operator<<=(const _Expr& __v) const; |
| 2368 | |
| 2369 | template <class _Expr> |
| 2370 | typename enable_if |
| 2371 | < |
| 2372 | __is_val_expr<_Expr>::value, |
| 2373 | void |
| 2374 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2375 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2376 | operator>>=(const _Expr& __v) const; |
| 2377 | |
Eric Fiselier | b9f37ca | 2019-12-12 20:48:11 -0500 | [diff] [blame] | 2378 | indirect_array(const indirect_array&) = default; |
| 2379 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2380 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2381 | const indirect_array& operator=(const indirect_array& __ia) const; |
| 2382 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2383 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2384 | void operator=(const value_type& __x) const; |
| 2385 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2386 | private: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2387 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2388 | indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v) |
| 2389 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
| 2390 | __1d_(__ia) |
| 2391 | {} |
| 2392 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 2393 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2394 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2395 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2396 | indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v) |
| 2397 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 2398 | __1d_(std::move(__ia)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2399 | {} |
| 2400 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2401 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2402 | |
| 2403 | template <class> friend class valarray; |
| 2404 | }; |
| 2405 | |
| 2406 | template <class _Tp> |
| 2407 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2408 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2409 | typename enable_if |
| 2410 | < |
| 2411 | __is_val_expr<_Expr>::value, |
| 2412 | void |
| 2413 | >::type |
| 2414 | indirect_array<_Tp>::operator=(const _Expr& __v) const |
| 2415 | { |
| 2416 | size_t __n = __1d_.size(); |
| 2417 | for (size_t __i = 0; __i < __n; ++__i) |
| 2418 | __vp_[__1d_[__i]] = __v[__i]; |
| 2419 | } |
| 2420 | |
| 2421 | template <class _Tp> |
| 2422 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2423 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2424 | typename enable_if |
| 2425 | < |
| 2426 | __is_val_expr<_Expr>::value, |
| 2427 | void |
| 2428 | >::type |
| 2429 | indirect_array<_Tp>::operator*=(const _Expr& __v) const |
| 2430 | { |
| 2431 | size_t __n = __1d_.size(); |
| 2432 | for (size_t __i = 0; __i < __n; ++__i) |
| 2433 | __vp_[__1d_[__i]] *= __v[__i]; |
| 2434 | } |
| 2435 | |
| 2436 | template <class _Tp> |
| 2437 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2438 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2439 | typename enable_if |
| 2440 | < |
| 2441 | __is_val_expr<_Expr>::value, |
| 2442 | void |
| 2443 | >::type |
| 2444 | indirect_array<_Tp>::operator/=(const _Expr& __v) const |
| 2445 | { |
| 2446 | size_t __n = __1d_.size(); |
| 2447 | for (size_t __i = 0; __i < __n; ++__i) |
| 2448 | __vp_[__1d_[__i]] /= __v[__i]; |
| 2449 | } |
| 2450 | |
| 2451 | template <class _Tp> |
| 2452 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2453 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2454 | typename enable_if |
| 2455 | < |
| 2456 | __is_val_expr<_Expr>::value, |
| 2457 | void |
| 2458 | >::type |
| 2459 | indirect_array<_Tp>::operator%=(const _Expr& __v) const |
| 2460 | { |
| 2461 | size_t __n = __1d_.size(); |
| 2462 | for (size_t __i = 0; __i < __n; ++__i) |
| 2463 | __vp_[__1d_[__i]] %= __v[__i]; |
| 2464 | } |
| 2465 | |
| 2466 | template <class _Tp> |
| 2467 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2468 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2469 | typename enable_if |
| 2470 | < |
| 2471 | __is_val_expr<_Expr>::value, |
| 2472 | void |
| 2473 | >::type |
| 2474 | indirect_array<_Tp>::operator+=(const _Expr& __v) const |
| 2475 | { |
| 2476 | size_t __n = __1d_.size(); |
| 2477 | for (size_t __i = 0; __i < __n; ++__i) |
| 2478 | __vp_[__1d_[__i]] += __v[__i]; |
| 2479 | } |
| 2480 | |
| 2481 | template <class _Tp> |
| 2482 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2483 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2484 | typename enable_if |
| 2485 | < |
| 2486 | __is_val_expr<_Expr>::value, |
| 2487 | void |
| 2488 | >::type |
| 2489 | indirect_array<_Tp>::operator-=(const _Expr& __v) const |
| 2490 | { |
| 2491 | size_t __n = __1d_.size(); |
| 2492 | for (size_t __i = 0; __i < __n; ++__i) |
| 2493 | __vp_[__1d_[__i]] -= __v[__i]; |
| 2494 | } |
| 2495 | |
| 2496 | template <class _Tp> |
| 2497 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2498 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2499 | typename enable_if |
| 2500 | < |
| 2501 | __is_val_expr<_Expr>::value, |
| 2502 | void |
| 2503 | >::type |
| 2504 | indirect_array<_Tp>::operator^=(const _Expr& __v) const |
| 2505 | { |
| 2506 | size_t __n = __1d_.size(); |
| 2507 | for (size_t __i = 0; __i < __n; ++__i) |
| 2508 | __vp_[__1d_[__i]] ^= __v[__i]; |
| 2509 | } |
| 2510 | |
| 2511 | template <class _Tp> |
| 2512 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2513 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2514 | typename enable_if |
| 2515 | < |
| 2516 | __is_val_expr<_Expr>::value, |
| 2517 | void |
| 2518 | >::type |
| 2519 | indirect_array<_Tp>::operator&=(const _Expr& __v) const |
| 2520 | { |
| 2521 | size_t __n = __1d_.size(); |
| 2522 | for (size_t __i = 0; __i < __n; ++__i) |
| 2523 | __vp_[__1d_[__i]] &= __v[__i]; |
| 2524 | } |
| 2525 | |
| 2526 | template <class _Tp> |
| 2527 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2528 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2529 | typename enable_if |
| 2530 | < |
| 2531 | __is_val_expr<_Expr>::value, |
| 2532 | void |
| 2533 | >::type |
| 2534 | indirect_array<_Tp>::operator|=(const _Expr& __v) const |
| 2535 | { |
| 2536 | size_t __n = __1d_.size(); |
| 2537 | for (size_t __i = 0; __i < __n; ++__i) |
| 2538 | __vp_[__1d_[__i]] |= __v[__i]; |
| 2539 | } |
| 2540 | |
| 2541 | template <class _Tp> |
| 2542 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2543 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2544 | typename enable_if |
| 2545 | < |
| 2546 | __is_val_expr<_Expr>::value, |
| 2547 | void |
| 2548 | >::type |
| 2549 | indirect_array<_Tp>::operator<<=(const _Expr& __v) const |
| 2550 | { |
| 2551 | size_t __n = __1d_.size(); |
| 2552 | for (size_t __i = 0; __i < __n; ++__i) |
| 2553 | __vp_[__1d_[__i]] <<= __v[__i]; |
| 2554 | } |
| 2555 | |
| 2556 | template <class _Tp> |
| 2557 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2558 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2559 | typename enable_if |
| 2560 | < |
| 2561 | __is_val_expr<_Expr>::value, |
| 2562 | void |
| 2563 | >::type |
| 2564 | indirect_array<_Tp>::operator>>=(const _Expr& __v) const |
| 2565 | { |
| 2566 | size_t __n = __1d_.size(); |
| 2567 | for (size_t __i = 0; __i < __n; ++__i) |
| 2568 | __vp_[__1d_[__i]] >>= __v[__i]; |
| 2569 | } |
| 2570 | |
| 2571 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2572 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2573 | const indirect_array<_Tp>& |
| 2574 | indirect_array<_Tp>::operator=(const indirect_array& __ia) const |
| 2575 | { |
| 2576 | typedef const size_t* _Ip; |
| 2577 | const value_type* __s = __ia.__vp_; |
| 2578 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; |
| 2579 | __i != __e; ++__i, ++__j) |
| 2580 | __vp_[*__i] = __s[*__j]; |
| 2581 | return *this; |
| 2582 | } |
| 2583 | |
| 2584 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2585 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2586 | void |
| 2587 | indirect_array<_Tp>::operator=(const value_type& __x) const |
| 2588 | { |
| 2589 | typedef const size_t* _Ip; |
| 2590 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) |
| 2591 | __vp_[*__i] = __x; |
| 2592 | } |
| 2593 | |
| 2594 | template <class _ValExpr> |
| 2595 | class __indirect_expr |
| 2596 | { |
| 2597 | typedef typename remove_reference<_ValExpr>::type _RmExpr; |
| 2598 | public: |
| 2599 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2600 | typedef value_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2601 | |
| 2602 | private: |
| 2603 | _ValExpr __expr_; |
| 2604 | valarray<size_t> __1d_; |
| 2605 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2606 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2607 | __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) |
| 2608 | : __expr_(__e), |
| 2609 | __1d_(__ia) |
| 2610 | {} |
| 2611 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 2612 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2613 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2614 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2615 | __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e) |
| 2616 | : __expr_(__e), |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 2617 | __1d_(std::move(__ia)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2618 | {} |
| 2619 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2620 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2621 | |
| 2622 | public: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2623 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2624 | __result_type operator[](size_t __i) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2625 | {return __expr_[__1d_[__i]];} |
| 2626 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2627 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2628 | size_t size() const {return __1d_.size();} |
| 2629 | |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2630 | template <class> friend class __val_expr; |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 2631 | template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2632 | }; |
| 2633 | |
| 2634 | template<class _ValExpr> |
| 2635 | class __val_expr |
| 2636 | { |
| 2637 | typedef typename remove_reference<_ValExpr>::type _RmExpr; |
| 2638 | |
| 2639 | _ValExpr __expr_; |
| 2640 | public: |
| 2641 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2642 | typedef typename _RmExpr::__result_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2643 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2644 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2645 | explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {} |
| 2646 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2647 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2648 | __result_type operator[](size_t __i) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2649 | {return __expr_[__i];} |
| 2650 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2651 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2652 | __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2653 | { |
| 2654 | typedef __slice_expr<_ValExpr> _NewExpr; |
| 2655 | return __val_expr< _NewExpr >(_NewExpr(__s, __expr_)); |
| 2656 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2657 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2658 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2659 | __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2660 | { |
| 2661 | typedef __indirect_expr<_ValExpr> _NewExpr; |
| 2662 | return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_)); |
| 2663 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2664 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2665 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2666 | __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2667 | { |
| 2668 | typedef __mask_expr<_ValExpr> _NewExpr; |
| 2669 | return __val_expr< _NewExpr >( _NewExpr(__vb, __expr_)); |
| 2670 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2671 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2672 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2673 | __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2674 | { |
| 2675 | typedef __indirect_expr<_ValExpr> _NewExpr; |
| 2676 | return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_)); |
| 2677 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2678 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2679 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2680 | __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> > |
| 2681 | operator+() const |
| 2682 | { |
| 2683 | typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr; |
| 2684 | return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_)); |
| 2685 | } |
| 2686 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2687 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2688 | __val_expr<_UnaryOp<negate<value_type>, _ValExpr> > |
| 2689 | operator-() const |
| 2690 | { |
| 2691 | typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr; |
| 2692 | return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_)); |
| 2693 | } |
| 2694 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2695 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2696 | __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> > |
| 2697 | operator~() const |
| 2698 | { |
| 2699 | typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr; |
| 2700 | return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_)); |
| 2701 | } |
| 2702 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2703 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2704 | __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> > |
| 2705 | operator!() const |
| 2706 | { |
| 2707 | typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr; |
| 2708 | return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_)); |
| 2709 | } |
| 2710 | |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2711 | operator valarray<__result_type>() const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2712 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2713 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2714 | size_t size() const {return __expr_.size();} |
| 2715 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2716 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2717 | __result_type sum() const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2718 | { |
| 2719 | size_t __n = __expr_.size(); |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2720 | __result_type __r = __n ? __expr_[0] : __result_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2721 | for (size_t __i = 1; __i < __n; ++__i) |
| 2722 | __r += __expr_[__i]; |
| 2723 | return __r; |
| 2724 | } |
| 2725 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2726 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2727 | __result_type min() const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2728 | { |
| 2729 | size_t __n = size(); |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2730 | __result_type __r = __n ? (*this)[0] : __result_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2731 | for (size_t __i = 1; __i < __n; ++__i) |
| 2732 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2733 | __result_type __x = __expr_[__i]; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2734 | if (__x < __r) |
| 2735 | __r = __x; |
| 2736 | } |
| 2737 | return __r; |
| 2738 | } |
| 2739 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2740 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2741 | __result_type max() const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2742 | { |
| 2743 | size_t __n = size(); |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2744 | __result_type __r = __n ? (*this)[0] : __result_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2745 | for (size_t __i = 1; __i < __n; ++__i) |
| 2746 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2747 | __result_type __x = __expr_[__i]; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2748 | if (__r < __x) |
| 2749 | __r = __x; |
| 2750 | } |
| 2751 | return __r; |
| 2752 | } |
| 2753 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2754 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2755 | __val_expr<__shift_expr<_ValExpr> > shift (int __i) const |
| 2756 | {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));} |
| 2757 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2758 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2759 | __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const |
| 2760 | {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));} |
| 2761 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2762 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2763 | __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> > |
| 2764 | apply(value_type __f(value_type)) const |
| 2765 | { |
| 2766 | typedef __apply_expr<value_type, value_type(*)(value_type)> _Op; |
| 2767 | typedef _UnaryOp<_Op, _ValExpr> _NewExpr; |
| 2768 | return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); |
| 2769 | } |
| 2770 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2771 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2772 | __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> > |
| 2773 | apply(value_type __f(const value_type&)) const |
| 2774 | { |
| 2775 | typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op; |
| 2776 | typedef _UnaryOp<_Op, _ValExpr> _NewExpr; |
| 2777 | return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); |
| 2778 | } |
| 2779 | }; |
| 2780 | |
| 2781 | template<class _ValExpr> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2782 | __val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2783 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2784 | valarray<__result_type> __r; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2785 | size_t __n = __expr_.size(); |
| 2786 | if (__n) |
| 2787 | { |
| 2788 | __r.__begin_ = |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2789 | __r.__end_ = allocator<__result_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2790 | for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i) |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2791 | ::new ((void*)__r.__end_) __result_type(__expr_[__i]); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2792 | } |
| 2793 | return __r; |
| 2794 | } |
| 2795 | |
| 2796 | // valarray |
| 2797 | |
| 2798 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2799 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2800 | valarray<_Tp>::valarray(size_t __n) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2801 | : __begin_(nullptr), |
| 2802 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2803 | { |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 2804 | if (__n) |
| 2805 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2806 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 2807 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2808 | try |
| 2809 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2810 | #endif // _LIBCPP_NO_EXCEPTIONS |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2811 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2812 | ::new ((void*)__end_) value_type(); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 2813 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2814 | } |
| 2815 | catch (...) |
| 2816 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2817 | __clear(__n); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 2818 | throw; |
| 2819 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2820 | #endif // _LIBCPP_NO_EXCEPTIONS |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 2821 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2822 | } |
| 2823 | |
| 2824 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2825 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2826 | valarray<_Tp>::valarray(const value_type& __x, size_t __n) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2827 | : __begin_(nullptr), |
| 2828 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2829 | { |
| 2830 | resize(__n, __x); |
| 2831 | } |
| 2832 | |
| 2833 | template <class _Tp> |
| 2834 | valarray<_Tp>::valarray(const value_type* __p, size_t __n) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2835 | : __begin_(nullptr), |
| 2836 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2837 | { |
| 2838 | if (__n) |
| 2839 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2840 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2841 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2842 | try |
| 2843 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2844 | #endif // _LIBCPP_NO_EXCEPTIONS |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2845 | for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2846 | ::new ((void*)__end_) value_type(*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2847 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2848 | } |
| 2849 | catch (...) |
| 2850 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2851 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2852 | throw; |
| 2853 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2854 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2855 | } |
| 2856 | } |
| 2857 | |
| 2858 | template <class _Tp> |
| 2859 | valarray<_Tp>::valarray(const valarray& __v) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2860 | : __begin_(nullptr), |
| 2861 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2862 | { |
| 2863 | if (__v.size()) |
| 2864 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2865 | __begin_ = __end_ = allocator<value_type>().allocate(__v.size()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2866 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2867 | try |
| 2868 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2869 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2870 | for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2871 | ::new ((void*)__end_) value_type(*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2872 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2873 | } |
| 2874 | catch (...) |
| 2875 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2876 | __clear(__v.size()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2877 | throw; |
| 2878 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2879 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2880 | } |
| 2881 | } |
| 2882 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 2883 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2884 | |
| 2885 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2886 | inline |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 2887 | valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2888 | : __begin_(__v.__begin_), |
| 2889 | __end_(__v.__end_) |
| 2890 | { |
| 2891 | __v.__begin_ = __v.__end_ = nullptr; |
| 2892 | } |
| 2893 | |
| 2894 | template <class _Tp> |
| 2895 | valarray<_Tp>::valarray(initializer_list<value_type> __il) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2896 | : __begin_(nullptr), |
| 2897 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2898 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2899 | const size_t __n = __il.size(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2900 | if (__n) |
| 2901 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2902 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2903 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2904 | try |
| 2905 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2906 | #endif // _LIBCPP_NO_EXCEPTIONS |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2907 | size_t __n_left = __n; |
| 2908 | for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2909 | ::new ((void*)__end_) value_type(*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2910 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2911 | } |
| 2912 | catch (...) |
| 2913 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2914 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2915 | throw; |
| 2916 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2917 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2918 | } |
| 2919 | } |
| 2920 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2921 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2922 | |
| 2923 | template <class _Tp> |
| 2924 | valarray<_Tp>::valarray(const slice_array<value_type>& __sa) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2925 | : __begin_(nullptr), |
| 2926 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2927 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2928 | const size_t __n = __sa.__size_; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2929 | if (__n) |
| 2930 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2931 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2932 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2933 | try |
| 2934 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2935 | #endif // _LIBCPP_NO_EXCEPTIONS |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2936 | size_t __n_left = __n; |
| 2937 | for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2938 | ::new ((void*)__end_) value_type(*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2939 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2940 | } |
| 2941 | catch (...) |
| 2942 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2943 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2944 | throw; |
| 2945 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2946 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2947 | } |
| 2948 | } |
| 2949 | |
| 2950 | template <class _Tp> |
| 2951 | valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2952 | : __begin_(nullptr), |
| 2953 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2954 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2955 | const size_t __n = __ga.__1d_.size(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2956 | if (__n) |
| 2957 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2958 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2959 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2960 | try |
| 2961 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2962 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2963 | typedef const size_t* _Ip; |
| 2964 | const value_type* __s = __ga.__vp_; |
| 2965 | for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; |
| 2966 | __i != __e; ++__i, ++__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2967 | ::new ((void*)__end_) value_type(__s[*__i]); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2968 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2969 | } |
| 2970 | catch (...) |
| 2971 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2972 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2973 | throw; |
| 2974 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2975 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2976 | } |
| 2977 | } |
| 2978 | |
| 2979 | template <class _Tp> |
| 2980 | valarray<_Tp>::valarray(const mask_array<value_type>& __ma) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2981 | : __begin_(nullptr), |
| 2982 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2983 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2984 | const size_t __n = __ma.__1d_.size(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2985 | if (__n) |
| 2986 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2987 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2988 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2989 | try |
| 2990 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2991 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2992 | typedef const size_t* _Ip; |
| 2993 | const value_type* __s = __ma.__vp_; |
| 2994 | for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; |
| 2995 | __i != __e; ++__i, ++__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2996 | ::new ((void*)__end_) value_type(__s[*__i]); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2997 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2998 | } |
| 2999 | catch (...) |
| 3000 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3001 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3002 | throw; |
| 3003 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3004 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3005 | } |
| 3006 | } |
| 3007 | |
| 3008 | template <class _Tp> |
| 3009 | valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 3010 | : __begin_(nullptr), |
| 3011 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3012 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3013 | const size_t __n = __ia.__1d_.size(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3014 | if (__n) |
| 3015 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3016 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3017 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3018 | try |
| 3019 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3020 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3021 | typedef const size_t* _Ip; |
| 3022 | const value_type* __s = __ia.__vp_; |
| 3023 | for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; |
| 3024 | __i != __e; ++__i, ++__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3025 | ::new ((void*)__end_) value_type(__s[*__i]); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3026 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3027 | } |
| 3028 | catch (...) |
| 3029 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3030 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3031 | throw; |
| 3032 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3033 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3034 | } |
| 3035 | } |
| 3036 | |
| 3037 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3038 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3039 | valarray<_Tp>::~valarray() |
| 3040 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3041 | __clear(size()); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 3042 | } |
| 3043 | |
| 3044 | template <class _Tp> |
| 3045 | valarray<_Tp>& |
| 3046 | valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) |
| 3047 | { |
| 3048 | size_t __n = __l - __f; |
| 3049 | if (size() != __n) |
| 3050 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3051 | __clear(size()); |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3052 | __begin_ = allocator<value_type>().allocate(__n); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 3053 | __end_ = __begin_ + __n; |
| 3054 | _VSTD::uninitialized_copy(__f, __l, __begin_); |
| 3055 | } else { |
| 3056 | _VSTD::copy(__f, __l, __begin_); |
| 3057 | } |
| 3058 | return *this; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3059 | } |
| 3060 | |
| 3061 | template <class _Tp> |
| 3062 | valarray<_Tp>& |
| 3063 | valarray<_Tp>::operator=(const valarray& __v) |
| 3064 | { |
Mark de Wever | 357a1fc | 2021-09-28 19:15:18 +0200 | [diff] [blame] | 3065 | if (this != _VSTD::addressof(__v)) |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 3066 | return __assign_range(__v.__begin_, __v.__end_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3067 | return *this; |
| 3068 | } |
| 3069 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 3070 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3071 | |
| 3072 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3073 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3074 | valarray<_Tp>& |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 3075 | valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3076 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3077 | __clear(size()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3078 | __begin_ = __v.__begin_; |
| 3079 | __end_ = __v.__end_; |
| 3080 | __v.__begin_ = nullptr; |
| 3081 | __v.__end_ = nullptr; |
| 3082 | return *this; |
| 3083 | } |
| 3084 | |
| 3085 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3086 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3087 | valarray<_Tp>& |
| 3088 | valarray<_Tp>::operator=(initializer_list<value_type> __il) |
| 3089 | { |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 3090 | return __assign_range(__il.begin(), __il.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3091 | } |
| 3092 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3093 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3094 | |
| 3095 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3096 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3097 | valarray<_Tp>& |
| 3098 | valarray<_Tp>::operator=(const value_type& __x) |
| 3099 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3100 | _VSTD::fill(__begin_, __end_, __x); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3101 | return *this; |
| 3102 | } |
| 3103 | |
| 3104 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3105 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3106 | valarray<_Tp>& |
| 3107 | valarray<_Tp>::operator=(const slice_array<value_type>& __sa) |
| 3108 | { |
| 3109 | value_type* __t = __begin_; |
| 3110 | const value_type* __s = __sa.__vp_; |
| 3111 | for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t) |
| 3112 | *__t = *__s; |
| 3113 | return *this; |
| 3114 | } |
| 3115 | |
| 3116 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3117 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3118 | valarray<_Tp>& |
| 3119 | valarray<_Tp>::operator=(const gslice_array<value_type>& __ga) |
| 3120 | { |
| 3121 | typedef const size_t* _Ip; |
| 3122 | value_type* __t = __begin_; |
| 3123 | const value_type* __s = __ga.__vp_; |
| 3124 | for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; |
| 3125 | __i != __e; ++__i, ++__t) |
| 3126 | *__t = __s[*__i]; |
| 3127 | return *this; |
| 3128 | } |
| 3129 | |
| 3130 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3131 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3132 | valarray<_Tp>& |
| 3133 | valarray<_Tp>::operator=(const mask_array<value_type>& __ma) |
| 3134 | { |
| 3135 | typedef const size_t* _Ip; |
| 3136 | value_type* __t = __begin_; |
| 3137 | const value_type* __s = __ma.__vp_; |
| 3138 | for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; |
| 3139 | __i != __e; ++__i, ++__t) |
| 3140 | *__t = __s[*__i]; |
| 3141 | return *this; |
| 3142 | } |
| 3143 | |
| 3144 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3145 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3146 | valarray<_Tp>& |
| 3147 | valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) |
| 3148 | { |
| 3149 | typedef const size_t* _Ip; |
| 3150 | value_type* __t = __begin_; |
| 3151 | const value_type* __s = __ia.__vp_; |
| 3152 | for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; |
| 3153 | __i != __e; ++__i, ++__t) |
| 3154 | *__t = __s[*__i]; |
| 3155 | return *this; |
| 3156 | } |
| 3157 | |
| 3158 | template <class _Tp> |
Howard Hinnant | 329cd41 | 2011-07-27 23:19:59 +0000 | [diff] [blame] | 3159 | template <class _ValExpr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3160 | inline |
Howard Hinnant | 329cd41 | 2011-07-27 23:19:59 +0000 | [diff] [blame] | 3161 | valarray<_Tp>& |
| 3162 | valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) |
| 3163 | { |
| 3164 | size_t __n = __v.size(); |
| 3165 | if (size() != __n) |
| 3166 | resize(__n); |
| 3167 | value_type* __t = __begin_; |
| 3168 | for (size_t __i = 0; __i != __n; ++__t, ++__i) |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 3169 | *__t = __result_type(__v[__i]); |
Howard Hinnant | 329cd41 | 2011-07-27 23:19:59 +0000 | [diff] [blame] | 3170 | return *this; |
| 3171 | } |
| 3172 | |
| 3173 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3174 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3175 | __val_expr<__slice_expr<const valarray<_Tp>&> > |
| 3176 | valarray<_Tp>::operator[](slice __s) const |
| 3177 | { |
| 3178 | return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this)); |
| 3179 | } |
| 3180 | |
| 3181 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3182 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3183 | slice_array<_Tp> |
| 3184 | valarray<_Tp>::operator[](slice __s) |
| 3185 | { |
| 3186 | return slice_array<value_type>(__s, *this); |
| 3187 | } |
| 3188 | |
| 3189 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3190 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3191 | __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 3192 | valarray<_Tp>::operator[](const gslice& __gs) const |
| 3193 | { |
| 3194 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this)); |
| 3195 | } |
| 3196 | |
| 3197 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3198 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3199 | gslice_array<_Tp> |
| 3200 | valarray<_Tp>::operator[](const gslice& __gs) |
| 3201 | { |
| 3202 | return gslice_array<value_type>(__gs, *this); |
| 3203 | } |
| 3204 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 3205 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3206 | |
| 3207 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3208 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3209 | __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 3210 | valarray<_Tp>::operator[](gslice&& __gs) const |
| 3211 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3212 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3213 | } |
| 3214 | |
| 3215 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3216 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3217 | gslice_array<_Tp> |
| 3218 | valarray<_Tp>::operator[](gslice&& __gs) |
| 3219 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3220 | return gslice_array<value_type>(std::move(__gs), *this); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3221 | } |
| 3222 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3223 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3224 | |
| 3225 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3226 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3227 | __val_expr<__mask_expr<const valarray<_Tp>&> > |
| 3228 | valarray<_Tp>::operator[](const valarray<bool>& __vb) const |
| 3229 | { |
| 3230 | return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this)); |
| 3231 | } |
| 3232 | |
| 3233 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3234 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3235 | mask_array<_Tp> |
| 3236 | valarray<_Tp>::operator[](const valarray<bool>& __vb) |
| 3237 | { |
| 3238 | return mask_array<value_type>(__vb, *this); |
| 3239 | } |
| 3240 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 3241 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3242 | |
| 3243 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3244 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3245 | __val_expr<__mask_expr<const valarray<_Tp>&> > |
| 3246 | valarray<_Tp>::operator[](valarray<bool>&& __vb) const |
| 3247 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3248 | return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3249 | } |
| 3250 | |
| 3251 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3252 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3253 | mask_array<_Tp> |
| 3254 | valarray<_Tp>::operator[](valarray<bool>&& __vb) |
| 3255 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3256 | return mask_array<value_type>(std::move(__vb), *this); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3257 | } |
| 3258 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3259 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3260 | |
| 3261 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3262 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3263 | __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 3264 | valarray<_Tp>::operator[](const valarray<size_t>& __vs) const |
| 3265 | { |
| 3266 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this)); |
| 3267 | } |
| 3268 | |
| 3269 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3270 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3271 | indirect_array<_Tp> |
| 3272 | valarray<_Tp>::operator[](const valarray<size_t>& __vs) |
| 3273 | { |
| 3274 | return indirect_array<value_type>(__vs, *this); |
| 3275 | } |
| 3276 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 3277 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3278 | |
| 3279 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3280 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3281 | __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 3282 | valarray<_Tp>::operator[](valarray<size_t>&& __vs) const |
| 3283 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3284 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3285 | } |
| 3286 | |
| 3287 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3288 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3289 | indirect_array<_Tp> |
| 3290 | valarray<_Tp>::operator[](valarray<size_t>&& __vs) |
| 3291 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3292 | return indirect_array<value_type>(std::move(__vs), *this); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3293 | } |
| 3294 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3295 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3296 | |
| 3297 | template <class _Tp> |
| 3298 | valarray<_Tp> |
| 3299 | valarray<_Tp>::operator+() const |
| 3300 | { |
| 3301 | valarray<value_type> __r; |
| 3302 | size_t __n = size(); |
| 3303 | if (__n) |
| 3304 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3305 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3306 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3307 | ::new ((void*)__r.__end_) value_type(+*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3308 | } |
| 3309 | return __r; |
| 3310 | } |
| 3311 | |
| 3312 | template <class _Tp> |
| 3313 | valarray<_Tp> |
| 3314 | valarray<_Tp>::operator-() const |
| 3315 | { |
| 3316 | valarray<value_type> __r; |
| 3317 | size_t __n = size(); |
| 3318 | if (__n) |
| 3319 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3320 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3321 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3322 | ::new ((void*)__r.__end_) value_type(-*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3323 | } |
| 3324 | return __r; |
| 3325 | } |
| 3326 | |
| 3327 | template <class _Tp> |
| 3328 | valarray<_Tp> |
| 3329 | valarray<_Tp>::operator~() const |
| 3330 | { |
| 3331 | valarray<value_type> __r; |
| 3332 | size_t __n = size(); |
| 3333 | if (__n) |
| 3334 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3335 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3336 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3337 | ::new ((void*)__r.__end_) value_type(~*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3338 | } |
| 3339 | return __r; |
| 3340 | } |
| 3341 | |
| 3342 | template <class _Tp> |
| 3343 | valarray<bool> |
| 3344 | valarray<_Tp>::operator!() const |
| 3345 | { |
| 3346 | valarray<bool> __r; |
| 3347 | size_t __n = size(); |
| 3348 | if (__n) |
| 3349 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3350 | __r.__begin_ = __r.__end_ = allocator<bool>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3351 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3352 | ::new ((void*)__r.__end_) bool(!*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3353 | } |
| 3354 | return __r; |
| 3355 | } |
| 3356 | |
| 3357 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3358 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3359 | valarray<_Tp>& |
| 3360 | valarray<_Tp>::operator*=(const value_type& __x) |
| 3361 | { |
| 3362 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3363 | *__p *= __x; |
| 3364 | return *this; |
| 3365 | } |
| 3366 | |
| 3367 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3368 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3369 | valarray<_Tp>& |
| 3370 | valarray<_Tp>::operator/=(const value_type& __x) |
| 3371 | { |
| 3372 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3373 | *__p /= __x; |
| 3374 | return *this; |
| 3375 | } |
| 3376 | |
| 3377 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3378 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3379 | valarray<_Tp>& |
| 3380 | valarray<_Tp>::operator%=(const value_type& __x) |
| 3381 | { |
| 3382 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3383 | *__p %= __x; |
| 3384 | return *this; |
| 3385 | } |
| 3386 | |
| 3387 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3388 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3389 | valarray<_Tp>& |
| 3390 | valarray<_Tp>::operator+=(const value_type& __x) |
| 3391 | { |
| 3392 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3393 | *__p += __x; |
| 3394 | return *this; |
| 3395 | } |
| 3396 | |
| 3397 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3398 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3399 | valarray<_Tp>& |
| 3400 | valarray<_Tp>::operator-=(const value_type& __x) |
| 3401 | { |
| 3402 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3403 | *__p -= __x; |
| 3404 | return *this; |
| 3405 | } |
| 3406 | |
| 3407 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3408 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3409 | valarray<_Tp>& |
| 3410 | valarray<_Tp>::operator^=(const value_type& __x) |
| 3411 | { |
| 3412 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3413 | *__p ^= __x; |
| 3414 | return *this; |
| 3415 | } |
| 3416 | |
| 3417 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3418 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3419 | valarray<_Tp>& |
| 3420 | valarray<_Tp>::operator&=(const value_type& __x) |
| 3421 | { |
| 3422 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3423 | *__p &= __x; |
| 3424 | return *this; |
| 3425 | } |
| 3426 | |
| 3427 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3428 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3429 | valarray<_Tp>& |
| 3430 | valarray<_Tp>::operator|=(const value_type& __x) |
| 3431 | { |
| 3432 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3433 | *__p |= __x; |
| 3434 | return *this; |
| 3435 | } |
| 3436 | |
| 3437 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3438 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3439 | valarray<_Tp>& |
| 3440 | valarray<_Tp>::operator<<=(const value_type& __x) |
| 3441 | { |
| 3442 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3443 | *__p <<= __x; |
| 3444 | return *this; |
| 3445 | } |
| 3446 | |
| 3447 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3448 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3449 | valarray<_Tp>& |
| 3450 | valarray<_Tp>::operator>>=(const value_type& __x) |
| 3451 | { |
| 3452 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3453 | *__p >>= __x; |
| 3454 | return *this; |
| 3455 | } |
| 3456 | |
| 3457 | template <class _Tp> |
| 3458 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3459 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3460 | typename enable_if |
| 3461 | < |
| 3462 | __is_val_expr<_Expr>::value, |
| 3463 | valarray<_Tp>& |
| 3464 | >::type |
| 3465 | valarray<_Tp>::operator*=(const _Expr& __v) |
| 3466 | { |
| 3467 | size_t __i = 0; |
| 3468 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3469 | *__t *= __v[__i]; |
| 3470 | return *this; |
| 3471 | } |
| 3472 | |
| 3473 | template <class _Tp> |
| 3474 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3475 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3476 | typename enable_if |
| 3477 | < |
| 3478 | __is_val_expr<_Expr>::value, |
| 3479 | valarray<_Tp>& |
| 3480 | >::type |
| 3481 | valarray<_Tp>::operator/=(const _Expr& __v) |
| 3482 | { |
| 3483 | size_t __i = 0; |
| 3484 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3485 | *__t /= __v[__i]; |
| 3486 | return *this; |
| 3487 | } |
| 3488 | |
| 3489 | template <class _Tp> |
| 3490 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3491 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3492 | typename enable_if |
| 3493 | < |
| 3494 | __is_val_expr<_Expr>::value, |
| 3495 | valarray<_Tp>& |
| 3496 | >::type |
| 3497 | valarray<_Tp>::operator%=(const _Expr& __v) |
| 3498 | { |
| 3499 | size_t __i = 0; |
| 3500 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3501 | *__t %= __v[__i]; |
| 3502 | return *this; |
| 3503 | } |
| 3504 | |
| 3505 | template <class _Tp> |
| 3506 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3507 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3508 | typename enable_if |
| 3509 | < |
| 3510 | __is_val_expr<_Expr>::value, |
| 3511 | valarray<_Tp>& |
| 3512 | >::type |
| 3513 | valarray<_Tp>::operator+=(const _Expr& __v) |
| 3514 | { |
| 3515 | size_t __i = 0; |
| 3516 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3517 | *__t += __v[__i]; |
| 3518 | return *this; |
| 3519 | } |
| 3520 | |
| 3521 | template <class _Tp> |
| 3522 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3523 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3524 | typename enable_if |
| 3525 | < |
| 3526 | __is_val_expr<_Expr>::value, |
| 3527 | valarray<_Tp>& |
| 3528 | >::type |
| 3529 | valarray<_Tp>::operator-=(const _Expr& __v) |
| 3530 | { |
| 3531 | size_t __i = 0; |
| 3532 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3533 | *__t -= __v[__i]; |
| 3534 | return *this; |
| 3535 | } |
| 3536 | |
| 3537 | template <class _Tp> |
| 3538 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3539 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3540 | typename enable_if |
| 3541 | < |
| 3542 | __is_val_expr<_Expr>::value, |
| 3543 | valarray<_Tp>& |
| 3544 | >::type |
| 3545 | valarray<_Tp>::operator^=(const _Expr& __v) |
| 3546 | { |
| 3547 | size_t __i = 0; |
| 3548 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3549 | *__t ^= __v[__i]; |
| 3550 | return *this; |
| 3551 | } |
| 3552 | |
| 3553 | template <class _Tp> |
| 3554 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3555 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3556 | typename enable_if |
| 3557 | < |
| 3558 | __is_val_expr<_Expr>::value, |
| 3559 | valarray<_Tp>& |
| 3560 | >::type |
| 3561 | valarray<_Tp>::operator|=(const _Expr& __v) |
| 3562 | { |
| 3563 | size_t __i = 0; |
| 3564 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3565 | *__t |= __v[__i]; |
| 3566 | return *this; |
| 3567 | } |
| 3568 | |
| 3569 | template <class _Tp> |
| 3570 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3571 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3572 | typename enable_if |
| 3573 | < |
| 3574 | __is_val_expr<_Expr>::value, |
| 3575 | valarray<_Tp>& |
| 3576 | >::type |
| 3577 | valarray<_Tp>::operator&=(const _Expr& __v) |
| 3578 | { |
| 3579 | size_t __i = 0; |
| 3580 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3581 | *__t &= __v[__i]; |
| 3582 | return *this; |
| 3583 | } |
| 3584 | |
| 3585 | template <class _Tp> |
| 3586 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3587 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3588 | typename enable_if |
| 3589 | < |
| 3590 | __is_val_expr<_Expr>::value, |
| 3591 | valarray<_Tp>& |
| 3592 | >::type |
| 3593 | valarray<_Tp>::operator<<=(const _Expr& __v) |
| 3594 | { |
| 3595 | size_t __i = 0; |
| 3596 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3597 | *__t <<= __v[__i]; |
| 3598 | return *this; |
| 3599 | } |
| 3600 | |
| 3601 | template <class _Tp> |
| 3602 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3603 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3604 | typename enable_if |
| 3605 | < |
| 3606 | __is_val_expr<_Expr>::value, |
| 3607 | valarray<_Tp>& |
| 3608 | >::type |
| 3609 | valarray<_Tp>::operator>>=(const _Expr& __v) |
| 3610 | { |
| 3611 | size_t __i = 0; |
| 3612 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3613 | *__t >>= __v[__i]; |
| 3614 | return *this; |
| 3615 | } |
| 3616 | |
| 3617 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3618 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3619 | void |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 3620 | valarray<_Tp>::swap(valarray& __v) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3621 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3622 | _VSTD::swap(__begin_, __v.__begin_); |
| 3623 | _VSTD::swap(__end_, __v.__end_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3624 | } |
| 3625 | |
| 3626 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3627 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3628 | _Tp |
| 3629 | valarray<_Tp>::sum() const |
| 3630 | { |
| 3631 | if (__begin_ == __end_) |
| 3632 | return value_type(); |
| 3633 | const value_type* __p = __begin_; |
| 3634 | _Tp __r = *__p; |
| 3635 | for (++__p; __p != __end_; ++__p) |
| 3636 | __r += *__p; |
| 3637 | return __r; |
| 3638 | } |
| 3639 | |
| 3640 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3641 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3642 | _Tp |
| 3643 | valarray<_Tp>::min() const |
| 3644 | { |
| 3645 | if (__begin_ == __end_) |
| 3646 | return value_type(); |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3647 | return *_VSTD::min_element(__begin_, __end_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3648 | } |
| 3649 | |
| 3650 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3651 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3652 | _Tp |
| 3653 | valarray<_Tp>::max() const |
| 3654 | { |
| 3655 | if (__begin_ == __end_) |
| 3656 | return value_type(); |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3657 | return *_VSTD::max_element(__begin_, __end_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3658 | } |
| 3659 | |
| 3660 | template <class _Tp> |
| 3661 | valarray<_Tp> |
| 3662 | valarray<_Tp>::shift(int __i) const |
| 3663 | { |
| 3664 | valarray<value_type> __r; |
| 3665 | size_t __n = size(); |
| 3666 | if (__n) |
| 3667 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3668 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3669 | const value_type* __sb; |
| 3670 | value_type* __tb; |
| 3671 | value_type* __te; |
| 3672 | if (__i >= 0) |
| 3673 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3674 | __i = _VSTD::min(__i, static_cast<int>(__n)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3675 | __sb = __begin_ + __i; |
| 3676 | __tb = __r.__begin_; |
| 3677 | __te = __r.__begin_ + (__n - __i); |
| 3678 | } |
| 3679 | else |
| 3680 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3681 | __i = _VSTD::min(-__i, static_cast<int>(__n)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3682 | __sb = __begin_; |
| 3683 | __tb = __r.__begin_ + __i; |
| 3684 | __te = __r.__begin_ + __n; |
| 3685 | } |
| 3686 | for (; __r.__end_ != __tb; ++__r.__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3687 | ::new ((void*)__r.__end_) value_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3688 | for (; __r.__end_ != __te; ++__r.__end_, ++__sb) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3689 | ::new ((void*)__r.__end_) value_type(*__sb); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3690 | for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3691 | ::new ((void*)__r.__end_) value_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3692 | } |
| 3693 | return __r; |
| 3694 | } |
| 3695 | |
| 3696 | template <class _Tp> |
| 3697 | valarray<_Tp> |
| 3698 | valarray<_Tp>::cshift(int __i) const |
| 3699 | { |
| 3700 | valarray<value_type> __r; |
| 3701 | size_t __n = size(); |
| 3702 | if (__n) |
| 3703 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3704 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3705 | __i %= static_cast<int>(__n); |
| 3706 | const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i; |
| 3707 | for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3708 | ::new ((void*)__r.__end_) value_type(*__s); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3709 | for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3710 | ::new ((void*)__r.__end_) value_type(*__s); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3711 | } |
| 3712 | return __r; |
| 3713 | } |
| 3714 | |
| 3715 | template <class _Tp> |
| 3716 | valarray<_Tp> |
| 3717 | valarray<_Tp>::apply(value_type __f(value_type)) const |
| 3718 | { |
| 3719 | valarray<value_type> __r; |
| 3720 | size_t __n = size(); |
| 3721 | if (__n) |
| 3722 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3723 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3724 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3725 | ::new ((void*)__r.__end_) value_type(__f(*__p)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3726 | } |
| 3727 | return __r; |
| 3728 | } |
| 3729 | |
| 3730 | template <class _Tp> |
| 3731 | valarray<_Tp> |
| 3732 | valarray<_Tp>::apply(value_type __f(const value_type&)) const |
| 3733 | { |
| 3734 | valarray<value_type> __r; |
| 3735 | size_t __n = size(); |
| 3736 | if (__n) |
| 3737 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3738 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3739 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3740 | ::new ((void*)__r.__end_) value_type(__f(*__p)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3741 | } |
| 3742 | return __r; |
| 3743 | } |
| 3744 | |
| 3745 | template <class _Tp> |
Eric Fiselier | a119c32 | 2018-10-25 17:43:26 +0000 | [diff] [blame] | 3746 | inline |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3747 | void valarray<_Tp>::__clear(size_t __capacity) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3748 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3749 | if (__begin_ != nullptr) |
| 3750 | { |
| 3751 | while (__end_ != __begin_) |
| 3752 | (--__end_)->~value_type(); |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3753 | allocator<value_type>().deallocate(__begin_, __capacity); |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3754 | __begin_ = __end_ = nullptr; |
| 3755 | } |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 3756 | } |
| 3757 | |
| 3758 | template <class _Tp> |
| 3759 | void |
| 3760 | valarray<_Tp>::resize(size_t __n, value_type __x) |
| 3761 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3762 | __clear(size()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3763 | if (__n) |
| 3764 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3765 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3766 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3767 | try |
| 3768 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3769 | #endif // _LIBCPP_NO_EXCEPTIONS |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3770 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3771 | ::new ((void*)__end_) value_type(__x); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3772 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3773 | } |
| 3774 | catch (...) |
| 3775 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3776 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3777 | throw; |
| 3778 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3779 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3780 | } |
| 3781 | } |
| 3782 | |
| 3783 | template<class _Tp> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3784 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3785 | void |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 3786 | swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3787 | { |
| 3788 | __x.swap(__y); |
| 3789 | } |
| 3790 | |
| 3791 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3792 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3793 | typename enable_if |
| 3794 | < |
| 3795 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 3796 | __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3797 | >::type |
| 3798 | operator*(const _Expr1& __x, const _Expr2& __y) |
| 3799 | { |
| 3800 | typedef typename _Expr1::value_type value_type; |
| 3801 | typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op; |
| 3802 | return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y)); |
| 3803 | } |
| 3804 | |
| 3805 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3806 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3807 | typename enable_if |
| 3808 | < |
| 3809 | __is_val_expr<_Expr>::value, |
| 3810 | __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, |
| 3811 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3812 | >::type |
| 3813 | operator*(const _Expr& __x, const typename _Expr::value_type& __y) |
| 3814 | { |
| 3815 | typedef typename _Expr::value_type value_type; |
| 3816 | typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3817 | return __val_expr<_Op>(_Op(multiplies<value_type>(), |
| 3818 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3819 | } |
| 3820 | |
| 3821 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3822 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3823 | typename enable_if |
| 3824 | < |
| 3825 | __is_val_expr<_Expr>::value, |
| 3826 | __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, |
| 3827 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3828 | >::type |
| 3829 | operator*(const typename _Expr::value_type& __x, const _Expr& __y) |
| 3830 | { |
| 3831 | typedef typename _Expr::value_type value_type; |
| 3832 | typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3833 | return __val_expr<_Op>(_Op(multiplies<value_type>(), |
| 3834 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 3835 | } |
| 3836 | |
| 3837 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3838 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3839 | typename enable_if |
| 3840 | < |
| 3841 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 3842 | __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3843 | >::type |
| 3844 | operator/(const _Expr1& __x, const _Expr2& __y) |
| 3845 | { |
| 3846 | typedef typename _Expr1::value_type value_type; |
| 3847 | typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op; |
| 3848 | return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y)); |
| 3849 | } |
| 3850 | |
| 3851 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3852 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3853 | typename enable_if |
| 3854 | < |
| 3855 | __is_val_expr<_Expr>::value, |
| 3856 | __val_expr<_BinaryOp<divides<typename _Expr::value_type>, |
| 3857 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3858 | >::type |
| 3859 | operator/(const _Expr& __x, const typename _Expr::value_type& __y) |
| 3860 | { |
| 3861 | typedef typename _Expr::value_type value_type; |
| 3862 | typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3863 | return __val_expr<_Op>(_Op(divides<value_type>(), |
| 3864 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3865 | } |
| 3866 | |
| 3867 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3868 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3869 | typename enable_if |
| 3870 | < |
| 3871 | __is_val_expr<_Expr>::value, |
| 3872 | __val_expr<_BinaryOp<divides<typename _Expr::value_type>, |
| 3873 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3874 | >::type |
| 3875 | operator/(const typename _Expr::value_type& __x, const _Expr& __y) |
| 3876 | { |
| 3877 | typedef typename _Expr::value_type value_type; |
| 3878 | typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3879 | return __val_expr<_Op>(_Op(divides<value_type>(), |
| 3880 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 3881 | } |
| 3882 | |
| 3883 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3884 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3885 | typename enable_if |
| 3886 | < |
| 3887 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 3888 | __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3889 | >::type |
| 3890 | operator%(const _Expr1& __x, const _Expr2& __y) |
| 3891 | { |
| 3892 | typedef typename _Expr1::value_type value_type; |
| 3893 | typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op; |
| 3894 | return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y)); |
| 3895 | } |
| 3896 | |
| 3897 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3898 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3899 | typename enable_if |
| 3900 | < |
| 3901 | __is_val_expr<_Expr>::value, |
| 3902 | __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, |
| 3903 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3904 | >::type |
| 3905 | operator%(const _Expr& __x, const typename _Expr::value_type& __y) |
| 3906 | { |
| 3907 | typedef typename _Expr::value_type value_type; |
| 3908 | typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3909 | return __val_expr<_Op>(_Op(modulus<value_type>(), |
| 3910 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3911 | } |
| 3912 | |
| 3913 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3914 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3915 | typename enable_if |
| 3916 | < |
| 3917 | __is_val_expr<_Expr>::value, |
| 3918 | __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, |
| 3919 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3920 | >::type |
| 3921 | operator%(const typename _Expr::value_type& __x, const _Expr& __y) |
| 3922 | { |
| 3923 | typedef typename _Expr::value_type value_type; |
| 3924 | typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3925 | return __val_expr<_Op>(_Op(modulus<value_type>(), |
| 3926 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 3927 | } |
| 3928 | |
| 3929 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3930 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3931 | typename enable_if |
| 3932 | < |
| 3933 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 3934 | __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3935 | >::type |
| 3936 | operator+(const _Expr1& __x, const _Expr2& __y) |
| 3937 | { |
| 3938 | typedef typename _Expr1::value_type value_type; |
| 3939 | typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op; |
| 3940 | return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y)); |
| 3941 | } |
| 3942 | |
| 3943 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3944 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3945 | typename enable_if |
| 3946 | < |
| 3947 | __is_val_expr<_Expr>::value, |
| 3948 | __val_expr<_BinaryOp<plus<typename _Expr::value_type>, |
| 3949 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3950 | >::type |
| 3951 | operator+(const _Expr& __x, const typename _Expr::value_type& __y) |
| 3952 | { |
| 3953 | typedef typename _Expr::value_type value_type; |
| 3954 | typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3955 | return __val_expr<_Op>(_Op(plus<value_type>(), |
| 3956 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3957 | } |
| 3958 | |
| 3959 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3960 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3961 | typename enable_if |
| 3962 | < |
| 3963 | __is_val_expr<_Expr>::value, |
| 3964 | __val_expr<_BinaryOp<plus<typename _Expr::value_type>, |
| 3965 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3966 | >::type |
| 3967 | operator+(const typename _Expr::value_type& __x, const _Expr& __y) |
| 3968 | { |
| 3969 | typedef typename _Expr::value_type value_type; |
| 3970 | typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3971 | return __val_expr<_Op>(_Op(plus<value_type>(), |
| 3972 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 3973 | } |
| 3974 | |
| 3975 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3976 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3977 | typename enable_if |
| 3978 | < |
| 3979 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 3980 | __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3981 | >::type |
| 3982 | operator-(const _Expr1& __x, const _Expr2& __y) |
| 3983 | { |
| 3984 | typedef typename _Expr1::value_type value_type; |
| 3985 | typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op; |
| 3986 | return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y)); |
| 3987 | } |
| 3988 | |
| 3989 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3990 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3991 | typename enable_if |
| 3992 | < |
| 3993 | __is_val_expr<_Expr>::value, |
| 3994 | __val_expr<_BinaryOp<minus<typename _Expr::value_type>, |
| 3995 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3996 | >::type |
| 3997 | operator-(const _Expr& __x, const typename _Expr::value_type& __y) |
| 3998 | { |
| 3999 | typedef typename _Expr::value_type value_type; |
| 4000 | typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4001 | return __val_expr<_Op>(_Op(minus<value_type>(), |
| 4002 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4003 | } |
| 4004 | |
| 4005 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4006 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4007 | typename enable_if |
| 4008 | < |
| 4009 | __is_val_expr<_Expr>::value, |
| 4010 | __val_expr<_BinaryOp<minus<typename _Expr::value_type>, |
| 4011 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4012 | >::type |
| 4013 | operator-(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4014 | { |
| 4015 | typedef typename _Expr::value_type value_type; |
| 4016 | typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4017 | return __val_expr<_Op>(_Op(minus<value_type>(), |
| 4018 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4019 | } |
| 4020 | |
| 4021 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4022 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4023 | typename enable_if |
| 4024 | < |
| 4025 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4026 | __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4027 | >::type |
| 4028 | operator^(const _Expr1& __x, const _Expr2& __y) |
| 4029 | { |
| 4030 | typedef typename _Expr1::value_type value_type; |
| 4031 | typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op; |
| 4032 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y)); |
| 4033 | } |
| 4034 | |
| 4035 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4036 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4037 | typename enable_if |
| 4038 | < |
| 4039 | __is_val_expr<_Expr>::value, |
| 4040 | __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, |
| 4041 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4042 | >::type |
| 4043 | operator^(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4044 | { |
| 4045 | typedef typename _Expr::value_type value_type; |
| 4046 | typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4047 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), |
| 4048 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4049 | } |
| 4050 | |
| 4051 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4052 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4053 | typename enable_if |
| 4054 | < |
| 4055 | __is_val_expr<_Expr>::value, |
| 4056 | __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, |
| 4057 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4058 | >::type |
| 4059 | operator^(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4060 | { |
| 4061 | typedef typename _Expr::value_type value_type; |
| 4062 | typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4063 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), |
| 4064 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4065 | } |
| 4066 | |
| 4067 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4068 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4069 | typename enable_if |
| 4070 | < |
| 4071 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4072 | __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4073 | >::type |
| 4074 | operator&(const _Expr1& __x, const _Expr2& __y) |
| 4075 | { |
| 4076 | typedef typename _Expr1::value_type value_type; |
| 4077 | typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op; |
| 4078 | return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y)); |
| 4079 | } |
| 4080 | |
| 4081 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4082 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4083 | typename enable_if |
| 4084 | < |
| 4085 | __is_val_expr<_Expr>::value, |
| 4086 | __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, |
| 4087 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4088 | >::type |
| 4089 | operator&(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4090 | { |
| 4091 | typedef typename _Expr::value_type value_type; |
| 4092 | typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4093 | return __val_expr<_Op>(_Op(bit_and<value_type>(), |
| 4094 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4095 | } |
| 4096 | |
| 4097 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4098 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4099 | typename enable_if |
| 4100 | < |
| 4101 | __is_val_expr<_Expr>::value, |
| 4102 | __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, |
| 4103 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4104 | >::type |
| 4105 | operator&(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4106 | { |
| 4107 | typedef typename _Expr::value_type value_type; |
| 4108 | typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4109 | return __val_expr<_Op>(_Op(bit_and<value_type>(), |
| 4110 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4111 | } |
| 4112 | |
| 4113 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4114 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4115 | typename enable_if |
| 4116 | < |
| 4117 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4118 | __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4119 | >::type |
| 4120 | operator|(const _Expr1& __x, const _Expr2& __y) |
| 4121 | { |
| 4122 | typedef typename _Expr1::value_type value_type; |
| 4123 | typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op; |
| 4124 | return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y)); |
| 4125 | } |
| 4126 | |
| 4127 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4128 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4129 | typename enable_if |
| 4130 | < |
| 4131 | __is_val_expr<_Expr>::value, |
| 4132 | __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, |
| 4133 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4134 | >::type |
| 4135 | operator|(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4136 | { |
| 4137 | typedef typename _Expr::value_type value_type; |
| 4138 | typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4139 | return __val_expr<_Op>(_Op(bit_or<value_type>(), |
| 4140 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4141 | } |
| 4142 | |
| 4143 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4144 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4145 | typename enable_if |
| 4146 | < |
| 4147 | __is_val_expr<_Expr>::value, |
| 4148 | __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, |
| 4149 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4150 | >::type |
| 4151 | operator|(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4152 | { |
| 4153 | typedef typename _Expr::value_type value_type; |
| 4154 | typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4155 | return __val_expr<_Op>(_Op(bit_or<value_type>(), |
| 4156 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4157 | } |
| 4158 | |
| 4159 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4160 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4161 | typename enable_if |
| 4162 | < |
| 4163 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4164 | __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4165 | >::type |
| 4166 | operator<<(const _Expr1& __x, const _Expr2& __y) |
| 4167 | { |
| 4168 | typedef typename _Expr1::value_type value_type; |
| 4169 | typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op; |
| 4170 | return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y)); |
| 4171 | } |
| 4172 | |
| 4173 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4174 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4175 | typename enable_if |
| 4176 | < |
| 4177 | __is_val_expr<_Expr>::value, |
| 4178 | __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, |
| 4179 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4180 | >::type |
| 4181 | operator<<(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4182 | { |
| 4183 | typedef typename _Expr::value_type value_type; |
| 4184 | typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4185 | return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), |
| 4186 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4187 | } |
| 4188 | |
| 4189 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4190 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4191 | typename enable_if |
| 4192 | < |
| 4193 | __is_val_expr<_Expr>::value, |
| 4194 | __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, |
| 4195 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4196 | >::type |
| 4197 | operator<<(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4198 | { |
| 4199 | typedef typename _Expr::value_type value_type; |
| 4200 | typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4201 | return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), |
| 4202 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4203 | } |
| 4204 | |
| 4205 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4206 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4207 | typename enable_if |
| 4208 | < |
| 4209 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4210 | __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4211 | >::type |
| 4212 | operator>>(const _Expr1& __x, const _Expr2& __y) |
| 4213 | { |
| 4214 | typedef typename _Expr1::value_type value_type; |
| 4215 | typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op; |
| 4216 | return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y)); |
| 4217 | } |
| 4218 | |
| 4219 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4220 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4221 | typename enable_if |
| 4222 | < |
| 4223 | __is_val_expr<_Expr>::value, |
| 4224 | __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, |
| 4225 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4226 | >::type |
| 4227 | operator>>(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4228 | { |
| 4229 | typedef typename _Expr::value_type value_type; |
| 4230 | typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4231 | return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), |
| 4232 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4233 | } |
| 4234 | |
| 4235 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4236 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4237 | typename enable_if |
| 4238 | < |
| 4239 | __is_val_expr<_Expr>::value, |
| 4240 | __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, |
| 4241 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4242 | >::type |
| 4243 | operator>>(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4244 | { |
| 4245 | typedef typename _Expr::value_type value_type; |
| 4246 | typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4247 | return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), |
| 4248 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4249 | } |
| 4250 | |
| 4251 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4252 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4253 | typename enable_if |
| 4254 | < |
| 4255 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4256 | __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4257 | >::type |
| 4258 | operator&&(const _Expr1& __x, const _Expr2& __y) |
| 4259 | { |
| 4260 | typedef typename _Expr1::value_type value_type; |
| 4261 | typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op; |
| 4262 | return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y)); |
| 4263 | } |
| 4264 | |
| 4265 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4266 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4267 | typename enable_if |
| 4268 | < |
| 4269 | __is_val_expr<_Expr>::value, |
| 4270 | __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, |
| 4271 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4272 | >::type |
| 4273 | operator&&(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4274 | { |
| 4275 | typedef typename _Expr::value_type value_type; |
| 4276 | typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4277 | return __val_expr<_Op>(_Op(logical_and<value_type>(), |
| 4278 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4279 | } |
| 4280 | |
| 4281 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4282 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4283 | typename enable_if |
| 4284 | < |
| 4285 | __is_val_expr<_Expr>::value, |
| 4286 | __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, |
| 4287 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4288 | >::type |
| 4289 | operator&&(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4290 | { |
| 4291 | typedef typename _Expr::value_type value_type; |
| 4292 | typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4293 | return __val_expr<_Op>(_Op(logical_and<value_type>(), |
| 4294 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4295 | } |
| 4296 | |
| 4297 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4298 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4299 | typename enable_if |
| 4300 | < |
| 4301 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4302 | __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4303 | >::type |
| 4304 | operator||(const _Expr1& __x, const _Expr2& __y) |
| 4305 | { |
| 4306 | typedef typename _Expr1::value_type value_type; |
| 4307 | typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op; |
| 4308 | return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y)); |
| 4309 | } |
| 4310 | |
| 4311 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4312 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4313 | typename enable_if |
| 4314 | < |
| 4315 | __is_val_expr<_Expr>::value, |
| 4316 | __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, |
| 4317 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4318 | >::type |
| 4319 | operator||(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4320 | { |
| 4321 | typedef typename _Expr::value_type value_type; |
| 4322 | typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4323 | return __val_expr<_Op>(_Op(logical_or<value_type>(), |
| 4324 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4325 | } |
| 4326 | |
| 4327 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4328 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4329 | typename enable_if |
| 4330 | < |
| 4331 | __is_val_expr<_Expr>::value, |
| 4332 | __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, |
| 4333 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4334 | >::type |
| 4335 | operator||(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4336 | { |
| 4337 | typedef typename _Expr::value_type value_type; |
| 4338 | typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4339 | return __val_expr<_Op>(_Op(logical_or<value_type>(), |
| 4340 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4341 | } |
| 4342 | |
| 4343 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4344 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4345 | typename enable_if |
| 4346 | < |
| 4347 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4348 | __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4349 | >::type |
| 4350 | operator==(const _Expr1& __x, const _Expr2& __y) |
| 4351 | { |
| 4352 | typedef typename _Expr1::value_type value_type; |
| 4353 | typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op; |
| 4354 | return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y)); |
| 4355 | } |
| 4356 | |
| 4357 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4358 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4359 | typename enable_if |
| 4360 | < |
| 4361 | __is_val_expr<_Expr>::value, |
| 4362 | __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, |
| 4363 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4364 | >::type |
| 4365 | operator==(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4366 | { |
| 4367 | typedef typename _Expr::value_type value_type; |
| 4368 | typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4369 | return __val_expr<_Op>(_Op(equal_to<value_type>(), |
| 4370 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4371 | } |
| 4372 | |
| 4373 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4374 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4375 | typename enable_if |
| 4376 | < |
| 4377 | __is_val_expr<_Expr>::value, |
| 4378 | __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, |
| 4379 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4380 | >::type |
| 4381 | operator==(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4382 | { |
| 4383 | typedef typename _Expr::value_type value_type; |
| 4384 | typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4385 | return __val_expr<_Op>(_Op(equal_to<value_type>(), |
| 4386 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4387 | } |
| 4388 | |
| 4389 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4390 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4391 | typename enable_if |
| 4392 | < |
| 4393 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4394 | __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4395 | >::type |
| 4396 | operator!=(const _Expr1& __x, const _Expr2& __y) |
| 4397 | { |
| 4398 | typedef typename _Expr1::value_type value_type; |
| 4399 | typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op; |
| 4400 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y)); |
| 4401 | } |
| 4402 | |
| 4403 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4404 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4405 | typename enable_if |
| 4406 | < |
| 4407 | __is_val_expr<_Expr>::value, |
| 4408 | __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, |
| 4409 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4410 | >::type |
| 4411 | operator!=(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4412 | { |
| 4413 | typedef typename _Expr::value_type value_type; |
| 4414 | typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4415 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), |
| 4416 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4417 | } |
| 4418 | |
| 4419 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4420 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4421 | typename enable_if |
| 4422 | < |
| 4423 | __is_val_expr<_Expr>::value, |
| 4424 | __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, |
| 4425 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4426 | >::type |
| 4427 | operator!=(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4428 | { |
| 4429 | typedef typename _Expr::value_type value_type; |
| 4430 | typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4431 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), |
| 4432 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4433 | } |
| 4434 | |
| 4435 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4436 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4437 | typename enable_if |
| 4438 | < |
| 4439 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4440 | __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4441 | >::type |
| 4442 | operator<(const _Expr1& __x, const _Expr2& __y) |
| 4443 | { |
| 4444 | typedef typename _Expr1::value_type value_type; |
| 4445 | typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op; |
| 4446 | return __val_expr<_Op>(_Op(less<value_type>(), __x, __y)); |
| 4447 | } |
| 4448 | |
| 4449 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4450 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4451 | typename enable_if |
| 4452 | < |
| 4453 | __is_val_expr<_Expr>::value, |
| 4454 | __val_expr<_BinaryOp<less<typename _Expr::value_type>, |
| 4455 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4456 | >::type |
| 4457 | operator<(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4458 | { |
| 4459 | typedef typename _Expr::value_type value_type; |
| 4460 | typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4461 | return __val_expr<_Op>(_Op(less<value_type>(), |
| 4462 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4463 | } |
| 4464 | |
| 4465 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4466 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4467 | typename enable_if |
| 4468 | < |
| 4469 | __is_val_expr<_Expr>::value, |
| 4470 | __val_expr<_BinaryOp<less<typename _Expr::value_type>, |
| 4471 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4472 | >::type |
| 4473 | operator<(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4474 | { |
| 4475 | typedef typename _Expr::value_type value_type; |
| 4476 | typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4477 | return __val_expr<_Op>(_Op(less<value_type>(), |
| 4478 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4479 | } |
| 4480 | |
| 4481 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4482 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4483 | typename enable_if |
| 4484 | < |
| 4485 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4486 | __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4487 | >::type |
| 4488 | operator>(const _Expr1& __x, const _Expr2& __y) |
| 4489 | { |
| 4490 | typedef typename _Expr1::value_type value_type; |
| 4491 | typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op; |
| 4492 | return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y)); |
| 4493 | } |
| 4494 | |
| 4495 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4496 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4497 | typename enable_if |
| 4498 | < |
| 4499 | __is_val_expr<_Expr>::value, |
| 4500 | __val_expr<_BinaryOp<greater<typename _Expr::value_type>, |
| 4501 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4502 | >::type |
| 4503 | operator>(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4504 | { |
| 4505 | typedef typename _Expr::value_type value_type; |
| 4506 | typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4507 | return __val_expr<_Op>(_Op(greater<value_type>(), |
| 4508 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4509 | } |
| 4510 | |
| 4511 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4512 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4513 | typename enable_if |
| 4514 | < |
| 4515 | __is_val_expr<_Expr>::value, |
| 4516 | __val_expr<_BinaryOp<greater<typename _Expr::value_type>, |
| 4517 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4518 | >::type |
| 4519 | operator>(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4520 | { |
| 4521 | typedef typename _Expr::value_type value_type; |
| 4522 | typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4523 | return __val_expr<_Op>(_Op(greater<value_type>(), |
| 4524 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4525 | } |
| 4526 | |
| 4527 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4528 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4529 | typename enable_if |
| 4530 | < |
| 4531 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4532 | __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4533 | >::type |
| 4534 | operator<=(const _Expr1& __x, const _Expr2& __y) |
| 4535 | { |
| 4536 | typedef typename _Expr1::value_type value_type; |
| 4537 | typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op; |
| 4538 | return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y)); |
| 4539 | } |
| 4540 | |
| 4541 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4542 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4543 | typename enable_if |
| 4544 | < |
| 4545 | __is_val_expr<_Expr>::value, |
| 4546 | __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, |
| 4547 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4548 | >::type |
| 4549 | operator<=(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4550 | { |
| 4551 | typedef typename _Expr::value_type value_type; |
| 4552 | typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4553 | return __val_expr<_Op>(_Op(less_equal<value_type>(), |
| 4554 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4555 | } |
| 4556 | |
| 4557 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4558 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4559 | typename enable_if |
| 4560 | < |
| 4561 | __is_val_expr<_Expr>::value, |
| 4562 | __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, |
| 4563 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4564 | >::type |
| 4565 | operator<=(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4566 | { |
| 4567 | typedef typename _Expr::value_type value_type; |
| 4568 | typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4569 | return __val_expr<_Op>(_Op(less_equal<value_type>(), |
| 4570 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4571 | } |
| 4572 | |
| 4573 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4574 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4575 | typename enable_if |
| 4576 | < |
| 4577 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4578 | __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4579 | >::type |
| 4580 | operator>=(const _Expr1& __x, const _Expr2& __y) |
| 4581 | { |
| 4582 | typedef typename _Expr1::value_type value_type; |
| 4583 | typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op; |
| 4584 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y)); |
| 4585 | } |
| 4586 | |
| 4587 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4588 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4589 | typename enable_if |
| 4590 | < |
| 4591 | __is_val_expr<_Expr>::value, |
| 4592 | __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, |
| 4593 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4594 | >::type |
| 4595 | operator>=(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4596 | { |
| 4597 | typedef typename _Expr::value_type value_type; |
| 4598 | typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4599 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), |
| 4600 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4601 | } |
| 4602 | |
| 4603 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4604 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4605 | typename enable_if |
| 4606 | < |
| 4607 | __is_val_expr<_Expr>::value, |
| 4608 | __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, |
| 4609 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4610 | >::type |
| 4611 | operator>=(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4612 | { |
| 4613 | typedef typename _Expr::value_type value_type; |
| 4614 | typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4615 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), |
| 4616 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4617 | } |
| 4618 | |
| 4619 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4620 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4621 | typename enable_if |
| 4622 | < |
| 4623 | __is_val_expr<_Expr>::value, |
| 4624 | __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> > |
| 4625 | >::type |
| 4626 | abs(const _Expr& __x) |
| 4627 | { |
| 4628 | typedef typename _Expr::value_type value_type; |
| 4629 | typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op; |
| 4630 | return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x)); |
| 4631 | } |
| 4632 | |
| 4633 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4634 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4635 | typename enable_if |
| 4636 | < |
| 4637 | __is_val_expr<_Expr>::value, |
| 4638 | __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> > |
| 4639 | >::type |
| 4640 | acos(const _Expr& __x) |
| 4641 | { |
| 4642 | typedef typename _Expr::value_type value_type; |
| 4643 | typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op; |
| 4644 | return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x)); |
| 4645 | } |
| 4646 | |
| 4647 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4648 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4649 | typename enable_if |
| 4650 | < |
| 4651 | __is_val_expr<_Expr>::value, |
| 4652 | __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> > |
| 4653 | >::type |
| 4654 | asin(const _Expr& __x) |
| 4655 | { |
| 4656 | typedef typename _Expr::value_type value_type; |
| 4657 | typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op; |
| 4658 | return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x)); |
| 4659 | } |
| 4660 | |
| 4661 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4662 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4663 | typename enable_if |
| 4664 | < |
| 4665 | __is_val_expr<_Expr>::value, |
| 4666 | __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> > |
| 4667 | >::type |
| 4668 | atan(const _Expr& __x) |
| 4669 | { |
| 4670 | typedef typename _Expr::value_type value_type; |
| 4671 | typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op; |
| 4672 | return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x)); |
| 4673 | } |
| 4674 | |
| 4675 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4676 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4677 | typename enable_if |
| 4678 | < |
| 4679 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4680 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4681 | >::type |
| 4682 | atan2(const _Expr1& __x, const _Expr2& __y) |
| 4683 | { |
| 4684 | typedef typename _Expr1::value_type value_type; |
| 4685 | typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op; |
| 4686 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y)); |
| 4687 | } |
| 4688 | |
| 4689 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4690 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4691 | typename enable_if |
| 4692 | < |
| 4693 | __is_val_expr<_Expr>::value, |
| 4694 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, |
| 4695 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4696 | >::type |
| 4697 | atan2(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4698 | { |
| 4699 | typedef typename _Expr::value_type value_type; |
| 4700 | typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4701 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), |
| 4702 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4703 | } |
| 4704 | |
| 4705 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4706 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4707 | typename enable_if |
| 4708 | < |
| 4709 | __is_val_expr<_Expr>::value, |
| 4710 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, |
| 4711 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4712 | >::type |
| 4713 | atan2(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4714 | { |
| 4715 | typedef typename _Expr::value_type value_type; |
| 4716 | typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4717 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), |
| 4718 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4719 | } |
| 4720 | |
| 4721 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4722 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4723 | typename enable_if |
| 4724 | < |
| 4725 | __is_val_expr<_Expr>::value, |
| 4726 | __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> > |
| 4727 | >::type |
| 4728 | cos(const _Expr& __x) |
| 4729 | { |
| 4730 | typedef typename _Expr::value_type value_type; |
| 4731 | typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op; |
| 4732 | return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x)); |
| 4733 | } |
| 4734 | |
| 4735 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4736 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4737 | typename enable_if |
| 4738 | < |
| 4739 | __is_val_expr<_Expr>::value, |
| 4740 | __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> > |
| 4741 | >::type |
| 4742 | cosh(const _Expr& __x) |
| 4743 | { |
| 4744 | typedef typename _Expr::value_type value_type; |
| 4745 | typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op; |
| 4746 | return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x)); |
| 4747 | } |
| 4748 | |
| 4749 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4750 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4751 | typename enable_if |
| 4752 | < |
| 4753 | __is_val_expr<_Expr>::value, |
| 4754 | __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> > |
| 4755 | >::type |
| 4756 | exp(const _Expr& __x) |
| 4757 | { |
| 4758 | typedef typename _Expr::value_type value_type; |
| 4759 | typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op; |
| 4760 | return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x)); |
| 4761 | } |
| 4762 | |
| 4763 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4764 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4765 | typename enable_if |
| 4766 | < |
| 4767 | __is_val_expr<_Expr>::value, |
| 4768 | __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> > |
| 4769 | >::type |
| 4770 | log(const _Expr& __x) |
| 4771 | { |
| 4772 | typedef typename _Expr::value_type value_type; |
| 4773 | typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op; |
| 4774 | return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x)); |
| 4775 | } |
| 4776 | |
| 4777 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4778 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4779 | typename enable_if |
| 4780 | < |
| 4781 | __is_val_expr<_Expr>::value, |
| 4782 | __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> > |
| 4783 | >::type |
| 4784 | log10(const _Expr& __x) |
| 4785 | { |
| 4786 | typedef typename _Expr::value_type value_type; |
| 4787 | typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op; |
| 4788 | return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x)); |
| 4789 | } |
| 4790 | |
| 4791 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4792 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4793 | typename enable_if |
| 4794 | < |
| 4795 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4796 | __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4797 | >::type |
| 4798 | pow(const _Expr1& __x, const _Expr2& __y) |
| 4799 | { |
| 4800 | typedef typename _Expr1::value_type value_type; |
| 4801 | typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op; |
| 4802 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y)); |
| 4803 | } |
| 4804 | |
| 4805 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4806 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4807 | typename enable_if |
| 4808 | < |
| 4809 | __is_val_expr<_Expr>::value, |
| 4810 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, |
| 4811 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4812 | >::type |
| 4813 | pow(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4814 | { |
| 4815 | typedef typename _Expr::value_type value_type; |
| 4816 | typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4817 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), |
| 4818 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4819 | } |
| 4820 | |
| 4821 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4822 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4823 | typename enable_if |
| 4824 | < |
| 4825 | __is_val_expr<_Expr>::value, |
| 4826 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, |
| 4827 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4828 | >::type |
| 4829 | pow(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4830 | { |
| 4831 | typedef typename _Expr::value_type value_type; |
| 4832 | typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4833 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), |
| 4834 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4835 | } |
| 4836 | |
| 4837 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4838 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4839 | typename enable_if |
| 4840 | < |
| 4841 | __is_val_expr<_Expr>::value, |
| 4842 | __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> > |
| 4843 | >::type |
| 4844 | sin(const _Expr& __x) |
| 4845 | { |
| 4846 | typedef typename _Expr::value_type value_type; |
| 4847 | typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op; |
| 4848 | return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x)); |
| 4849 | } |
| 4850 | |
| 4851 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4852 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4853 | typename enable_if |
| 4854 | < |
| 4855 | __is_val_expr<_Expr>::value, |
| 4856 | __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> > |
| 4857 | >::type |
| 4858 | sinh(const _Expr& __x) |
| 4859 | { |
| 4860 | typedef typename _Expr::value_type value_type; |
| 4861 | typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op; |
| 4862 | return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x)); |
| 4863 | } |
| 4864 | |
| 4865 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4866 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4867 | typename enable_if |
| 4868 | < |
| 4869 | __is_val_expr<_Expr>::value, |
| 4870 | __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> > |
| 4871 | >::type |
| 4872 | sqrt(const _Expr& __x) |
| 4873 | { |
| 4874 | typedef typename _Expr::value_type value_type; |
| 4875 | typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op; |
| 4876 | return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x)); |
| 4877 | } |
| 4878 | |
| 4879 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4880 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4881 | typename enable_if |
| 4882 | < |
| 4883 | __is_val_expr<_Expr>::value, |
| 4884 | __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> > |
| 4885 | >::type |
| 4886 | tan(const _Expr& __x) |
| 4887 | { |
| 4888 | typedef typename _Expr::value_type value_type; |
| 4889 | typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op; |
| 4890 | return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x)); |
| 4891 | } |
| 4892 | |
| 4893 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4894 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4895 | typename enable_if |
| 4896 | < |
| 4897 | __is_val_expr<_Expr>::value, |
| 4898 | __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> > |
| 4899 | >::type |
| 4900 | tanh(const _Expr& __x) |
| 4901 | { |
| 4902 | typedef typename _Expr::value_type value_type; |
| 4903 | typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op; |
| 4904 | return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x)); |
| 4905 | } |
| 4906 | |
| 4907 | template <class _Tp> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4908 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4909 | _Tp* |
| 4910 | begin(valarray<_Tp>& __v) |
| 4911 | { |
| 4912 | return __v.__begin_; |
| 4913 | } |
| 4914 | |
| 4915 | template <class _Tp> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4916 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4917 | const _Tp* |
| 4918 | begin(const valarray<_Tp>& __v) |
| 4919 | { |
| 4920 | return __v.__begin_; |
| 4921 | } |
| 4922 | |
| 4923 | template <class _Tp> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4924 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4925 | _Tp* |
| 4926 | end(valarray<_Tp>& __v) |
| 4927 | { |
| 4928 | return __v.__end_; |
| 4929 | } |
| 4930 | |
| 4931 | template <class _Tp> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4932 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4933 | const _Tp* |
| 4934 | end(const valarray<_Tp>& __v) |
| 4935 | { |
| 4936 | return __v.__end_; |
| 4937 | } |
| 4938 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4939 | _LIBCPP_END_NAMESPACE_STD |
| 4940 | |
Eric Fiselier | f4433a3 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 4941 | _LIBCPP_POP_MACROS |
| 4942 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 4943 | #endif // _LIBCPP_VALARRAY |