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