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