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