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