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