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