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