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