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