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