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