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