| 1 |
// -*- C++ -*- |
| 2 |
//===----------------------------------------------------------------------===// |
| 3 |
// |
| 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 |
| 7 |
// |
| 8 |
//===----------------------------------------------------------------------===// |
| 9 |
|
| 10 |
#ifndef _LIBCPP___CXX03_VALARRAY |
| 11 |
#define _LIBCPP___CXX03_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); |
| 31 |
valarray(valarray&& v) noexcept; |
| 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); |
| 41 |
valarray& operator=(valarray&& v) noexcept; |
| 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: |
| 93 |
void swap(valarray& v) noexcept; |
| 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 |
template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>; |
| 109 |
|
| 110 |
class slice |
| 111 |
{ |
| 112 |
public: |
| 113 |
slice(); |
| 114 |
slice(size_t start, size_t size, size_t stride); |
| 115 |
|
| 116 |
size_t start() const; |
| 117 |
size_t size() const; |
| 118 |
size_t stride() const; |
| 119 |
|
| 120 |
friend bool operator==(const slice& x, const slice& y); // since C++20 |
| 121 |
}; |
| 122 |
|
| 123 |
template <class T> |
| 124 |
class slice_array |
| 125 |
{ |
| 126 |
public: |
| 127 |
typedef T value_type; |
| 128 |
|
| 129 |
const slice_array& operator=(const slice_array& sa) const; |
| 130 |
void operator= (const valarray<value_type>& v) const; |
| 131 |
void operator*= (const valarray<value_type>& v) const; |
| 132 |
void operator/= (const valarray<value_type>& v) const; |
| 133 |
void operator%= (const valarray<value_type>& v) const; |
| 134 |
void operator+= (const valarray<value_type>& v) const; |
| 135 |
void operator-= (const valarray<value_type>& v) const; |
| 136 |
void operator^= (const valarray<value_type>& v) const; |
| 137 |
void operator&= (const valarray<value_type>& v) const; |
| 138 |
void operator|= (const valarray<value_type>& v) const; |
| 139 |
void operator<<=(const valarray<value_type>& v) const; |
| 140 |
void operator>>=(const valarray<value_type>& v) const; |
| 141 |
|
| 142 |
void operator=(const value_type& x) const; |
| 143 |
void operator=(const valarray<T>& val_arr) const; |
| 144 |
|
| 145 |
slice_array() = delete; |
| 146 |
}; |
| 147 |
|
| 148 |
class gslice |
| 149 |
{ |
| 150 |
public: |
| 151 |
gslice(); |
| 152 |
gslice(size_t start, const valarray<size_t>& size, |
| 153 |
const valarray<size_t>& stride); |
| 154 |
|
| 155 |
size_t start() const; |
| 156 |
valarray<size_t> size() const; |
| 157 |
valarray<size_t> stride() const; |
| 158 |
}; |
| 159 |
|
| 160 |
template <class T> |
| 161 |
class gslice_array |
| 162 |
{ |
| 163 |
public: |
| 164 |
typedef T value_type; |
| 165 |
|
| 166 |
void operator= (const valarray<value_type>& v) const; |
| 167 |
void operator*= (const valarray<value_type>& v) const; |
| 168 |
void operator/= (const valarray<value_type>& v) const; |
| 169 |
void operator%= (const valarray<value_type>& v) const; |
| 170 |
void operator+= (const valarray<value_type>& v) const; |
| 171 |
void operator-= (const valarray<value_type>& v) const; |
| 172 |
void operator^= (const valarray<value_type>& v) const; |
| 173 |
void operator&= (const valarray<value_type>& v) const; |
| 174 |
void operator|= (const valarray<value_type>& v) const; |
| 175 |
void operator<<=(const valarray<value_type>& v) const; |
| 176 |
void operator>>=(const valarray<value_type>& v) const; |
| 177 |
|
| 178 |
gslice_array(const gslice_array& ga); |
| 179 |
~gslice_array(); |
| 180 |
const gslice_array& operator=(const gslice_array& ga) const; |
| 181 |
void operator=(const value_type& x) const; |
| 182 |
|
| 183 |
gslice_array() = delete; |
| 184 |
}; |
| 185 |
|
| 186 |
template <class T> |
| 187 |
class mask_array |
| 188 |
{ |
| 189 |
public: |
| 190 |
typedef T value_type; |
| 191 |
|
| 192 |
void operator= (const valarray<value_type>& v) const; |
| 193 |
void operator*= (const valarray<value_type>& v) const; |
| 194 |
void operator/= (const valarray<value_type>& v) const; |
| 195 |
void operator%= (const valarray<value_type>& v) const; |
| 196 |
void operator+= (const valarray<value_type>& v) const; |
| 197 |
void operator-= (const valarray<value_type>& v) const; |
| 198 |
void operator^= (const valarray<value_type>& v) const; |
| 199 |
void operator&= (const valarray<value_type>& v) const; |
| 200 |
void operator|= (const valarray<value_type>& v) const; |
| 201 |
void operator<<=(const valarray<value_type>& v) const; |
| 202 |
void operator>>=(const valarray<value_type>& v) const; |
| 203 |
|
| 204 |
mask_array(const mask_array& ma); |
| 205 |
~mask_array(); |
| 206 |
const mask_array& operator=(const mask_array& ma) const; |
| 207 |
void operator=(const value_type& x) const; |
| 208 |
|
| 209 |
mask_array() = delete; |
| 210 |
}; |
| 211 |
|
| 212 |
template <class T> |
| 213 |
class indirect_array |
| 214 |
{ |
| 215 |
public: |
| 216 |
typedef T value_type; |
| 217 |
|
| 218 |
void operator= (const valarray<value_type>& v) const; |
| 219 |
void operator*= (const valarray<value_type>& v) const; |
| 220 |
void operator/= (const valarray<value_type>& v) const; |
| 221 |
void operator%= (const valarray<value_type>& v) const; |
| 222 |
void operator+= (const valarray<value_type>& v) const; |
| 223 |
void operator-= (const valarray<value_type>& v) const; |
| 224 |
void operator^= (const valarray<value_type>& v) const; |
| 225 |
void operator&= (const valarray<value_type>& v) const; |
| 226 |
void operator|= (const valarray<value_type>& v) const; |
| 227 |
void operator<<=(const valarray<value_type>& v) const; |
| 228 |
void operator>>=(const valarray<value_type>& v) const; |
| 229 |
|
| 230 |
indirect_array(const indirect_array& ia); |
| 231 |
~indirect_array(); |
| 232 |
const indirect_array& operator=(const indirect_array& ia) const; |
| 233 |
void operator=(const value_type& x) const; |
| 234 |
|
| 235 |
indirect_array() = delete; |
| 236 |
}; |
| 237 |
|
| 238 |
template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept; |
| 239 |
|
| 240 |
template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y); |
| 241 |
template<class T> valarray<T> operator* (const valarray<T>& x, const T& y); |
| 242 |
template<class T> valarray<T> operator* (const T& x, const valarray<T>& y); |
| 243 |
|
| 244 |
template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y); |
| 245 |
template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y); |
| 246 |
template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y); |
| 247 |
|
| 248 |
template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y); |
| 249 |
template<class T> valarray<T> operator% (const valarray<T>& x, const T& y); |
| 250 |
template<class T> valarray<T> operator% (const T& x, const valarray<T>& y); |
| 251 |
|
| 252 |
template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y); |
| 253 |
template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y); |
| 254 |
template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y); |
| 255 |
|
| 256 |
template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y); |
| 257 |
template<class T> valarray<T> operator- (const valarray<T>& x, const T& y); |
| 258 |
template<class T> valarray<T> operator- (const T& x, const valarray<T>& y); |
| 259 |
|
| 260 |
template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y); |
| 261 |
template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y); |
| 262 |
template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y); |
| 263 |
|
| 264 |
template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y); |
| 265 |
template<class T> valarray<T> operator& (const valarray<T>& x, const T& y); |
| 266 |
template<class T> valarray<T> operator& (const T& x, const valarray<T>& y); |
| 267 |
|
| 268 |
template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y); |
| 269 |
template<class T> valarray<T> operator| (const valarray<T>& x, const T& y); |
| 270 |
template<class T> valarray<T> operator| (const T& x, const valarray<T>& y); |
| 271 |
|
| 272 |
template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y); |
| 273 |
template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y); |
| 274 |
template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y); |
| 275 |
|
| 276 |
template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y); |
| 277 |
template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y); |
| 278 |
template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y); |
| 279 |
|
| 280 |
template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y); |
| 281 |
template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y); |
| 282 |
template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y); |
| 283 |
|
| 284 |
template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y); |
| 285 |
template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y); |
| 286 |
template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y); |
| 287 |
|
| 288 |
template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y); |
| 289 |
template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y); |
| 290 |
template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y); |
| 291 |
|
| 292 |
template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y); |
| 293 |
template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y); |
| 294 |
template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y); |
| 295 |
|
| 296 |
template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y); |
| 297 |
template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y); |
| 298 |
template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y); |
| 299 |
|
| 300 |
template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y); |
| 301 |
template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y); |
| 302 |
template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y); |
| 303 |
|
| 304 |
template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y); |
| 305 |
template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y); |
| 306 |
template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y); |
| 307 |
|
| 308 |
template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y); |
| 309 |
template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y); |
| 310 |
template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y); |
| 311 |
|
| 312 |
template<class T> valarray<T> abs (const valarray<T>& x); |
| 313 |
template<class T> valarray<T> acos (const valarray<T>& x); |
| 314 |
template<class T> valarray<T> asin (const valarray<T>& x); |
| 315 |
template<class T> valarray<T> atan (const valarray<T>& x); |
| 316 |
|
| 317 |
template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y); |
| 318 |
template<class T> valarray<T> atan2(const valarray<T>& x, const T& y); |
| 319 |
template<class T> valarray<T> atan2(const T& x, const valarray<T>& y); |
| 320 |
|
| 321 |
template<class T> valarray<T> cos (const valarray<T>& x); |
| 322 |
template<class T> valarray<T> cosh (const valarray<T>& x); |
| 323 |
template<class T> valarray<T> exp (const valarray<T>& x); |
| 324 |
template<class T> valarray<T> log (const valarray<T>& x); |
| 325 |
template<class T> valarray<T> log10(const valarray<T>& x); |
| 326 |
|
| 327 |
template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y); |
| 328 |
template<class T> valarray<T> pow(const valarray<T>& x, const T& y); |
| 329 |
template<class T> valarray<T> pow(const T& x, const valarray<T>& y); |
| 330 |
|
| 331 |
template<class T> valarray<T> sin (const valarray<T>& x); |
| 332 |
template<class T> valarray<T> sinh (const valarray<T>& x); |
| 333 |
template<class T> valarray<T> sqrt (const valarray<T>& x); |
| 334 |
template<class T> valarray<T> tan (const valarray<T>& x); |
| 335 |
template<class T> valarray<T> tanh (const valarray<T>& x); |
| 336 |
|
| 337 |
template <class T> unspecified1 begin(valarray<T>& v); |
| 338 |
template <class T> unspecified2 begin(const valarray<T>& v); |
| 339 |
template <class T> unspecified1 end(valarray<T>& v); |
| 340 |
template <class T> unspecified2 end(const valarray<T>& v); |
| 341 |
|
| 342 |
} // std |
| 343 |
|
| 344 |
*/ |
| 345 |
|
| 346 |
#include <__cxx03/__algorithm/copy.h> |
| 347 |
#include <__cxx03/__algorithm/count.h> |
| 348 |
#include <__cxx03/__algorithm/fill.h> |
| 349 |
#include <__cxx03/__algorithm/max_element.h> |
| 350 |
#include <__cxx03/__algorithm/min.h> |
| 351 |
#include <__cxx03/__algorithm/min_element.h> |
| 352 |
#include <__cxx03/__algorithm/unwrap_iter.h> |
| 353 |
#include <__cxx03/__assert> |
| 354 |
#include <__cxx03/__config> |
| 355 |
#include <__cxx03/__functional/operations.h> |
| 356 |
#include <__cxx03/__memory/addressof.h> |
| 357 |
#include <__cxx03/__memory/allocator.h> |
| 358 |
#include <__cxx03/__memory/uninitialized_algorithms.h> |
| 359 |
#include <__cxx03/__type_traits/decay.h> |
| 360 |
#include <__cxx03/__type_traits/remove_reference.h> |
| 361 |
#include <__cxx03/__utility/move.h> |
| 362 |
#include <__cxx03/__utility/swap.h> |
| 363 |
#include <__cxx03/cmath> |
| 364 |
#include <__cxx03/cstddef> |
| 365 |
#include <__cxx03/new> |
| 366 |
#include <__cxx03/version> |
| 367 |
|
| 368 |
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 369 |
# pragma GCC system_header |
| 370 |
#endif |
| 371 |
|
| 372 |
_LIBCPP_PUSH_MACROS |
| 373 |
#include <__cxx03/__undef_macros> |
| 374 |
|
| 375 |
_LIBCPP_BEGIN_NAMESPACE_STD |
| 376 |
|
| 377 |
template <class _Tp> |
| 378 |
class _LIBCPP_TEMPLATE_VIS valarray; |
| 379 |
|
| 380 |
class _LIBCPP_TEMPLATE_VIS slice { |
| 381 |
size_t __start_; |
| 382 |
size_t __size_; |
| 383 |
size_t __stride_; |
| 384 |
|
| 385 |
public: |
| 386 |
_LIBCPP_HIDE_FROM_ABI slice() : __start_(0), __size_(0), __stride_(0) {} |
| 387 |
|
| 388 |
_LIBCPP_HIDE_FROM_ABI slice(size_t __start, size_t __size, size_t __stride) |
| 389 |
: __start_(__start), __size_(__size), __stride_(__stride) {} |
| 390 |
|
| 391 |
_LIBCPP_HIDE_FROM_ABI size_t start() const { return __start_; } |
| 392 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } |
| 393 |
_LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; } |
| 394 |
}; |
| 395 |
|
| 396 |
template <class _Tp> |
| 397 |
class _LIBCPP_TEMPLATE_VIS slice_array; |
| 398 |
class _LIBCPP_EXPORTED_FROM_ABI gslice; |
| 399 |
template <class _Tp> |
| 400 |
class _LIBCPP_TEMPLATE_VIS gslice_array; |
| 401 |
template <class _Tp> |
| 402 |
class _LIBCPP_TEMPLATE_VIS mask_array; |
| 403 |
template <class _Tp> |
| 404 |
class _LIBCPP_TEMPLATE_VIS indirect_array; |
| 405 |
|
| 406 |
template <class _Tp> |
| 407 |
_LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v); |
| 408 |
|
| 409 |
template <class _Tp> |
| 410 |
_LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v); |
| 411 |
|
| 412 |
template <class _Tp> |
| 413 |
_LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v); |
| 414 |
|
| 415 |
template <class _Tp> |
| 416 |
_LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v); |
| 417 |
|
| 418 |
template <class _Op, class _A0> |
| 419 |
struct _UnaryOp { |
| 420 |
typedef typename _Op::__result_type __result_type; |
| 421 |
using value_type = __decay_t<__result_type>; |
| 422 |
|
| 423 |
_Op __op_; |
| 424 |
_A0 __a0_; |
| 425 |
|
| 426 |
_LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {} |
| 427 |
|
| 428 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); } |
| 429 |
|
| 430 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
| 431 |
}; |
| 432 |
|
| 433 |
template <class _Op, class _A0, class _A1> |
| 434 |
struct _BinaryOp { |
| 435 |
typedef typename _Op::__result_type __result_type; |
| 436 |
using value_type = __decay_t<__result_type>; |
| 437 |
|
| 438 |
_Op __op_; |
| 439 |
_A0 __a0_; |
| 440 |
_A1 __a1_; |
| 441 |
|
| 442 |
_LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1) |
| 443 |
: __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 444 |
|
| 445 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); } |
| 446 |
|
| 447 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
| 448 |
}; |
| 449 |
|
| 450 |
template <class _Tp> |
| 451 |
class __scalar_expr { |
| 452 |
public: |
| 453 |
typedef _Tp value_type; |
| 454 |
typedef const _Tp& __result_type; |
| 455 |
|
| 456 |
private: |
| 457 |
const value_type& __t_; |
| 458 |
size_t __s_; |
| 459 |
|
| 460 |
public: |
| 461 |
_LIBCPP_HIDE_FROM_ABI explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {} |
| 462 |
|
| 463 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t) const { return __t_; } |
| 464 |
|
| 465 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __s_; } |
| 466 |
}; |
| 467 |
|
| 468 |
template <class _Tp> |
| 469 |
struct __unary_plus { |
| 470 |
typedef _Tp __result_type; |
| 471 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return +__x; } |
| 472 |
}; |
| 473 |
|
| 474 |
template <class _Tp> |
| 475 |
struct __bit_not { |
| 476 |
typedef _Tp __result_type; |
| 477 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; } |
| 478 |
}; |
| 479 |
|
| 480 |
template <class _Tp> |
| 481 |
struct __bit_shift_left { |
| 482 |
typedef _Tp __result_type; |
| 483 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x << __y; } |
| 484 |
}; |
| 485 |
|
| 486 |
template <class _Tp> |
| 487 |
struct __bit_shift_right { |
| 488 |
typedef _Tp __result_type; |
| 489 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x >> __y; } |
| 490 |
}; |
| 491 |
|
| 492 |
template <class _Tp, class _Fp> |
| 493 |
struct __apply_expr { |
| 494 |
private: |
| 495 |
_Fp __f_; |
| 496 |
|
| 497 |
public: |
| 498 |
typedef _Tp __result_type; |
| 499 |
|
| 500 |
_LIBCPP_HIDE_FROM_ABI explicit __apply_expr(_Fp __f) : __f_(__f) {} |
| 501 |
|
| 502 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return __f_(__x); } |
| 503 |
}; |
| 504 |
|
| 505 |
template <class _Tp> |
| 506 |
struct __abs_expr { |
| 507 |
typedef _Tp __result_type; |
| 508 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::abs(__x); } |
| 509 |
}; |
| 510 |
|
| 511 |
template <class _Tp> |
| 512 |
struct __acos_expr { |
| 513 |
typedef _Tp __result_type; |
| 514 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::acos(__x); } |
| 515 |
}; |
| 516 |
|
| 517 |
template <class _Tp> |
| 518 |
struct __asin_expr { |
| 519 |
typedef _Tp __result_type; |
| 520 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::asin(__x); } |
| 521 |
}; |
| 522 |
|
| 523 |
template <class _Tp> |
| 524 |
struct __atan_expr { |
| 525 |
typedef _Tp __result_type; |
| 526 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::atan(__x); } |
| 527 |
}; |
| 528 |
|
| 529 |
template <class _Tp> |
| 530 |
struct __atan2_expr { |
| 531 |
typedef _Tp __result_type; |
| 532 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::atan2(__x, __y); } |
| 533 |
}; |
| 534 |
|
| 535 |
template <class _Tp> |
| 536 |
struct __cos_expr { |
| 537 |
typedef _Tp __result_type; |
| 538 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cos(__x); } |
| 539 |
}; |
| 540 |
|
| 541 |
template <class _Tp> |
| 542 |
struct __cosh_expr { |
| 543 |
typedef _Tp __result_type; |
| 544 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cosh(__x); } |
| 545 |
}; |
| 546 |
|
| 547 |
template <class _Tp> |
| 548 |
struct __exp_expr { |
| 549 |
typedef _Tp __result_type; |
| 550 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::exp(__x); } |
| 551 |
}; |
| 552 |
|
| 553 |
template <class _Tp> |
| 554 |
struct __log_expr { |
| 555 |
typedef _Tp __result_type; |
| 556 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log(__x); } |
| 557 |
}; |
| 558 |
|
| 559 |
template <class _Tp> |
| 560 |
struct __log10_expr { |
| 561 |
typedef _Tp __result_type; |
| 562 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log10(__x); } |
| 563 |
}; |
| 564 |
|
| 565 |
template <class _Tp> |
| 566 |
struct __pow_expr { |
| 567 |
typedef _Tp __result_type; |
| 568 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::pow(__x, __y); } |
| 569 |
}; |
| 570 |
|
| 571 |
template <class _Tp> |
| 572 |
struct __sin_expr { |
| 573 |
typedef _Tp __result_type; |
| 574 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sin(__x); } |
| 575 |
}; |
| 576 |
|
| 577 |
template <class _Tp> |
| 578 |
struct __sinh_expr { |
| 579 |
typedef _Tp __result_type; |
| 580 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sinh(__x); } |
| 581 |
}; |
| 582 |
|
| 583 |
template <class _Tp> |
| 584 |
struct __sqrt_expr { |
| 585 |
typedef _Tp __result_type; |
| 586 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sqrt(__x); } |
| 587 |
}; |
| 588 |
|
| 589 |
template <class _Tp> |
| 590 |
struct __tan_expr { |
| 591 |
typedef _Tp __result_type; |
| 592 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tan(__x); } |
| 593 |
}; |
| 594 |
|
| 595 |
template <class _Tp> |
| 596 |
struct __tanh_expr { |
| 597 |
typedef _Tp __result_type; |
| 598 |
_LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tanh(__x); } |
| 599 |
}; |
| 600 |
|
| 601 |
template <class _ValExpr> |
| 602 |
class __slice_expr { |
| 603 |
typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
| 604 |
|
| 605 |
public: |
| 606 |
typedef typename _RmExpr::value_type value_type; |
| 607 |
typedef value_type __result_type; |
| 608 |
|
| 609 |
private: |
| 610 |
_ValExpr __expr_; |
| 611 |
size_t __start_; |
| 612 |
size_t __size_; |
| 613 |
size_t __stride_; |
| 614 |
|
| 615 |
_LIBCPP_HIDE_FROM_ABI __slice_expr(const slice& __sl, const _RmExpr& __e) |
| 616 |
: __expr_(__e), __start_(__sl.start()), __size_(__sl.size()), __stride_(__sl.stride()) {} |
| 617 |
|
| 618 |
public: |
| 619 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__start_ + __i * __stride_]; } |
| 620 |
|
| 621 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } |
| 622 |
|
| 623 |
template <class> |
| 624 |
friend class __val_expr; |
| 625 |
template <class> |
| 626 |
friend class _LIBCPP_TEMPLATE_VIS valarray; |
| 627 |
}; |
| 628 |
|
| 629 |
template <class _ValExpr> |
| 630 |
class __mask_expr; |
| 631 |
|
| 632 |
template <class _ValExpr> |
| 633 |
class __indirect_expr; |
| 634 |
|
| 635 |
template <class _ValExpr> |
| 636 |
class __shift_expr { |
| 637 |
typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
| 638 |
|
| 639 |
public: |
| 640 |
typedef typename _RmExpr::value_type value_type; |
| 641 |
typedef value_type __result_type; |
| 642 |
|
| 643 |
private: |
| 644 |
_ValExpr __expr_; |
| 645 |
size_t __size_; |
| 646 |
ptrdiff_t __ul_; |
| 647 |
ptrdiff_t __sn_; |
| 648 |
ptrdiff_t __n_; |
| 649 |
static const ptrdiff_t _Np = static_cast<ptrdiff_t>(sizeof(ptrdiff_t) * __CHAR_BIT__ - 1); |
| 650 |
|
| 651 |
_LIBCPP_HIDE_FROM_ABI __shift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()), __n_(__n) { |
| 652 |
ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np); |
| 653 |
__sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np); |
| 654 |
__ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n); |
| 655 |
} |
| 656 |
|
| 657 |
public: |
| 658 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __j) const { |
| 659 |
ptrdiff_t __i = static_cast<ptrdiff_t>(__j); |
| 660 |
ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np; |
| 661 |
return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m); |
| 662 |
} |
| 663 |
|
| 664 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } |
| 665 |
|
| 666 |
template <class> |
| 667 |
friend class __val_expr; |
| 668 |
}; |
| 669 |
|
| 670 |
template <class _ValExpr> |
| 671 |
class __cshift_expr { |
| 672 |
typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
| 673 |
|
| 674 |
public: |
| 675 |
typedef typename _RmExpr::value_type value_type; |
| 676 |
typedef value_type __result_type; |
| 677 |
|
| 678 |
private: |
| 679 |
_ValExpr __expr_; |
| 680 |
size_t __size_; |
| 681 |
size_t __m_; |
| 682 |
size_t __o1_; |
| 683 |
size_t __o2_; |
| 684 |
|
| 685 |
_LIBCPP_HIDE_FROM_ABI __cshift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()) { |
| 686 |
__n %= static_cast<int>(__size_); |
| 687 |
if (__n >= 0) { |
| 688 |
__m_ = __size_ - __n; |
| 689 |
__o1_ = __n; |
| 690 |
__o2_ = __n - __size_; |
| 691 |
} else { |
| 692 |
__m_ = -__n; |
| 693 |
__o1_ = __n + __size_; |
| 694 |
__o2_ = __n; |
| 695 |
} |
| 696 |
} |
| 697 |
|
| 698 |
public: |
| 699 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { |
| 700 |
if (__i < __m_) |
| 701 |
return __expr_[__i + __o1_]; |
| 702 |
return __expr_[__i + __o2_]; |
| 703 |
} |
| 704 |
|
| 705 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } |
| 706 |
|
| 707 |
template <class> |
| 708 |
friend class __val_expr; |
| 709 |
}; |
| 710 |
|
| 711 |
template <class _ValExpr> |
| 712 |
class __val_expr; |
| 713 |
|
| 714 |
template <class _ValExpr> |
| 715 |
struct __is_val_expr : false_type {}; |
| 716 |
|
| 717 |
template <class _ValExpr> |
| 718 |
struct __is_val_expr<__val_expr<_ValExpr> > : true_type {}; |
| 719 |
|
| 720 |
template <class _Tp> |
| 721 |
struct __is_val_expr<valarray<_Tp> > : true_type {}; |
| 722 |
|
| 723 |
template <class _Tp> |
| 724 |
struct __is_val_expr<slice_array<_Tp> > : true_type {}; |
| 725 |
|
| 726 |
template <class _Tp> |
| 727 |
struct __is_val_expr<gslice_array<_Tp> > : true_type {}; |
| 728 |
|
| 729 |
template <class _Tp> |
| 730 |
struct __is_val_expr<mask_array<_Tp> > : true_type {}; |
| 731 |
|
| 732 |
template <class _Tp> |
| 733 |
struct __is_val_expr<indirect_array<_Tp> > : true_type {}; |
| 734 |
|
| 735 |
// The functions using a __val_expr access the elements by their index. |
| 736 |
// valarray and the libc++ lazy proxies have an operator[]. The |
| 737 |
// Standard proxy array's don't have this operator, instead they have a |
| 738 |
// implementation specific accessor |
| 739 |
// __get(size_t) |
| 740 |
// |
| 741 |
// The functions use the non-member function |
| 742 |
// __get(__val_expr, size_t) |
| 743 |
// |
| 744 |
// If the __val_expr is a specialization of __val_expr_use_member_functions it |
| 745 |
// uses the __val_expr's member function |
| 746 |
// __get(size_t) |
| 747 |
// else it uses the __val_expr's member function |
| 748 |
// operator[](size_t) |
| 749 |
template <class _ValExpr> |
| 750 |
struct __val_expr_use_member_functions; |
| 751 |
|
| 752 |
template <class> |
| 753 |
struct __val_expr_use_member_functions : false_type {}; |
| 754 |
|
| 755 |
template <class _Tp> |
| 756 |
struct __val_expr_use_member_functions<slice_array<_Tp> > : true_type {}; |
| 757 |
|
| 758 |
template <class _Tp> |
| 759 |
struct __val_expr_use_member_functions<gslice_array<_Tp> > : true_type {}; |
| 760 |
|
| 761 |
template <class _Tp> |
| 762 |
struct __val_expr_use_member_functions<mask_array<_Tp> > : true_type {}; |
| 763 |
|
| 764 |
template <class _Tp> |
| 765 |
struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {}; |
| 766 |
|
| 767 |
template <class _Tp> |
| 768 |
class _LIBCPP_TEMPLATE_VIS valarray { |
| 769 |
public: |
| 770 |
typedef _Tp value_type; |
| 771 |
typedef _Tp __result_type; |
| 772 |
|
| 773 |
private: |
| 774 |
value_type* __begin_; |
| 775 |
value_type* __end_; |
| 776 |
|
| 777 |
public: |
| 778 |
// construct/destroy: |
| 779 |
_LIBCPP_HIDE_FROM_ABI valarray() : __begin_(nullptr), __end_(nullptr) {} |
| 780 |
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit valarray(size_t __n); |
| 781 |
_LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n); |
| 782 |
valarray(const value_type* __p, size_t __n); |
| 783 |
valarray(const valarray& __v); |
| 784 |
valarray(const slice_array<value_type>& __sa); |
| 785 |
valarray(const gslice_array<value_type>& __ga); |
| 786 |
valarray(const mask_array<value_type>& __ma); |
| 787 |
valarray(const indirect_array<value_type>& __ia); |
| 788 |
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 ~valarray(); |
| 789 |
|
| 790 |
// assignment: |
| 791 |
valarray& operator=(const valarray& __v); |
| 792 |
_LIBCPP_HIDE_FROM_ABI valarray& operator=(const value_type& __x); |
| 793 |
_LIBCPP_HIDE_FROM_ABI valarray& operator=(const slice_array<value_type>& __sa); |
| 794 |
_LIBCPP_HIDE_FROM_ABI valarray& operator=(const gslice_array<value_type>& __ga); |
| 795 |
_LIBCPP_HIDE_FROM_ABI valarray& operator=(const mask_array<value_type>& __ma); |
| 796 |
_LIBCPP_HIDE_FROM_ABI valarray& operator=(const indirect_array<value_type>& __ia); |
| 797 |
template <class _ValExpr> |
| 798 |
_LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v); |
| 799 |
|
| 800 |
// element access: |
| 801 |
_LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const { return __begin_[__i]; } |
| 802 |
|
| 803 |
_LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) { return __begin_[__i]; } |
| 804 |
|
| 805 |
// subset operations: |
| 806 |
_LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const; |
| 807 |
_LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s); |
| 808 |
_LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const; |
| 809 |
_LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs); |
| 810 |
_LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const; |
| 811 |
_LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb); |
| 812 |
_LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const; |
| 813 |
_LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs); |
| 814 |
|
| 815 |
// unary operators: |
| 816 |
_LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const; |
| 817 |
_LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const; |
| 818 |
_LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const; |
| 819 |
_LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const; |
| 820 |
|
| 821 |
// computed assignment: |
| 822 |
_LIBCPP_HIDE_FROM_ABI valarray& operator*=(const value_type& __x); |
| 823 |
_LIBCPP_HIDE_FROM_ABI valarray& operator/=(const value_type& __x); |
| 824 |
_LIBCPP_HIDE_FROM_ABI valarray& operator%=(const value_type& __x); |
| 825 |
_LIBCPP_HIDE_FROM_ABI valarray& operator+=(const value_type& __x); |
| 826 |
_LIBCPP_HIDE_FROM_ABI valarray& operator-=(const value_type& __x); |
| 827 |
_LIBCPP_HIDE_FROM_ABI valarray& operator^=(const value_type& __x); |
| 828 |
_LIBCPP_HIDE_FROM_ABI valarray& operator&=(const value_type& __x); |
| 829 |
_LIBCPP_HIDE_FROM_ABI valarray& operator|=(const value_type& __x); |
| 830 |
_LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const value_type& __x); |
| 831 |
_LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const value_type& __x); |
| 832 |
|
| 833 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 834 |
_LIBCPP_HIDE_FROM_ABI valarray& operator*=(const _Expr& __v); |
| 835 |
|
| 836 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 837 |
_LIBCPP_HIDE_FROM_ABI valarray& operator/=(const _Expr& __v); |
| 838 |
|
| 839 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 840 |
_LIBCPP_HIDE_FROM_ABI valarray& operator%=(const _Expr& __v); |
| 841 |
|
| 842 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 843 |
_LIBCPP_HIDE_FROM_ABI valarray& operator+=(const _Expr& __v); |
| 844 |
|
| 845 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 846 |
_LIBCPP_HIDE_FROM_ABI valarray& operator-=(const _Expr& __v); |
| 847 |
|
| 848 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 849 |
_LIBCPP_HIDE_FROM_ABI valarray& operator^=(const _Expr& __v); |
| 850 |
|
| 851 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 852 |
_LIBCPP_HIDE_FROM_ABI valarray& operator|=(const _Expr& __v); |
| 853 |
|
| 854 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 855 |
_LIBCPP_HIDE_FROM_ABI valarray& operator&=(const _Expr& __v); |
| 856 |
|
| 857 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 858 |
_LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const _Expr& __v); |
| 859 |
|
| 860 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 861 |
_LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const _Expr& __v); |
| 862 |
|
| 863 |
// member functions: |
| 864 |
_LIBCPP_HIDE_FROM_ABI void swap(valarray& __v) _NOEXCEPT; |
| 865 |
|
| 866 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return static_cast<size_t>(__end_ - __begin_); } |
| 867 |
|
| 868 |
_LIBCPP_HIDE_FROM_ABI value_type sum() const; |
| 869 |
_LIBCPP_HIDE_FROM_ABI value_type min() const; |
| 870 |
_LIBCPP_HIDE_FROM_ABI value_type max() const; |
| 871 |
|
| 872 |
valarray shift(int __i) const; |
| 873 |
valarray cshift(int __i) const; |
| 874 |
valarray apply(value_type __f(value_type)) const; |
| 875 |
valarray apply(value_type __f(const value_type&)) const; |
| 876 |
void resize(size_t __n, value_type __x = value_type()); |
| 877 |
|
| 878 |
private: |
| 879 |
template <class> |
| 880 |
friend class _LIBCPP_TEMPLATE_VIS valarray; |
| 881 |
template <class> |
| 882 |
friend class _LIBCPP_TEMPLATE_VIS slice_array; |
| 883 |
template <class> |
| 884 |
friend class _LIBCPP_TEMPLATE_VIS gslice_array; |
| 885 |
template <class> |
| 886 |
friend class _LIBCPP_TEMPLATE_VIS mask_array; |
| 887 |
template <class> |
| 888 |
friend class __mask_expr; |
| 889 |
template <class> |
| 890 |
friend class _LIBCPP_TEMPLATE_VIS indirect_array; |
| 891 |
template <class> |
| 892 |
friend class __indirect_expr; |
| 893 |
template <class> |
| 894 |
friend class __val_expr; |
| 895 |
|
| 896 |
template <class _Up> |
| 897 |
friend _Up* begin(valarray<_Up>& __v); |
| 898 |
|
| 899 |
template <class _Up> |
| 900 |
friend const _Up* begin(const valarray<_Up>& __v); |
| 901 |
|
| 902 |
template <class _Up> |
| 903 |
friend _Up* end(valarray<_Up>& __v); |
| 904 |
|
| 905 |
template <class _Up> |
| 906 |
friend const _Up* end(const valarray<_Up>& __v); |
| 907 |
|
| 908 |
_LIBCPP_HIDE_FROM_ABI void __clear(size_t __capacity); |
| 909 |
valarray& __assign_range(const value_type* __f, const value_type* __l); |
| 910 |
}; |
| 911 |
|
| 912 |
template <class _Expr, |
| 913 |
__enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0> |
| 914 |
_LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) { |
| 915 |
return __v.__get(__i); |
| 916 |
} |
| 917 |
|
| 918 |
template <class _Expr, |
| 919 |
__enable_if_t<__is_val_expr<_Expr>::value && !__val_expr_use_member_functions<_Expr>::value, int> = 0> |
| 920 |
_LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) { |
| 921 |
return __v[__i]; |
| 922 |
} |
| 923 |
|
| 924 |
extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t); |
| 925 |
|
| 926 |
template <class _Op, class _Tp> |
| 927 |
struct _UnaryOp<_Op, valarray<_Tp> > { |
| 928 |
typedef typename _Op::__result_type __result_type; |
| 929 |
using value_type = __decay_t<__result_type>; |
| 930 |
|
| 931 |
_Op __op_; |
| 932 |
const valarray<_Tp>& __a0_; |
| 933 |
|
| 934 |
_LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {} |
| 935 |
|
| 936 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); } |
| 937 |
|
| 938 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
| 939 |
}; |
| 940 |
|
| 941 |
template <class _Op, class _Tp, class _A1> |
| 942 |
struct _BinaryOp<_Op, valarray<_Tp>, _A1> { |
| 943 |
typedef typename _Op::__result_type __result_type; |
| 944 |
using value_type = __decay_t<__result_type>; |
| 945 |
|
| 946 |
_Op __op_; |
| 947 |
const valarray<_Tp>& __a0_; |
| 948 |
_A1 __a1_; |
| 949 |
|
| 950 |
_LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1) |
| 951 |
: __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 952 |
|
| 953 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); } |
| 954 |
|
| 955 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
| 956 |
}; |
| 957 |
|
| 958 |
template <class _Op, class _A0, class _Tp> |
| 959 |
struct _BinaryOp<_Op, _A0, valarray<_Tp> > { |
| 960 |
typedef typename _Op::__result_type __result_type; |
| 961 |
using value_type = __decay_t<__result_type>; |
| 962 |
|
| 963 |
_Op __op_; |
| 964 |
_A0 __a0_; |
| 965 |
const valarray<_Tp>& __a1_; |
| 966 |
|
| 967 |
_LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1) |
| 968 |
: __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 969 |
|
| 970 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); } |
| 971 |
|
| 972 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
| 973 |
}; |
| 974 |
|
| 975 |
template <class _Op, class _Tp> |
| 976 |
struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > { |
| 977 |
typedef typename _Op::__result_type __result_type; |
| 978 |
using value_type = __decay_t<__result_type>; |
| 979 |
|
| 980 |
_Op __op_; |
| 981 |
const valarray<_Tp>& __a0_; |
| 982 |
const valarray<_Tp>& __a1_; |
| 983 |
|
| 984 |
_LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1) |
| 985 |
: __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 986 |
|
| 987 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); } |
| 988 |
|
| 989 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
| 990 |
}; |
| 991 |
|
| 992 |
// slice_array |
| 993 |
|
| 994 |
template <class _Tp> |
| 995 |
class _LIBCPP_TEMPLATE_VIS slice_array { |
| 996 |
public: |
| 997 |
typedef _Tp value_type; |
| 998 |
|
| 999 |
private: |
| 1000 |
value_type* __vp_; |
| 1001 |
size_t __size_; |
| 1002 |
size_t __stride_; |
| 1003 |
|
| 1004 |
public: |
| 1005 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1006 |
void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const; |
| 1007 |
|
| 1008 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1009 |
void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const; |
| 1010 |
|
| 1011 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1012 |
void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const; |
| 1013 |
|
| 1014 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1015 |
void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const; |
| 1016 |
|
| 1017 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1018 |
void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const; |
| 1019 |
|
| 1020 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1021 |
void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const; |
| 1022 |
|
| 1023 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1024 |
void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const; |
| 1025 |
|
| 1026 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1027 |
void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const; |
| 1028 |
|
| 1029 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1030 |
void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const; |
| 1031 |
|
| 1032 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1033 |
void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const; |
| 1034 |
|
| 1035 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1036 |
void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const; |
| 1037 |
|
| 1038 |
slice_array(slice_array const&) = default; |
| 1039 |
|
| 1040 |
_LIBCPP_HIDE_FROM_ABI const slice_array& operator=(const slice_array& __sa) const; |
| 1041 |
|
| 1042 |
_LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; |
| 1043 |
|
| 1044 |
_LIBCPP_HIDE_FROM_ABI void operator=(const valarray<value_type>& __va) const; |
| 1045 |
|
| 1046 |
// Behaves like __val_expr::operator[], which returns by value. |
| 1047 |
_LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { |
| 1048 |
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "slice_array.__get() index out of bounds"); |
| 1049 |
return __vp_[__i * __stride_]; |
| 1050 |
} |
| 1051 |
|
| 1052 |
private: |
| 1053 |
_LIBCPP_HIDE_FROM_ABI slice_array(const slice& __sl, const valarray<value_type>& __v) |
| 1054 |
: __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), __size_(__sl.size()), __stride_(__sl.stride()) {} |
| 1055 |
|
| 1056 |
template <class> |
| 1057 |
friend class valarray; |
| 1058 |
}; |
| 1059 |
|
| 1060 |
template <class _Tp> |
| 1061 |
inline const slice_array<_Tp>& slice_array<_Tp>::operator=(const slice_array& __sa) const { |
| 1062 |
value_type* __t = __vp_; |
| 1063 |
const value_type* __s = __sa.__vp_; |
| 1064 |
for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_) |
| 1065 |
*__t = *__s; |
| 1066 |
return *this; |
| 1067 |
} |
| 1068 |
|
| 1069 |
template <class _Tp> |
| 1070 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1071 |
inline void slice_array<_Tp>::operator=(const _Expr& __v) const { |
| 1072 |
value_type* __t = __vp_; |
| 1073 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1074 |
*__t = __v[__i]; |
| 1075 |
} |
| 1076 |
|
| 1077 |
template <class _Tp> |
| 1078 |
inline void slice_array<_Tp>::operator=(const valarray<value_type>& __va) const { |
| 1079 |
value_type* __t = __vp_; |
| 1080 |
for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_) |
| 1081 |
*__t = __va[__i]; |
| 1082 |
} |
| 1083 |
|
| 1084 |
template <class _Tp> |
| 1085 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1086 |
inline void slice_array<_Tp>::operator*=(const _Expr& __v) const { |
| 1087 |
value_type* __t = __vp_; |
| 1088 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1089 |
*__t *= __v[__i]; |
| 1090 |
} |
| 1091 |
|
| 1092 |
template <class _Tp> |
| 1093 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1094 |
inline void slice_array<_Tp>::operator/=(const _Expr& __v) const { |
| 1095 |
value_type* __t = __vp_; |
| 1096 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1097 |
*__t /= __v[__i]; |
| 1098 |
} |
| 1099 |
|
| 1100 |
template <class _Tp> |
| 1101 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1102 |
inline void slice_array<_Tp>::operator%=(const _Expr& __v) const { |
| 1103 |
value_type* __t = __vp_; |
| 1104 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1105 |
*__t %= __v[__i]; |
| 1106 |
} |
| 1107 |
|
| 1108 |
template <class _Tp> |
| 1109 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1110 |
inline void slice_array<_Tp>::operator+=(const _Expr& __v) const { |
| 1111 |
value_type* __t = __vp_; |
| 1112 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1113 |
*__t += __v[__i]; |
| 1114 |
} |
| 1115 |
|
| 1116 |
template <class _Tp> |
| 1117 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1118 |
inline void slice_array<_Tp>::operator-=(const _Expr& __v) const { |
| 1119 |
value_type* __t = __vp_; |
| 1120 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1121 |
*__t -= __v[__i]; |
| 1122 |
} |
| 1123 |
|
| 1124 |
template <class _Tp> |
| 1125 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1126 |
inline void slice_array<_Tp>::operator^=(const _Expr& __v) const { |
| 1127 |
value_type* __t = __vp_; |
| 1128 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1129 |
*__t ^= __v[__i]; |
| 1130 |
} |
| 1131 |
|
| 1132 |
template <class _Tp> |
| 1133 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1134 |
inline void slice_array<_Tp>::operator&=(const _Expr& __v) const { |
| 1135 |
value_type* __t = __vp_; |
| 1136 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1137 |
*__t &= __v[__i]; |
| 1138 |
} |
| 1139 |
|
| 1140 |
template <class _Tp> |
| 1141 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1142 |
inline void slice_array<_Tp>::operator|=(const _Expr& __v) const { |
| 1143 |
value_type* __t = __vp_; |
| 1144 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1145 |
*__t |= __v[__i]; |
| 1146 |
} |
| 1147 |
|
| 1148 |
template <class _Tp> |
| 1149 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1150 |
inline void slice_array<_Tp>::operator<<=(const _Expr& __v) const { |
| 1151 |
value_type* __t = __vp_; |
| 1152 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1153 |
*__t <<= __v[__i]; |
| 1154 |
} |
| 1155 |
|
| 1156 |
template <class _Tp> |
| 1157 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1158 |
inline void slice_array<_Tp>::operator>>=(const _Expr& __v) const { |
| 1159 |
value_type* __t = __vp_; |
| 1160 |
for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1161 |
*__t >>= __v[__i]; |
| 1162 |
} |
| 1163 |
|
| 1164 |
template <class _Tp> |
| 1165 |
inline void slice_array<_Tp>::operator=(const value_type& __x) const { |
| 1166 |
value_type* __t = __vp_; |
| 1167 |
for (size_t __n = __size_; __n; --__n, __t += __stride_) |
| 1168 |
*__t = __x; |
| 1169 |
} |
| 1170 |
|
| 1171 |
// gslice |
| 1172 |
|
| 1173 |
class _LIBCPP_EXPORTED_FROM_ABI gslice { |
| 1174 |
valarray<size_t> __size_; |
| 1175 |
valarray<size_t> __stride_; |
| 1176 |
valarray<size_t> __1d_; |
| 1177 |
|
| 1178 |
public: |
| 1179 |
_LIBCPP_HIDE_FROM_ABI gslice() {} |
| 1180 |
|
| 1181 |
_LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, const valarray<size_t>& __stride) |
| 1182 |
: __size_(__size), __stride_(__stride) { |
| 1183 |
__init(__start); |
| 1184 |
} |
| 1185 |
|
| 1186 |
_LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; } |
| 1187 |
|
| 1188 |
_LIBCPP_HIDE_FROM_ABI valarray<size_t> size() const { return __size_; } |
| 1189 |
|
| 1190 |
_LIBCPP_HIDE_FROM_ABI valarray<size_t> stride() const { return __stride_; } |
| 1191 |
|
| 1192 |
private: |
| 1193 |
void __init(size_t __start); |
| 1194 |
|
| 1195 |
template <class> |
| 1196 |
friend class gslice_array; |
| 1197 |
template <class> |
| 1198 |
friend class valarray; |
| 1199 |
template <class> |
| 1200 |
friend class __val_expr; |
| 1201 |
}; |
| 1202 |
|
| 1203 |
// gslice_array |
| 1204 |
|
| 1205 |
template <class _Tp> |
| 1206 |
class _LIBCPP_TEMPLATE_VIS gslice_array { |
| 1207 |
public: |
| 1208 |
typedef _Tp value_type; |
| 1209 |
|
| 1210 |
private: |
| 1211 |
value_type* __vp_; |
| 1212 |
valarray<size_t> __1d_; |
| 1213 |
|
| 1214 |
public: |
| 1215 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1216 |
void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const; |
| 1217 |
|
| 1218 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1219 |
void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const; |
| 1220 |
|
| 1221 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1222 |
void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const; |
| 1223 |
|
| 1224 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1225 |
void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const; |
| 1226 |
|
| 1227 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1228 |
void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const; |
| 1229 |
|
| 1230 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1231 |
void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const; |
| 1232 |
|
| 1233 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1234 |
void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const; |
| 1235 |
|
| 1236 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1237 |
void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const; |
| 1238 |
|
| 1239 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1240 |
void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const; |
| 1241 |
|
| 1242 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1243 |
void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const; |
| 1244 |
|
| 1245 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1246 |
void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const; |
| 1247 |
|
| 1248 |
_LIBCPP_HIDE_FROM_ABI const gslice_array& operator=(const gslice_array& __ga) const; |
| 1249 |
|
| 1250 |
_LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; |
| 1251 |
|
| 1252 |
gslice_array(const gslice_array&) = default; |
| 1253 |
|
| 1254 |
// Behaves like __val_expr::operator[], which returns by value. |
| 1255 |
_LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { |
| 1256 |
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "gslice_array.__get() index out of bounds"); |
| 1257 |
return __vp_[__1d_[__i]]; |
| 1258 |
} |
| 1259 |
|
| 1260 |
private: |
| 1261 |
gslice_array(const gslice& __gs, const valarray<value_type>& __v) |
| 1262 |
: __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {} |
| 1263 |
|
| 1264 |
template <class> |
| 1265 |
friend class valarray; |
| 1266 |
}; |
| 1267 |
|
| 1268 |
template <class _Tp> |
| 1269 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1270 |
inline void gslice_array<_Tp>::operator=(const _Expr& __v) const { |
| 1271 |
typedef const size_t* _Ip; |
| 1272 |
size_t __j = 0; |
| 1273 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1274 |
__vp_[*__i] = __v[__j]; |
| 1275 |
} |
| 1276 |
|
| 1277 |
template <class _Tp> |
| 1278 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1279 |
inline void gslice_array<_Tp>::operator*=(const _Expr& __v) const { |
| 1280 |
typedef const size_t* _Ip; |
| 1281 |
size_t __j = 0; |
| 1282 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1283 |
__vp_[*__i] *= __v[__j]; |
| 1284 |
} |
| 1285 |
|
| 1286 |
template <class _Tp> |
| 1287 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1288 |
inline void gslice_array<_Tp>::operator/=(const _Expr& __v) const { |
| 1289 |
typedef const size_t* _Ip; |
| 1290 |
size_t __j = 0; |
| 1291 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1292 |
__vp_[*__i] /= __v[__j]; |
| 1293 |
} |
| 1294 |
|
| 1295 |
template <class _Tp> |
| 1296 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1297 |
inline void gslice_array<_Tp>::operator%=(const _Expr& __v) const { |
| 1298 |
typedef const size_t* _Ip; |
| 1299 |
size_t __j = 0; |
| 1300 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1301 |
__vp_[*__i] %= __v[__j]; |
| 1302 |
} |
| 1303 |
|
| 1304 |
template <class _Tp> |
| 1305 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1306 |
inline void gslice_array<_Tp>::operator+=(const _Expr& __v) const { |
| 1307 |
typedef const size_t* _Ip; |
| 1308 |
size_t __j = 0; |
| 1309 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1310 |
__vp_[*__i] += __v[__j]; |
| 1311 |
} |
| 1312 |
|
| 1313 |
template <class _Tp> |
| 1314 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1315 |
inline void gslice_array<_Tp>::operator-=(const _Expr& __v) const { |
| 1316 |
typedef const size_t* _Ip; |
| 1317 |
size_t __j = 0; |
| 1318 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1319 |
__vp_[*__i] -= __v[__j]; |
| 1320 |
} |
| 1321 |
|
| 1322 |
template <class _Tp> |
| 1323 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1324 |
inline void gslice_array<_Tp>::operator^=(const _Expr& __v) const { |
| 1325 |
typedef const size_t* _Ip; |
| 1326 |
size_t __j = 0; |
| 1327 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1328 |
__vp_[*__i] ^= __v[__j]; |
| 1329 |
} |
| 1330 |
|
| 1331 |
template <class _Tp> |
| 1332 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1333 |
inline void gslice_array<_Tp>::operator&=(const _Expr& __v) const { |
| 1334 |
typedef const size_t* _Ip; |
| 1335 |
size_t __j = 0; |
| 1336 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1337 |
__vp_[*__i] &= __v[__j]; |
| 1338 |
} |
| 1339 |
|
| 1340 |
template <class _Tp> |
| 1341 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1342 |
inline void gslice_array<_Tp>::operator|=(const _Expr& __v) const { |
| 1343 |
typedef const size_t* _Ip; |
| 1344 |
size_t __j = 0; |
| 1345 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1346 |
__vp_[*__i] |= __v[__j]; |
| 1347 |
} |
| 1348 |
|
| 1349 |
template <class _Tp> |
| 1350 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1351 |
inline void gslice_array<_Tp>::operator<<=(const _Expr& __v) const { |
| 1352 |
typedef const size_t* _Ip; |
| 1353 |
size_t __j = 0; |
| 1354 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1355 |
__vp_[*__i] <<= __v[__j]; |
| 1356 |
} |
| 1357 |
|
| 1358 |
template <class _Tp> |
| 1359 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1360 |
inline void gslice_array<_Tp>::operator>>=(const _Expr& __v) const { |
| 1361 |
typedef const size_t* _Ip; |
| 1362 |
size_t __j = 0; |
| 1363 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1364 |
__vp_[*__i] >>= __v[__j]; |
| 1365 |
} |
| 1366 |
|
| 1367 |
template <class _Tp> |
| 1368 |
inline const gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array& __ga) const { |
| 1369 |
typedef const size_t* _Ip; |
| 1370 |
const value_type* __s = __ga.__vp_; |
| 1371 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; __i != __e; ++__i, ++__j) |
| 1372 |
__vp_[*__i] = __s[*__j]; |
| 1373 |
return *this; |
| 1374 |
} |
| 1375 |
|
| 1376 |
template <class _Tp> |
| 1377 |
inline void gslice_array<_Tp>::operator=(const value_type& __x) const { |
| 1378 |
typedef const size_t* _Ip; |
| 1379 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) |
| 1380 |
__vp_[*__i] = __x; |
| 1381 |
} |
| 1382 |
|
| 1383 |
// mask_array |
| 1384 |
|
| 1385 |
template <class _Tp> |
| 1386 |
class _LIBCPP_TEMPLATE_VIS mask_array { |
| 1387 |
public: |
| 1388 |
typedef _Tp value_type; |
| 1389 |
|
| 1390 |
private: |
| 1391 |
value_type* __vp_; |
| 1392 |
valarray<size_t> __1d_; |
| 1393 |
|
| 1394 |
public: |
| 1395 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1396 |
void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const; |
| 1397 |
|
| 1398 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1399 |
void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const; |
| 1400 |
|
| 1401 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1402 |
void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const; |
| 1403 |
|
| 1404 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1405 |
void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const; |
| 1406 |
|
| 1407 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1408 |
void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const; |
| 1409 |
|
| 1410 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1411 |
void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const; |
| 1412 |
|
| 1413 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1414 |
void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const; |
| 1415 |
|
| 1416 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1417 |
void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const; |
| 1418 |
|
| 1419 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1420 |
void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const; |
| 1421 |
|
| 1422 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1423 |
void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const; |
| 1424 |
|
| 1425 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1426 |
void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const; |
| 1427 |
|
| 1428 |
mask_array(const mask_array&) = default; |
| 1429 |
|
| 1430 |
_LIBCPP_HIDE_FROM_ABI const mask_array& operator=(const mask_array& __ma) const; |
| 1431 |
|
| 1432 |
_LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; |
| 1433 |
|
| 1434 |
// Behaves like __val_expr::operator[], which returns by value. |
| 1435 |
_LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { |
| 1436 |
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "mask_array.__get() index out of bounds"); |
| 1437 |
return __vp_[__1d_[__i]]; |
| 1438 |
} |
| 1439 |
|
| 1440 |
private: |
| 1441 |
_LIBCPP_HIDE_FROM_ABI mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v) |
| 1442 |
: __vp_(const_cast<value_type*>(__v.__begin_)), |
| 1443 |
__1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) { |
| 1444 |
size_t __j = 0; |
| 1445 |
for (size_t __i = 0; __i < __vb.size(); ++__i) |
| 1446 |
if (__vb[__i]) |
| 1447 |
__1d_[__j++] = __i; |
| 1448 |
} |
| 1449 |
|
| 1450 |
template <class> |
| 1451 |
friend class valarray; |
| 1452 |
}; |
| 1453 |
|
| 1454 |
template <class _Tp> |
| 1455 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1456 |
inline void mask_array<_Tp>::operator=(const _Expr& __v) const { |
| 1457 |
size_t __n = __1d_.size(); |
| 1458 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1459 |
__vp_[__1d_[__i]] = __v[__i]; |
| 1460 |
} |
| 1461 |
|
| 1462 |
template <class _Tp> |
| 1463 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1464 |
inline void mask_array<_Tp>::operator*=(const _Expr& __v) const { |
| 1465 |
size_t __n = __1d_.size(); |
| 1466 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1467 |
__vp_[__1d_[__i]] *= __v[__i]; |
| 1468 |
} |
| 1469 |
|
| 1470 |
template <class _Tp> |
| 1471 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1472 |
inline void mask_array<_Tp>::operator/=(const _Expr& __v) const { |
| 1473 |
size_t __n = __1d_.size(); |
| 1474 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1475 |
__vp_[__1d_[__i]] /= __v[__i]; |
| 1476 |
} |
| 1477 |
|
| 1478 |
template <class _Tp> |
| 1479 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1480 |
inline void mask_array<_Tp>::operator%=(const _Expr& __v) const { |
| 1481 |
size_t __n = __1d_.size(); |
| 1482 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1483 |
__vp_[__1d_[__i]] %= __v[__i]; |
| 1484 |
} |
| 1485 |
|
| 1486 |
template <class _Tp> |
| 1487 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1488 |
inline void mask_array<_Tp>::operator+=(const _Expr& __v) const { |
| 1489 |
size_t __n = __1d_.size(); |
| 1490 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1491 |
__vp_[__1d_[__i]] += __v[__i]; |
| 1492 |
} |
| 1493 |
|
| 1494 |
template <class _Tp> |
| 1495 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1496 |
inline void mask_array<_Tp>::operator-=(const _Expr& __v) const { |
| 1497 |
size_t __n = __1d_.size(); |
| 1498 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1499 |
__vp_[__1d_[__i]] -= __v[__i]; |
| 1500 |
} |
| 1501 |
|
| 1502 |
template <class _Tp> |
| 1503 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1504 |
inline void mask_array<_Tp>::operator^=(const _Expr& __v) const { |
| 1505 |
size_t __n = __1d_.size(); |
| 1506 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1507 |
__vp_[__1d_[__i]] ^= __v[__i]; |
| 1508 |
} |
| 1509 |
|
| 1510 |
template <class _Tp> |
| 1511 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1512 |
inline void mask_array<_Tp>::operator&=(const _Expr& __v) const { |
| 1513 |
size_t __n = __1d_.size(); |
| 1514 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1515 |
__vp_[__1d_[__i]] &= __v[__i]; |
| 1516 |
} |
| 1517 |
|
| 1518 |
template <class _Tp> |
| 1519 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1520 |
inline void mask_array<_Tp>::operator|=(const _Expr& __v) const { |
| 1521 |
size_t __n = __1d_.size(); |
| 1522 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1523 |
__vp_[__1d_[__i]] |= __v[__i]; |
| 1524 |
} |
| 1525 |
|
| 1526 |
template <class _Tp> |
| 1527 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1528 |
inline void mask_array<_Tp>::operator<<=(const _Expr& __v) const { |
| 1529 |
size_t __n = __1d_.size(); |
| 1530 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1531 |
__vp_[__1d_[__i]] <<= __v[__i]; |
| 1532 |
} |
| 1533 |
|
| 1534 |
template <class _Tp> |
| 1535 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1536 |
inline void mask_array<_Tp>::operator>>=(const _Expr& __v) const { |
| 1537 |
size_t __n = __1d_.size(); |
| 1538 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1539 |
__vp_[__1d_[__i]] >>= __v[__i]; |
| 1540 |
} |
| 1541 |
|
| 1542 |
template <class _Tp> |
| 1543 |
inline const mask_array<_Tp>& mask_array<_Tp>::operator=(const mask_array& __ma) const { |
| 1544 |
size_t __n = __1d_.size(); |
| 1545 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1546 |
__vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]]; |
| 1547 |
return *this; |
| 1548 |
} |
| 1549 |
|
| 1550 |
template <class _Tp> |
| 1551 |
inline void mask_array<_Tp>::operator=(const value_type& __x) const { |
| 1552 |
size_t __n = __1d_.size(); |
| 1553 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1554 |
__vp_[__1d_[__i]] = __x; |
| 1555 |
} |
| 1556 |
|
| 1557 |
template <class _ValExpr> |
| 1558 |
class __mask_expr { |
| 1559 |
typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
| 1560 |
|
| 1561 |
public: |
| 1562 |
typedef typename _RmExpr::value_type value_type; |
| 1563 |
typedef value_type __result_type; |
| 1564 |
|
| 1565 |
private: |
| 1566 |
_ValExpr __expr_; |
| 1567 |
valarray<size_t> __1d_; |
| 1568 |
|
| 1569 |
_LIBCPP_HIDE_FROM_ABI __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e) |
| 1570 |
: __expr_(__e), __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) { |
| 1571 |
size_t __j = 0; |
| 1572 |
for (size_t __i = 0; __i < __vb.size(); ++__i) |
| 1573 |
if (__vb[__i]) |
| 1574 |
__1d_[__j++] = __i; |
| 1575 |
} |
| 1576 |
|
| 1577 |
public: |
| 1578 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; } |
| 1579 |
|
| 1580 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); } |
| 1581 |
|
| 1582 |
template <class> |
| 1583 |
friend class __val_expr; |
| 1584 |
template <class> |
| 1585 |
friend class valarray; |
| 1586 |
}; |
| 1587 |
|
| 1588 |
// indirect_array |
| 1589 |
|
| 1590 |
template <class _Tp> |
| 1591 |
class _LIBCPP_TEMPLATE_VIS indirect_array { |
| 1592 |
public: |
| 1593 |
typedef _Tp value_type; |
| 1594 |
|
| 1595 |
private: |
| 1596 |
value_type* __vp_; |
| 1597 |
valarray<size_t> __1d_; |
| 1598 |
|
| 1599 |
public: |
| 1600 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1601 |
void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const; |
| 1602 |
|
| 1603 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1604 |
void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const; |
| 1605 |
|
| 1606 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1607 |
void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const; |
| 1608 |
|
| 1609 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1610 |
void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const; |
| 1611 |
|
| 1612 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1613 |
void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const; |
| 1614 |
|
| 1615 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1616 |
void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const; |
| 1617 |
|
| 1618 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1619 |
void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const; |
| 1620 |
|
| 1621 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1622 |
void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const; |
| 1623 |
|
| 1624 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1625 |
void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const; |
| 1626 |
|
| 1627 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1628 |
void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const; |
| 1629 |
|
| 1630 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 1631 |
void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const; |
| 1632 |
|
| 1633 |
indirect_array(const indirect_array&) = default; |
| 1634 |
|
| 1635 |
_LIBCPP_HIDE_FROM_ABI const indirect_array& operator=(const indirect_array& __ia) const; |
| 1636 |
|
| 1637 |
_LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; |
| 1638 |
|
| 1639 |
// Behaves like __val_expr::operator[], which returns by value. |
| 1640 |
_LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { |
| 1641 |
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "indirect_array.__get() index out of bounds"); |
| 1642 |
return __vp_[__1d_[__i]]; |
| 1643 |
} |
| 1644 |
|
| 1645 |
private: |
| 1646 |
_LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v) |
| 1647 |
: __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {} |
| 1648 |
|
| 1649 |
template <class> |
| 1650 |
friend class valarray; |
| 1651 |
}; |
| 1652 |
|
| 1653 |
template <class _Tp> |
| 1654 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1655 |
inline void indirect_array<_Tp>::operator=(const _Expr& __v) const { |
| 1656 |
size_t __n = __1d_.size(); |
| 1657 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1658 |
__vp_[__1d_[__i]] = __v[__i]; |
| 1659 |
} |
| 1660 |
|
| 1661 |
template <class _Tp> |
| 1662 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1663 |
inline void indirect_array<_Tp>::operator*=(const _Expr& __v) const { |
| 1664 |
size_t __n = __1d_.size(); |
| 1665 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1666 |
__vp_[__1d_[__i]] *= __v[__i]; |
| 1667 |
} |
| 1668 |
|
| 1669 |
template <class _Tp> |
| 1670 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1671 |
inline void indirect_array<_Tp>::operator/=(const _Expr& __v) const { |
| 1672 |
size_t __n = __1d_.size(); |
| 1673 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1674 |
__vp_[__1d_[__i]] /= __v[__i]; |
| 1675 |
} |
| 1676 |
|
| 1677 |
template <class _Tp> |
| 1678 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1679 |
inline void indirect_array<_Tp>::operator%=(const _Expr& __v) const { |
| 1680 |
size_t __n = __1d_.size(); |
| 1681 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1682 |
__vp_[__1d_[__i]] %= __v[__i]; |
| 1683 |
} |
| 1684 |
|
| 1685 |
template <class _Tp> |
| 1686 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1687 |
inline void indirect_array<_Tp>::operator+=(const _Expr& __v) const { |
| 1688 |
size_t __n = __1d_.size(); |
| 1689 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1690 |
__vp_[__1d_[__i]] += __v[__i]; |
| 1691 |
} |
| 1692 |
|
| 1693 |
template <class _Tp> |
| 1694 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1695 |
inline void indirect_array<_Tp>::operator-=(const _Expr& __v) const { |
| 1696 |
size_t __n = __1d_.size(); |
| 1697 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1698 |
__vp_[__1d_[__i]] -= __v[__i]; |
| 1699 |
} |
| 1700 |
|
| 1701 |
template <class _Tp> |
| 1702 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1703 |
inline void indirect_array<_Tp>::operator^=(const _Expr& __v) const { |
| 1704 |
size_t __n = __1d_.size(); |
| 1705 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1706 |
__vp_[__1d_[__i]] ^= __v[__i]; |
| 1707 |
} |
| 1708 |
|
| 1709 |
template <class _Tp> |
| 1710 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1711 |
inline void indirect_array<_Tp>::operator&=(const _Expr& __v) const { |
| 1712 |
size_t __n = __1d_.size(); |
| 1713 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1714 |
__vp_[__1d_[__i]] &= __v[__i]; |
| 1715 |
} |
| 1716 |
|
| 1717 |
template <class _Tp> |
| 1718 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1719 |
inline void indirect_array<_Tp>::operator|=(const _Expr& __v) const { |
| 1720 |
size_t __n = __1d_.size(); |
| 1721 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1722 |
__vp_[__1d_[__i]] |= __v[__i]; |
| 1723 |
} |
| 1724 |
|
| 1725 |
template <class _Tp> |
| 1726 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1727 |
inline void indirect_array<_Tp>::operator<<=(const _Expr& __v) const { |
| 1728 |
size_t __n = __1d_.size(); |
| 1729 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1730 |
__vp_[__1d_[__i]] <<= __v[__i]; |
| 1731 |
} |
| 1732 |
|
| 1733 |
template <class _Tp> |
| 1734 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 1735 |
inline void indirect_array<_Tp>::operator>>=(const _Expr& __v) const { |
| 1736 |
size_t __n = __1d_.size(); |
| 1737 |
for (size_t __i = 0; __i < __n; ++__i) |
| 1738 |
__vp_[__1d_[__i]] >>= __v[__i]; |
| 1739 |
} |
| 1740 |
|
| 1741 |
template <class _Tp> |
| 1742 |
inline const indirect_array<_Tp>& indirect_array<_Tp>::operator=(const indirect_array& __ia) const { |
| 1743 |
typedef const size_t* _Ip; |
| 1744 |
const value_type* __s = __ia.__vp_; |
| 1745 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; __i != __e; ++__i, ++__j) |
| 1746 |
__vp_[*__i] = __s[*__j]; |
| 1747 |
return *this; |
| 1748 |
} |
| 1749 |
|
| 1750 |
template <class _Tp> |
| 1751 |
inline void indirect_array<_Tp>::operator=(const value_type& __x) const { |
| 1752 |
typedef const size_t* _Ip; |
| 1753 |
for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) |
| 1754 |
__vp_[*__i] = __x; |
| 1755 |
} |
| 1756 |
|
| 1757 |
template <class _ValExpr> |
| 1758 |
class __indirect_expr { |
| 1759 |
typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
| 1760 |
|
| 1761 |
public: |
| 1762 |
typedef typename _RmExpr::value_type value_type; |
| 1763 |
typedef value_type __result_type; |
| 1764 |
|
| 1765 |
private: |
| 1766 |
_ValExpr __expr_; |
| 1767 |
valarray<size_t> __1d_; |
| 1768 |
|
| 1769 |
_LIBCPP_HIDE_FROM_ABI __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(__ia) {} |
| 1770 |
|
| 1771 |
public: |
| 1772 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; } |
| 1773 |
|
| 1774 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); } |
| 1775 |
|
| 1776 |
template <class> |
| 1777 |
friend class __val_expr; |
| 1778 |
template <class> |
| 1779 |
friend class _LIBCPP_TEMPLATE_VIS valarray; |
| 1780 |
}; |
| 1781 |
|
| 1782 |
template <class _ValExpr> |
| 1783 |
class __val_expr { |
| 1784 |
typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
| 1785 |
|
| 1786 |
_ValExpr __expr_; |
| 1787 |
|
| 1788 |
public: |
| 1789 |
typedef typename _RmExpr::value_type value_type; |
| 1790 |
typedef typename _RmExpr::__result_type __result_type; |
| 1791 |
|
| 1792 |
_LIBCPP_HIDE_FROM_ABI explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {} |
| 1793 |
|
| 1794 |
_LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__i]; } |
| 1795 |
|
| 1796 |
_LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const { |
| 1797 |
typedef __slice_expr<_ValExpr> _NewExpr; |
| 1798 |
return __val_expr< _NewExpr >(_NewExpr(__s, __expr_)); |
| 1799 |
} |
| 1800 |
|
| 1801 |
_LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const { |
| 1802 |
typedef __indirect_expr<_ValExpr> _NewExpr; |
| 1803 |
return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_)); |
| 1804 |
} |
| 1805 |
|
| 1806 |
_LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const { |
| 1807 |
typedef __mask_expr<_ValExpr> _NewExpr; |
| 1808 |
return __val_expr< _NewExpr >(_NewExpr(__vb, __expr_)); |
| 1809 |
} |
| 1810 |
|
| 1811 |
_LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const { |
| 1812 |
typedef __indirect_expr<_ValExpr> _NewExpr; |
| 1813 |
return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_)); |
| 1814 |
} |
| 1815 |
|
| 1816 |
_LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> > operator+() const { |
| 1817 |
typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr; |
| 1818 |
return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_)); |
| 1819 |
} |
| 1820 |
|
| 1821 |
_LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<value_type>, _ValExpr> > operator-() const { |
| 1822 |
typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr; |
| 1823 |
return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_)); |
| 1824 |
} |
| 1825 |
|
| 1826 |
_LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> > operator~() const { |
| 1827 |
typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr; |
| 1828 |
return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_)); |
| 1829 |
} |
| 1830 |
|
| 1831 |
_LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> > operator!() const { |
| 1832 |
typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr; |
| 1833 |
return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_)); |
| 1834 |
} |
| 1835 |
|
| 1836 |
operator valarray<__result_type>() const; |
| 1837 |
|
| 1838 |
_LIBCPP_HIDE_FROM_ABI size_t size() const { return __expr_.size(); } |
| 1839 |
|
| 1840 |
_LIBCPP_HIDE_FROM_ABI __result_type sum() const { |
| 1841 |
size_t __n = __expr_.size(); |
| 1842 |
__result_type __r = __n ? __expr_[0] : __result_type(); |
| 1843 |
for (size_t __i = 1; __i < __n; ++__i) |
| 1844 |
__r += __expr_[__i]; |
| 1845 |
return __r; |
| 1846 |
} |
| 1847 |
|
| 1848 |
_LIBCPP_HIDE_FROM_ABI __result_type min() const { |
| 1849 |
size_t __n = size(); |
| 1850 |
__result_type __r = __n ? (*this)[0] : __result_type(); |
| 1851 |
for (size_t __i = 1; __i < __n; ++__i) { |
| 1852 |
__result_type __x = __expr_[__i]; |
| 1853 |
if (__x < __r) |
| 1854 |
__r = __x; |
| 1855 |
} |
| 1856 |
return __r; |
| 1857 |
} |
| 1858 |
|
| 1859 |
_LIBCPP_HIDE_FROM_ABI __result_type max() const { |
| 1860 |
size_t __n = size(); |
| 1861 |
__result_type __r = __n ? (*this)[0] : __result_type(); |
| 1862 |
for (size_t __i = 1; __i < __n; ++__i) { |
| 1863 |
__result_type __x = __expr_[__i]; |
| 1864 |
if (__r < __x) |
| 1865 |
__r = __x; |
| 1866 |
} |
| 1867 |
return __r; |
| 1868 |
} |
| 1869 |
|
| 1870 |
_LIBCPP_HIDE_FROM_ABI __val_expr<__shift_expr<_ValExpr> > shift(int __i) const { |
| 1871 |
return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_)); |
| 1872 |
} |
| 1873 |
|
| 1874 |
_LIBCPP_HIDE_FROM_ABI __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const { |
| 1875 |
return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_)); |
| 1876 |
} |
| 1877 |
|
| 1878 |
_LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(value_type)>, _ValExpr> > |
| 1879 |
apply(value_type __f(value_type)) const { |
| 1880 |
typedef __apply_expr<value_type, value_type (*)(value_type)> _Op; |
| 1881 |
typedef _UnaryOp<_Op, _ValExpr> _NewExpr; |
| 1882 |
return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); |
| 1883 |
} |
| 1884 |
|
| 1885 |
_LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(const value_type&)>, _ValExpr> > |
| 1886 |
apply(value_type __f(const value_type&)) const { |
| 1887 |
typedef __apply_expr<value_type, value_type (*)(const value_type&)> _Op; |
| 1888 |
typedef _UnaryOp<_Op, _ValExpr> _NewExpr; |
| 1889 |
return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); |
| 1890 |
} |
| 1891 |
}; |
| 1892 |
|
| 1893 |
template <class _ValExpr> |
| 1894 |
__val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const { |
| 1895 |
valarray<__result_type> __r; |
| 1896 |
size_t __n = __expr_.size(); |
| 1897 |
if (__n) { |
| 1898 |
__r.__begin_ = __r.__end_ = allocator<__result_type>().allocate(__n); |
| 1899 |
for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i) |
| 1900 |
::new ((void*)__r.__end_) __result_type(__expr_[__i]); |
| 1901 |
} |
| 1902 |
return __r; |
| 1903 |
} |
| 1904 |
|
| 1905 |
// valarray |
| 1906 |
|
| 1907 |
template <class _Tp> |
| 1908 |
inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) { |
| 1909 |
if (__n) { |
| 1910 |
__begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 1911 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1912 |
try { |
| 1913 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1914 |
for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
| 1915 |
::new ((void*)__end_) value_type(); |
| 1916 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1917 |
} catch (...) { |
| 1918 |
__clear(__n); |
| 1919 |
throw; |
| 1920 |
} |
| 1921 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1922 |
} |
| 1923 |
} |
| 1924 |
|
| 1925 |
template <class _Tp> |
| 1926 |
inline valarray<_Tp>::valarray(const value_type& __x, size_t __n) : __begin_(nullptr), __end_(nullptr) { |
| 1927 |
resize(__n, __x); |
| 1928 |
} |
| 1929 |
|
| 1930 |
template <class _Tp> |
| 1931 |
valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) { |
| 1932 |
if (__n) { |
| 1933 |
__begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 1934 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1935 |
try { |
| 1936 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1937 |
for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) |
| 1938 |
::new ((void*)__end_) value_type(*__p); |
| 1939 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1940 |
} catch (...) { |
| 1941 |
__clear(__n); |
| 1942 |
throw; |
| 1943 |
} |
| 1944 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1945 |
} |
| 1946 |
} |
| 1947 |
|
| 1948 |
template <class _Tp> |
| 1949 |
valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) { |
| 1950 |
if (__v.size()) { |
| 1951 |
__begin_ = __end_ = allocator<value_type>().allocate(__v.size()); |
| 1952 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1953 |
try { |
| 1954 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1955 |
for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) |
| 1956 |
::new ((void*)__end_) value_type(*__p); |
| 1957 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1958 |
} catch (...) { |
| 1959 |
__clear(__v.size()); |
| 1960 |
throw; |
| 1961 |
} |
| 1962 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1963 |
} |
| 1964 |
} |
| 1965 |
|
| 1966 |
template <class _Tp> |
| 1967 |
valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr), __end_(nullptr) { |
| 1968 |
const size_t __n = __sa.__size_; |
| 1969 |
if (__n) { |
| 1970 |
__begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 1971 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1972 |
try { |
| 1973 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1974 |
size_t __n_left = __n; |
| 1975 |
for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) |
| 1976 |
::new ((void*)__end_) value_type(*__p); |
| 1977 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1978 |
} catch (...) { |
| 1979 |
__clear(__n); |
| 1980 |
throw; |
| 1981 |
} |
| 1982 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1983 |
} |
| 1984 |
} |
| 1985 |
|
| 1986 |
template <class _Tp> |
| 1987 |
valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr), __end_(nullptr) { |
| 1988 |
const size_t __n = __ga.__1d_.size(); |
| 1989 |
if (__n) { |
| 1990 |
__begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 1991 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1992 |
try { |
| 1993 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 1994 |
typedef const size_t* _Ip; |
| 1995 |
const value_type* __s = __ga.__vp_; |
| 1996 |
for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_) |
| 1997 |
::new ((void*)__end_) value_type(__s[*__i]); |
| 1998 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 1999 |
} catch (...) { |
| 2000 |
__clear(__n); |
| 2001 |
throw; |
| 2002 |
} |
| 2003 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 2004 |
} |
| 2005 |
} |
| 2006 |
|
| 2007 |
template <class _Tp> |
| 2008 |
valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr), __end_(nullptr) { |
| 2009 |
const size_t __n = __ma.__1d_.size(); |
| 2010 |
if (__n) { |
| 2011 |
__begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2012 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 2013 |
try { |
| 2014 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 2015 |
typedef const size_t* _Ip; |
| 2016 |
const value_type* __s = __ma.__vp_; |
| 2017 |
for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_) |
| 2018 |
::new ((void*)__end_) value_type(__s[*__i]); |
| 2019 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 2020 |
} catch (...) { |
| 2021 |
__clear(__n); |
| 2022 |
throw; |
| 2023 |
} |
| 2024 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 2025 |
} |
| 2026 |
} |
| 2027 |
|
| 2028 |
template <class _Tp> |
| 2029 |
valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullptr), __end_(nullptr) { |
| 2030 |
const size_t __n = __ia.__1d_.size(); |
| 2031 |
if (__n) { |
| 2032 |
__begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2033 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 2034 |
try { |
| 2035 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 2036 |
typedef const size_t* _Ip; |
| 2037 |
const value_type* __s = __ia.__vp_; |
| 2038 |
for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_) |
| 2039 |
::new ((void*)__end_) value_type(__s[*__i]); |
| 2040 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 2041 |
} catch (...) { |
| 2042 |
__clear(__n); |
| 2043 |
throw; |
| 2044 |
} |
| 2045 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 2046 |
} |
| 2047 |
} |
| 2048 |
|
| 2049 |
template <class _Tp> |
| 2050 |
inline valarray<_Tp>::~valarray() { |
| 2051 |
__clear(size()); |
| 2052 |
} |
| 2053 |
|
| 2054 |
template <class _Tp> |
| 2055 |
valarray<_Tp>& valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) { |
| 2056 |
size_t __n = __l - __f; |
| 2057 |
if (size() != __n) { |
| 2058 |
__clear(size()); |
| 2059 |
__begin_ = allocator<value_type>().allocate(__n); |
| 2060 |
__end_ = __begin_ + __n; |
| 2061 |
std::uninitialized_copy(__f, __l, __begin_); |
| 2062 |
} else { |
| 2063 |
std::copy(__f, __l, __begin_); |
| 2064 |
} |
| 2065 |
return *this; |
| 2066 |
} |
| 2067 |
|
| 2068 |
template <class _Tp> |
| 2069 |
valarray<_Tp>& valarray<_Tp>::operator=(const valarray& __v) { |
| 2070 |
if (this != std::addressof(__v)) |
| 2071 |
return __assign_range(__v.__begin_, __v.__end_); |
| 2072 |
return *this; |
| 2073 |
} |
| 2074 |
|
| 2075 |
template <class _Tp> |
| 2076 |
inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) { |
| 2077 |
std::fill(__begin_, __end_, __x); |
| 2078 |
return *this; |
| 2079 |
} |
| 2080 |
|
| 2081 |
template <class _Tp> |
| 2082 |
inline valarray<_Tp>& valarray<_Tp>::operator=(const slice_array<value_type>& __sa) { |
| 2083 |
value_type* __t = __begin_; |
| 2084 |
const value_type* __s = __sa.__vp_; |
| 2085 |
for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t) |
| 2086 |
*__t = *__s; |
| 2087 |
return *this; |
| 2088 |
} |
| 2089 |
|
| 2090 |
template <class _Tp> |
| 2091 |
inline valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<value_type>& __ga) { |
| 2092 |
typedef const size_t* _Ip; |
| 2093 |
value_type* __t = __begin_; |
| 2094 |
const value_type* __s = __ga.__vp_; |
| 2095 |
for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__t) |
| 2096 |
*__t = __s[*__i]; |
| 2097 |
return *this; |
| 2098 |
} |
| 2099 |
|
| 2100 |
template <class _Tp> |
| 2101 |
inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<value_type>& __ma) { |
| 2102 |
typedef const size_t* _Ip; |
| 2103 |
value_type* __t = __begin_; |
| 2104 |
const value_type* __s = __ma.__vp_; |
| 2105 |
for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__t) |
| 2106 |
*__t = __s[*__i]; |
| 2107 |
return *this; |
| 2108 |
} |
| 2109 |
|
| 2110 |
template <class _Tp> |
| 2111 |
inline valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) { |
| 2112 |
typedef const size_t* _Ip; |
| 2113 |
value_type* __t = __begin_; |
| 2114 |
const value_type* __s = __ia.__vp_; |
| 2115 |
for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__t) |
| 2116 |
*__t = __s[*__i]; |
| 2117 |
return *this; |
| 2118 |
} |
| 2119 |
|
| 2120 |
template <class _Tp> |
| 2121 |
template <class _ValExpr> |
| 2122 |
inline valarray<_Tp>& valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) { |
| 2123 |
size_t __n = __v.size(); |
| 2124 |
if (size() != __n) |
| 2125 |
resize(__n); |
| 2126 |
value_type* __t = __begin_; |
| 2127 |
for (size_t __i = 0; __i != __n; ++__t, ++__i) |
| 2128 |
*__t = __result_type(__v[__i]); |
| 2129 |
return *this; |
| 2130 |
} |
| 2131 |
|
| 2132 |
template <class _Tp> |
| 2133 |
inline __val_expr<__slice_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](slice __s) const { |
| 2134 |
return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this)); |
| 2135 |
} |
| 2136 |
|
| 2137 |
template <class _Tp> |
| 2138 |
inline slice_array<_Tp> valarray<_Tp>::operator[](slice __s) { |
| 2139 |
return slice_array<value_type>(__s, *this); |
| 2140 |
} |
| 2141 |
|
| 2142 |
template <class _Tp> |
| 2143 |
inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const gslice& __gs) const { |
| 2144 |
return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this)); |
| 2145 |
} |
| 2146 |
|
| 2147 |
template <class _Tp> |
| 2148 |
inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) { |
| 2149 |
return gslice_array<value_type>(__gs, *this); |
| 2150 |
} |
| 2151 |
|
| 2152 |
template <class _Tp> |
| 2153 |
inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const valarray<bool>& __vb) const { |
| 2154 |
return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this)); |
| 2155 |
} |
| 2156 |
|
| 2157 |
template <class _Tp> |
| 2158 |
inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __vb) { |
| 2159 |
return mask_array<value_type>(__vb, *this); |
| 2160 |
} |
| 2161 |
|
| 2162 |
template <class _Tp> |
| 2163 |
inline __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 2164 |
valarray<_Tp>::operator[](const valarray<size_t>& __vs) const { |
| 2165 |
return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this)); |
| 2166 |
} |
| 2167 |
|
| 2168 |
template <class _Tp> |
| 2169 |
inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray<size_t>& __vs) { |
| 2170 |
return indirect_array<value_type>(__vs, *this); |
| 2171 |
} |
| 2172 |
|
| 2173 |
template <class _Tp> |
| 2174 |
inline __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator+() const { |
| 2175 |
using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>; |
| 2176 |
return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this)); |
| 2177 |
} |
| 2178 |
|
| 2179 |
template <class _Tp> |
| 2180 |
inline __val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator-() const { |
| 2181 |
using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>; |
| 2182 |
return __val_expr<_Op>(_Op(negate<_Tp>(), *this)); |
| 2183 |
} |
| 2184 |
|
| 2185 |
template <class _Tp> |
| 2186 |
inline __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator~() const { |
| 2187 |
using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>; |
| 2188 |
return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this)); |
| 2189 |
} |
| 2190 |
|
| 2191 |
template <class _Tp> |
| 2192 |
inline __val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator!() const { |
| 2193 |
using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>; |
| 2194 |
return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this)); |
| 2195 |
} |
| 2196 |
|
| 2197 |
template <class _Tp> |
| 2198 |
inline valarray<_Tp>& valarray<_Tp>::operator*=(const value_type& __x) { |
| 2199 |
for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 2200 |
*__p *= __x; |
| 2201 |
return *this; |
| 2202 |
} |
| 2203 |
|
| 2204 |
template <class _Tp> |
| 2205 |
inline valarray<_Tp>& valarray<_Tp>::operator/=(const value_type& __x) { |
| 2206 |
for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 2207 |
*__p /= __x; |
| 2208 |
return *this; |
| 2209 |
} |
| 2210 |
|
| 2211 |
template <class _Tp> |
| 2212 |
inline valarray<_Tp>& valarray<_Tp>::operator%=(const value_type& __x) { |
| 2213 |
for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 2214 |
*__p %= __x; |
| 2215 |
return *this; |
| 2216 |
} |
| 2217 |
|
| 2218 |
template <class _Tp> |
| 2219 |
inline valarray<_Tp>& valarray<_Tp>::operator+=(const value_type& __x) { |
| 2220 |
for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 2221 |
*__p += __x; |
| 2222 |
return *this; |
| 2223 |
} |
| 2224 |
|
| 2225 |
template <class _Tp> |
| 2226 |
inline valarray<_Tp>& valarray<_Tp>::operator-=(const value_type& __x) { |
| 2227 |
for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 2228 |
*__p -= __x; |
| 2229 |
return *this; |
| 2230 |
} |
| 2231 |
|
| 2232 |
template <class _Tp> |
| 2233 |
inline valarray<_Tp>& valarray<_Tp>::operator^=(const value_type& __x) { |
| 2234 |
for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 2235 |
*__p ^= __x; |
| 2236 |
return *this; |
| 2237 |
} |
| 2238 |
|
| 2239 |
template <class _Tp> |
| 2240 |
inline valarray<_Tp>& valarray<_Tp>::operator&=(const value_type& __x) { |
| 2241 |
for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 2242 |
*__p &= __x; |
| 2243 |
return *this; |
| 2244 |
} |
| 2245 |
|
| 2246 |
template <class _Tp> |
| 2247 |
inline valarray<_Tp>& valarray<_Tp>::operator|=(const value_type& __x) { |
| 2248 |
for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 2249 |
*__p |= __x; |
| 2250 |
return *this; |
| 2251 |
} |
| 2252 |
|
| 2253 |
template <class _Tp> |
| 2254 |
inline valarray<_Tp>& valarray<_Tp>::operator<<=(const value_type& __x) { |
| 2255 |
for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 2256 |
*__p <<= __x; |
| 2257 |
return *this; |
| 2258 |
} |
| 2259 |
|
| 2260 |
template <class _Tp> |
| 2261 |
inline valarray<_Tp>& valarray<_Tp>::operator>>=(const value_type& __x) { |
| 2262 |
for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 2263 |
*__p >>= __x; |
| 2264 |
return *this; |
| 2265 |
} |
| 2266 |
|
| 2267 |
template <class _Tp> |
| 2268 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2269 |
inline valarray<_Tp>& valarray<_Tp>::operator*=(const _Expr& __v) { |
| 2270 |
size_t __i = 0; |
| 2271 |
for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2272 |
*__t *= std::__get(__v, __i); |
| 2273 |
return *this; |
| 2274 |
} |
| 2275 |
|
| 2276 |
template <class _Tp> |
| 2277 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2278 |
inline valarray<_Tp>& valarray<_Tp>::operator/=(const _Expr& __v) { |
| 2279 |
size_t __i = 0; |
| 2280 |
for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2281 |
*__t /= std::__get(__v, __i); |
| 2282 |
return *this; |
| 2283 |
} |
| 2284 |
|
| 2285 |
template <class _Tp> |
| 2286 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2287 |
inline valarray<_Tp>& valarray<_Tp>::operator%=(const _Expr& __v) { |
| 2288 |
size_t __i = 0; |
| 2289 |
for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2290 |
*__t %= std::__get(__v, __i); |
| 2291 |
return *this; |
| 2292 |
} |
| 2293 |
|
| 2294 |
template <class _Tp> |
| 2295 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2296 |
inline valarray<_Tp>& valarray<_Tp>::operator+=(const _Expr& __v) { |
| 2297 |
size_t __i = 0; |
| 2298 |
for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2299 |
*__t += std::__get(__v, __i); |
| 2300 |
return *this; |
| 2301 |
} |
| 2302 |
|
| 2303 |
template <class _Tp> |
| 2304 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2305 |
inline valarray<_Tp>& valarray<_Tp>::operator-=(const _Expr& __v) { |
| 2306 |
size_t __i = 0; |
| 2307 |
for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2308 |
*__t -= std::__get(__v, __i); |
| 2309 |
return *this; |
| 2310 |
} |
| 2311 |
|
| 2312 |
template <class _Tp> |
| 2313 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2314 |
inline valarray<_Tp>& valarray<_Tp>::operator^=(const _Expr& __v) { |
| 2315 |
size_t __i = 0; |
| 2316 |
for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2317 |
*__t ^= std::__get(__v, __i); |
| 2318 |
return *this; |
| 2319 |
} |
| 2320 |
|
| 2321 |
template <class _Tp> |
| 2322 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2323 |
inline valarray<_Tp>& valarray<_Tp>::operator|=(const _Expr& __v) { |
| 2324 |
size_t __i = 0; |
| 2325 |
for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2326 |
*__t |= std::__get(__v, __i); |
| 2327 |
return *this; |
| 2328 |
} |
| 2329 |
|
| 2330 |
template <class _Tp> |
| 2331 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2332 |
inline valarray<_Tp>& valarray<_Tp>::operator&=(const _Expr& __v) { |
| 2333 |
size_t __i = 0; |
| 2334 |
for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2335 |
*__t &= std::__get(__v, __i); |
| 2336 |
return *this; |
| 2337 |
} |
| 2338 |
|
| 2339 |
template <class _Tp> |
| 2340 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2341 |
inline valarray<_Tp>& valarray<_Tp>::operator<<=(const _Expr& __v) { |
| 2342 |
size_t __i = 0; |
| 2343 |
for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2344 |
*__t <<= std::__get(__v, __i); |
| 2345 |
return *this; |
| 2346 |
} |
| 2347 |
|
| 2348 |
template <class _Tp> |
| 2349 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
| 2350 |
inline valarray<_Tp>& valarray<_Tp>::operator>>=(const _Expr& __v) { |
| 2351 |
size_t __i = 0; |
| 2352 |
for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
| 2353 |
*__t >>= std::__get(__v, __i); |
| 2354 |
return *this; |
| 2355 |
} |
| 2356 |
|
| 2357 |
template <class _Tp> |
| 2358 |
inline void valarray<_Tp>::swap(valarray& __v) _NOEXCEPT { |
| 2359 |
std::swap(__begin_, __v.__begin_); |
| 2360 |
std::swap(__end_, __v.__end_); |
| 2361 |
} |
| 2362 |
|
| 2363 |
template <class _Tp> |
| 2364 |
inline _Tp valarray<_Tp>::sum() const { |
| 2365 |
if (__begin_ == __end_) |
| 2366 |
return value_type(); |
| 2367 |
const value_type* __p = __begin_; |
| 2368 |
_Tp __r = *__p; |
| 2369 |
for (++__p; __p != __end_; ++__p) |
| 2370 |
__r += *__p; |
| 2371 |
return __r; |
| 2372 |
} |
| 2373 |
|
| 2374 |
template <class _Tp> |
| 2375 |
inline _Tp valarray<_Tp>::min() const { |
| 2376 |
if (__begin_ == __end_) |
| 2377 |
return value_type(); |
| 2378 |
return *std::min_element(__begin_, __end_); |
| 2379 |
} |
| 2380 |
|
| 2381 |
template <class _Tp> |
| 2382 |
inline _Tp valarray<_Tp>::max() const { |
| 2383 |
if (__begin_ == __end_) |
| 2384 |
return value_type(); |
| 2385 |
return *std::max_element(__begin_, __end_); |
| 2386 |
} |
| 2387 |
|
| 2388 |
template <class _Tp> |
| 2389 |
valarray<_Tp> valarray<_Tp>::shift(int __i) const { |
| 2390 |
valarray<value_type> __r; |
| 2391 |
size_t __n = size(); |
| 2392 |
if (__n) { |
| 2393 |
__r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
| 2394 |
const value_type* __sb; |
| 2395 |
value_type* __tb; |
| 2396 |
value_type* __te; |
| 2397 |
if (__i >= 0) { |
| 2398 |
__i = std::min(__i, static_cast<int>(__n)); |
| 2399 |
__sb = __begin_ + __i; |
| 2400 |
__tb = __r.__begin_; |
| 2401 |
__te = __r.__begin_ + (__n - __i); |
| 2402 |
} else { |
| 2403 |
__i = std::min(-__i, static_cast<int>(__n)); |
| 2404 |
__sb = __begin_; |
| 2405 |
__tb = __r.__begin_ + __i; |
| 2406 |
__te = __r.__begin_ + __n; |
| 2407 |
} |
| 2408 |
for (; __r.__end_ != __tb; ++__r.__end_) |
| 2409 |
::new ((void*)__r.__end_) value_type(); |
| 2410 |
for (; __r.__end_ != __te; ++__r.__end_, ++__sb) |
| 2411 |
::new ((void*)__r.__end_) value_type(*__sb); |
| 2412 |
for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_) |
| 2413 |
::new ((void*)__r.__end_) value_type(); |
| 2414 |
} |
| 2415 |
return __r; |
| 2416 |
} |
| 2417 |
|
| 2418 |
template <class _Tp> |
| 2419 |
valarray<_Tp> valarray<_Tp>::cshift(int __i) const { |
| 2420 |
valarray<value_type> __r; |
| 2421 |
size_t __n = size(); |
| 2422 |
if (__n) { |
| 2423 |
__r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
| 2424 |
__i %= static_cast<int>(__n); |
| 2425 |
const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i; |
| 2426 |
for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s) |
| 2427 |
::new ((void*)__r.__end_) value_type(*__s); |
| 2428 |
for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s) |
| 2429 |
::new ((void*)__r.__end_) value_type(*__s); |
| 2430 |
} |
| 2431 |
return __r; |
| 2432 |
} |
| 2433 |
|
| 2434 |
template <class _Tp> |
| 2435 |
valarray<_Tp> valarray<_Tp>::apply(value_type __f(value_type)) const { |
| 2436 |
valarray<value_type> __r; |
| 2437 |
size_t __n = size(); |
| 2438 |
if (__n) { |
| 2439 |
__r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
| 2440 |
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
| 2441 |
::new ((void*)__r.__end_) value_type(__f(*__p)); |
| 2442 |
} |
| 2443 |
return __r; |
| 2444 |
} |
| 2445 |
|
| 2446 |
template <class _Tp> |
| 2447 |
valarray<_Tp> valarray<_Tp>::apply(value_type __f(const value_type&)) const { |
| 2448 |
valarray<value_type> __r; |
| 2449 |
size_t __n = size(); |
| 2450 |
if (__n) { |
| 2451 |
__r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
| 2452 |
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
| 2453 |
::new ((void*)__r.__end_) value_type(__f(*__p)); |
| 2454 |
} |
| 2455 |
return __r; |
| 2456 |
} |
| 2457 |
|
| 2458 |
template <class _Tp> |
| 2459 |
inline void valarray<_Tp>::__clear(size_t __capacity) { |
| 2460 |
if (__begin_ != nullptr) { |
| 2461 |
while (__end_ != __begin_) |
| 2462 |
(--__end_)->~value_type(); |
| 2463 |
allocator<value_type>().deallocate(__begin_, __capacity); |
| 2464 |
__begin_ = __end_ = nullptr; |
| 2465 |
} |
| 2466 |
} |
| 2467 |
|
| 2468 |
template <class _Tp> |
| 2469 |
void valarray<_Tp>::resize(size_t __n, value_type __x) { |
| 2470 |
__clear(size()); |
| 2471 |
if (__n) { |
| 2472 |
__begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2473 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 2474 |
try { |
| 2475 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 2476 |
for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
| 2477 |
::new ((void*)__end_) value_type(__x); |
| 2478 |
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS |
| 2479 |
} catch (...) { |
| 2480 |
__clear(__n); |
| 2481 |
throw; |
| 2482 |
} |
| 2483 |
#endif // _LIBCPP_HAS_NO_EXCEPTIONS |
| 2484 |
} |
| 2485 |
} |
| 2486 |
|
| 2487 |
template <class _Tp> |
| 2488 |
inline _LIBCPP_HIDE_FROM_ABI void swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT { |
| 2489 |
__x.swap(__y); |
| 2490 |
} |
| 2491 |
|
| 2492 |
template <class _Expr1, |
| 2493 |
class _Expr2, |
| 2494 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2495 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2496 |
operator*(const _Expr1& __x, const _Expr2& __y) { |
| 2497 |
typedef typename _Expr1::value_type value_type; |
| 2498 |
typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op; |
| 2499 |
return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y)); |
| 2500 |
} |
| 2501 |
|
| 2502 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2503 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2504 |
__val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2505 |
operator*(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2506 |
typedef typename _Expr::value_type value_type; |
| 2507 |
typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2508 |
return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2509 |
} |
| 2510 |
|
| 2511 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2512 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2513 |
__val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2514 |
operator*(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2515 |
typedef typename _Expr::value_type value_type; |
| 2516 |
typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2517 |
return __val_expr<_Op>(_Op(multiplies<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2518 |
} |
| 2519 |
|
| 2520 |
template <class _Expr1, |
| 2521 |
class _Expr2, |
| 2522 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2523 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2524 |
operator/(const _Expr1& __x, const _Expr2& __y) { |
| 2525 |
typedef typename _Expr1::value_type value_type; |
| 2526 |
typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op; |
| 2527 |
return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y)); |
| 2528 |
} |
| 2529 |
|
| 2530 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2531 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2532 |
__val_expr<_BinaryOp<divides<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2533 |
operator/(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2534 |
typedef typename _Expr::value_type value_type; |
| 2535 |
typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2536 |
return __val_expr<_Op>(_Op(divides<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2537 |
} |
| 2538 |
|
| 2539 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2540 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2541 |
__val_expr<_BinaryOp<divides<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2542 |
operator/(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2543 |
typedef typename _Expr::value_type value_type; |
| 2544 |
typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2545 |
return __val_expr<_Op>(_Op(divides<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2546 |
} |
| 2547 |
|
| 2548 |
template <class _Expr1, |
| 2549 |
class _Expr2, |
| 2550 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2551 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2552 |
operator%(const _Expr1& __x, const _Expr2& __y) { |
| 2553 |
typedef typename _Expr1::value_type value_type; |
| 2554 |
typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op; |
| 2555 |
return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y)); |
| 2556 |
} |
| 2557 |
|
| 2558 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2559 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2560 |
__val_expr<_BinaryOp<modulus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2561 |
operator%(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2562 |
typedef typename _Expr::value_type value_type; |
| 2563 |
typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2564 |
return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2565 |
} |
| 2566 |
|
| 2567 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2568 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2569 |
__val_expr<_BinaryOp<modulus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2570 |
operator%(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2571 |
typedef typename _Expr::value_type value_type; |
| 2572 |
typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2573 |
return __val_expr<_Op>(_Op(modulus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2574 |
} |
| 2575 |
|
| 2576 |
template <class _Expr1, |
| 2577 |
class _Expr2, |
| 2578 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2579 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2580 |
operator+(const _Expr1& __x, const _Expr2& __y) { |
| 2581 |
typedef typename _Expr1::value_type value_type; |
| 2582 |
typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op; |
| 2583 |
return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y)); |
| 2584 |
} |
| 2585 |
|
| 2586 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2587 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2588 |
__val_expr<_BinaryOp<plus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2589 |
operator+(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2590 |
typedef typename _Expr::value_type value_type; |
| 2591 |
typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2592 |
return __val_expr<_Op>(_Op(plus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2593 |
} |
| 2594 |
|
| 2595 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2596 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2597 |
__val_expr<_BinaryOp<plus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2598 |
operator+(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2599 |
typedef typename _Expr::value_type value_type; |
| 2600 |
typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2601 |
return __val_expr<_Op>(_Op(plus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2602 |
} |
| 2603 |
|
| 2604 |
template <class _Expr1, |
| 2605 |
class _Expr2, |
| 2606 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2607 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2608 |
operator-(const _Expr1& __x, const _Expr2& __y) { |
| 2609 |
typedef typename _Expr1::value_type value_type; |
| 2610 |
typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op; |
| 2611 |
return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y)); |
| 2612 |
} |
| 2613 |
|
| 2614 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2615 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2616 |
__val_expr<_BinaryOp<minus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2617 |
operator-(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2618 |
typedef typename _Expr::value_type value_type; |
| 2619 |
typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2620 |
return __val_expr<_Op>(_Op(minus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2621 |
} |
| 2622 |
|
| 2623 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2624 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2625 |
__val_expr<_BinaryOp<minus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2626 |
operator-(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2627 |
typedef typename _Expr::value_type value_type; |
| 2628 |
typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2629 |
return __val_expr<_Op>(_Op(minus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2630 |
} |
| 2631 |
|
| 2632 |
template <class _Expr1, |
| 2633 |
class _Expr2, |
| 2634 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2635 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2636 |
operator^(const _Expr1& __x, const _Expr2& __y) { |
| 2637 |
typedef typename _Expr1::value_type value_type; |
| 2638 |
typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op; |
| 2639 |
return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y)); |
| 2640 |
} |
| 2641 |
|
| 2642 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2643 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2644 |
__val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2645 |
operator^(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2646 |
typedef typename _Expr::value_type value_type; |
| 2647 |
typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2648 |
return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2649 |
} |
| 2650 |
|
| 2651 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2652 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2653 |
__val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2654 |
operator^(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2655 |
typedef typename _Expr::value_type value_type; |
| 2656 |
typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2657 |
return __val_expr<_Op>(_Op(bit_xor<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2658 |
} |
| 2659 |
|
| 2660 |
template <class _Expr1, |
| 2661 |
class _Expr2, |
| 2662 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2663 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2664 |
operator&(const _Expr1& __x, const _Expr2& __y) { |
| 2665 |
typedef typename _Expr1::value_type value_type; |
| 2666 |
typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op; |
| 2667 |
return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y)); |
| 2668 |
} |
| 2669 |
|
| 2670 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2671 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2672 |
__val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2673 |
operator&(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2674 |
typedef typename _Expr::value_type value_type; |
| 2675 |
typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2676 |
return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2677 |
} |
| 2678 |
|
| 2679 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2680 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2681 |
__val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2682 |
operator&(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2683 |
typedef typename _Expr::value_type value_type; |
| 2684 |
typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2685 |
return __val_expr<_Op>(_Op(bit_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2686 |
} |
| 2687 |
|
| 2688 |
template <class _Expr1, |
| 2689 |
class _Expr2, |
| 2690 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2691 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2692 |
operator|(const _Expr1& __x, const _Expr2& __y) { |
| 2693 |
typedef typename _Expr1::value_type value_type; |
| 2694 |
typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op; |
| 2695 |
return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y)); |
| 2696 |
} |
| 2697 |
|
| 2698 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2699 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2700 |
__val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2701 |
operator|(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2702 |
typedef typename _Expr::value_type value_type; |
| 2703 |
typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2704 |
return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2705 |
} |
| 2706 |
|
| 2707 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2708 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2709 |
__val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2710 |
operator|(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2711 |
typedef typename _Expr::value_type value_type; |
| 2712 |
typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2713 |
return __val_expr<_Op>(_Op(bit_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2714 |
} |
| 2715 |
|
| 2716 |
template <class _Expr1, |
| 2717 |
class _Expr2, |
| 2718 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2719 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2720 |
operator<<(const _Expr1& __x, const _Expr2& __y) { |
| 2721 |
typedef typename _Expr1::value_type value_type; |
| 2722 |
typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op; |
| 2723 |
return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y)); |
| 2724 |
} |
| 2725 |
|
| 2726 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2727 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2728 |
__val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2729 |
operator<<(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2730 |
typedef typename _Expr::value_type value_type; |
| 2731 |
typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2732 |
return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2733 |
} |
| 2734 |
|
| 2735 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2736 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2737 |
__val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2738 |
operator<<(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2739 |
typedef typename _Expr::value_type value_type; |
| 2740 |
typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2741 |
return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2742 |
} |
| 2743 |
|
| 2744 |
template <class _Expr1, |
| 2745 |
class _Expr2, |
| 2746 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2747 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2748 |
operator>>(const _Expr1& __x, const _Expr2& __y) { |
| 2749 |
typedef typename _Expr1::value_type value_type; |
| 2750 |
typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op; |
| 2751 |
return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y)); |
| 2752 |
} |
| 2753 |
|
| 2754 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2755 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr< |
| 2756 |
_BinaryOp<__bit_shift_right<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2757 |
operator>>(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2758 |
typedef typename _Expr::value_type value_type; |
| 2759 |
typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2760 |
return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2761 |
} |
| 2762 |
|
| 2763 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2764 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2765 |
__val_expr< _BinaryOp<__bit_shift_right<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2766 |
operator>>(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2767 |
typedef typename _Expr::value_type value_type; |
| 2768 |
typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2769 |
return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2770 |
} |
| 2771 |
|
| 2772 |
template <class _Expr1, |
| 2773 |
class _Expr2, |
| 2774 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2775 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2776 |
operator&&(const _Expr1& __x, const _Expr2& __y) { |
| 2777 |
typedef typename _Expr1::value_type value_type; |
| 2778 |
typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op; |
| 2779 |
return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y)); |
| 2780 |
} |
| 2781 |
|
| 2782 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2783 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2784 |
__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2785 |
operator&&(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2786 |
typedef typename _Expr::value_type value_type; |
| 2787 |
typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2788 |
return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2789 |
} |
| 2790 |
|
| 2791 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2792 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2793 |
__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2794 |
operator&&(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2795 |
typedef typename _Expr::value_type value_type; |
| 2796 |
typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2797 |
return __val_expr<_Op>(_Op(logical_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2798 |
} |
| 2799 |
|
| 2800 |
template <class _Expr1, |
| 2801 |
class _Expr2, |
| 2802 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2803 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2804 |
operator||(const _Expr1& __x, const _Expr2& __y) { |
| 2805 |
typedef typename _Expr1::value_type value_type; |
| 2806 |
typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op; |
| 2807 |
return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y)); |
| 2808 |
} |
| 2809 |
|
| 2810 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2811 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2812 |
__val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2813 |
operator||(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2814 |
typedef typename _Expr::value_type value_type; |
| 2815 |
typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2816 |
return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2817 |
} |
| 2818 |
|
| 2819 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2820 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2821 |
__val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2822 |
operator||(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2823 |
typedef typename _Expr::value_type value_type; |
| 2824 |
typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2825 |
return __val_expr<_Op>(_Op(logical_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2826 |
} |
| 2827 |
|
| 2828 |
template <class _Expr1, |
| 2829 |
class _Expr2, |
| 2830 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2831 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2832 |
operator==(const _Expr1& __x, const _Expr2& __y) { |
| 2833 |
typedef typename _Expr1::value_type value_type; |
| 2834 |
typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op; |
| 2835 |
return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y)); |
| 2836 |
} |
| 2837 |
|
| 2838 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2839 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2840 |
__val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2841 |
operator==(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2842 |
typedef typename _Expr::value_type value_type; |
| 2843 |
typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2844 |
return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2845 |
} |
| 2846 |
|
| 2847 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2848 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2849 |
__val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2850 |
operator==(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2851 |
typedef typename _Expr::value_type value_type; |
| 2852 |
typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2853 |
return __val_expr<_Op>(_Op(equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2854 |
} |
| 2855 |
|
| 2856 |
template <class _Expr1, |
| 2857 |
class _Expr2, |
| 2858 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2859 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2860 |
operator!=(const _Expr1& __x, const _Expr2& __y) { |
| 2861 |
typedef typename _Expr1::value_type value_type; |
| 2862 |
typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op; |
| 2863 |
return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y)); |
| 2864 |
} |
| 2865 |
|
| 2866 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2867 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2868 |
__val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2869 |
operator!=(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2870 |
typedef typename _Expr::value_type value_type; |
| 2871 |
typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2872 |
return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2873 |
} |
| 2874 |
|
| 2875 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2876 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2877 |
__val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2878 |
operator!=(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2879 |
typedef typename _Expr::value_type value_type; |
| 2880 |
typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2881 |
return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2882 |
} |
| 2883 |
|
| 2884 |
template <class _Expr1, |
| 2885 |
class _Expr2, |
| 2886 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2887 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2888 |
operator<(const _Expr1& __x, const _Expr2& __y) { |
| 2889 |
typedef typename _Expr1::value_type value_type; |
| 2890 |
typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op; |
| 2891 |
return __val_expr<_Op>(_Op(less<value_type>(), __x, __y)); |
| 2892 |
} |
| 2893 |
|
| 2894 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2895 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2896 |
__val_expr<_BinaryOp<less<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2897 |
operator<(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2898 |
typedef typename _Expr::value_type value_type; |
| 2899 |
typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2900 |
return __val_expr<_Op>(_Op(less<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2901 |
} |
| 2902 |
|
| 2903 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2904 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2905 |
__val_expr<_BinaryOp<less<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2906 |
operator<(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2907 |
typedef typename _Expr::value_type value_type; |
| 2908 |
typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2909 |
return __val_expr<_Op>(_Op(less<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2910 |
} |
| 2911 |
|
| 2912 |
template <class _Expr1, |
| 2913 |
class _Expr2, |
| 2914 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2915 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2916 |
operator>(const _Expr1& __x, const _Expr2& __y) { |
| 2917 |
typedef typename _Expr1::value_type value_type; |
| 2918 |
typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op; |
| 2919 |
return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y)); |
| 2920 |
} |
| 2921 |
|
| 2922 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2923 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2924 |
__val_expr<_BinaryOp<greater<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2925 |
operator>(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2926 |
typedef typename _Expr::value_type value_type; |
| 2927 |
typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2928 |
return __val_expr<_Op>(_Op(greater<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2929 |
} |
| 2930 |
|
| 2931 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2932 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2933 |
__val_expr<_BinaryOp<greater<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2934 |
operator>(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2935 |
typedef typename _Expr::value_type value_type; |
| 2936 |
typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2937 |
return __val_expr<_Op>(_Op(greater<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2938 |
} |
| 2939 |
|
| 2940 |
template <class _Expr1, |
| 2941 |
class _Expr2, |
| 2942 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2943 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2944 |
operator<=(const _Expr1& __x, const _Expr2& __y) { |
| 2945 |
typedef typename _Expr1::value_type value_type; |
| 2946 |
typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op; |
| 2947 |
return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y)); |
| 2948 |
} |
| 2949 |
|
| 2950 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2951 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2952 |
__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2953 |
operator<=(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2954 |
typedef typename _Expr::value_type value_type; |
| 2955 |
typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2956 |
return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2957 |
} |
| 2958 |
|
| 2959 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2960 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2961 |
__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2962 |
operator<=(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2963 |
typedef typename _Expr::value_type value_type; |
| 2964 |
typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2965 |
return __val_expr<_Op>(_Op(less_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2966 |
} |
| 2967 |
|
| 2968 |
template <class _Expr1, |
| 2969 |
class _Expr2, |
| 2970 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 2971 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 2972 |
operator>=(const _Expr1& __x, const _Expr2& __y) { |
| 2973 |
typedef typename _Expr1::value_type value_type; |
| 2974 |
typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op; |
| 2975 |
return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y)); |
| 2976 |
} |
| 2977 |
|
| 2978 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2979 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2980 |
__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 2981 |
operator>=(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 2982 |
typedef typename _Expr::value_type value_type; |
| 2983 |
typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 2984 |
return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 2985 |
} |
| 2986 |
|
| 2987 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2988 |
inline _LIBCPP_HIDE_FROM_ABI |
| 2989 |
__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 2990 |
operator>=(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 2991 |
typedef typename _Expr::value_type value_type; |
| 2992 |
typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 2993 |
return __val_expr<_Op>(_Op(greater_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 2994 |
} |
| 2995 |
|
| 2996 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 2997 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> > |
| 2998 |
abs(const _Expr& __x) { |
| 2999 |
typedef typename _Expr::value_type value_type; |
| 3000 |
typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op; |
| 3001 |
return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x)); |
| 3002 |
} |
| 3003 |
|
| 3004 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3005 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> > |
| 3006 |
acos(const _Expr& __x) { |
| 3007 |
typedef typename _Expr::value_type value_type; |
| 3008 |
typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op; |
| 3009 |
return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x)); |
| 3010 |
} |
| 3011 |
|
| 3012 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3013 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> > |
| 3014 |
asin(const _Expr& __x) { |
| 3015 |
typedef typename _Expr::value_type value_type; |
| 3016 |
typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op; |
| 3017 |
return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x)); |
| 3018 |
} |
| 3019 |
|
| 3020 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3021 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> > |
| 3022 |
atan(const _Expr& __x) { |
| 3023 |
typedef typename _Expr::value_type value_type; |
| 3024 |
typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op; |
| 3025 |
return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x)); |
| 3026 |
} |
| 3027 |
|
| 3028 |
template <class _Expr1, |
| 3029 |
class _Expr2, |
| 3030 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 3031 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3032 |
atan2(const _Expr1& __x, const _Expr2& __y) { |
| 3033 |
typedef typename _Expr1::value_type value_type; |
| 3034 |
typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op; |
| 3035 |
return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y)); |
| 3036 |
} |
| 3037 |
|
| 3038 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3039 |
inline _LIBCPP_HIDE_FROM_ABI |
| 3040 |
__val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3041 |
atan2(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3042 |
typedef typename _Expr::value_type value_type; |
| 3043 |
typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3044 |
return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3045 |
} |
| 3046 |
|
| 3047 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3048 |
inline _LIBCPP_HIDE_FROM_ABI |
| 3049 |
__val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3050 |
atan2(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3051 |
typedef typename _Expr::value_type value_type; |
| 3052 |
typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3053 |
return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 3054 |
} |
| 3055 |
|
| 3056 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3057 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> > |
| 3058 |
cos(const _Expr& __x) { |
| 3059 |
typedef typename _Expr::value_type value_type; |
| 3060 |
typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op; |
| 3061 |
return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x)); |
| 3062 |
} |
| 3063 |
|
| 3064 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3065 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> > |
| 3066 |
cosh(const _Expr& __x) { |
| 3067 |
typedef typename _Expr::value_type value_type; |
| 3068 |
typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op; |
| 3069 |
return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x)); |
| 3070 |
} |
| 3071 |
|
| 3072 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3073 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> > |
| 3074 |
exp(const _Expr& __x) { |
| 3075 |
typedef typename _Expr::value_type value_type; |
| 3076 |
typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op; |
| 3077 |
return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x)); |
| 3078 |
} |
| 3079 |
|
| 3080 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3081 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> > |
| 3082 |
log(const _Expr& __x) { |
| 3083 |
typedef typename _Expr::value_type value_type; |
| 3084 |
typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op; |
| 3085 |
return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x)); |
| 3086 |
} |
| 3087 |
|
| 3088 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3089 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> > |
| 3090 |
log10(const _Expr& __x) { |
| 3091 |
typedef typename _Expr::value_type value_type; |
| 3092 |
typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op; |
| 3093 |
return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x)); |
| 3094 |
} |
| 3095 |
|
| 3096 |
template <class _Expr1, |
| 3097 |
class _Expr2, |
| 3098 |
__enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 3099 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3100 |
pow(const _Expr1& __x, const _Expr2& __y) { |
| 3101 |
typedef typename _Expr1::value_type value_type; |
| 3102 |
typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op; |
| 3103 |
return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y)); |
| 3104 |
} |
| 3105 |
|
| 3106 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3107 |
inline _LIBCPP_HIDE_FROM_ABI |
| 3108 |
__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3109 |
pow(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3110 |
typedef typename _Expr::value_type value_type; |
| 3111 |
typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3112 |
return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3113 |
} |
| 3114 |
|
| 3115 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3116 |
inline _LIBCPP_HIDE_FROM_ABI |
| 3117 |
__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3118 |
pow(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3119 |
typedef typename _Expr::value_type value_type; |
| 3120 |
typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3121 |
return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 3122 |
} |
| 3123 |
|
| 3124 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3125 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> > |
| 3126 |
sin(const _Expr& __x) { |
| 3127 |
typedef typename _Expr::value_type value_type; |
| 3128 |
typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op; |
| 3129 |
return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x)); |
| 3130 |
} |
| 3131 |
|
| 3132 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3133 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> > |
| 3134 |
sinh(const _Expr& __x) { |
| 3135 |
typedef typename _Expr::value_type value_type; |
| 3136 |
typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op; |
| 3137 |
return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x)); |
| 3138 |
} |
| 3139 |
|
| 3140 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3141 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> > |
| 3142 |
sqrt(const _Expr& __x) { |
| 3143 |
typedef typename _Expr::value_type value_type; |
| 3144 |
typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op; |
| 3145 |
return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x)); |
| 3146 |
} |
| 3147 |
|
| 3148 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3149 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> > |
| 3150 |
tan(const _Expr& __x) { |
| 3151 |
typedef typename _Expr::value_type value_type; |
| 3152 |
typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op; |
| 3153 |
return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x)); |
| 3154 |
} |
| 3155 |
|
| 3156 |
template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3157 |
inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> > |
| 3158 |
tanh(const _Expr& __x) { |
| 3159 |
typedef typename _Expr::value_type value_type; |
| 3160 |
typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op; |
| 3161 |
return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x)); |
| 3162 |
} |
| 3163 |
|
| 3164 |
template <class _Tp> |
| 3165 |
inline _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v) { |
| 3166 |
return __v.__begin_; |
| 3167 |
} |
| 3168 |
|
| 3169 |
template <class _Tp> |
| 3170 |
inline _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v) { |
| 3171 |
return __v.__begin_; |
| 3172 |
} |
| 3173 |
|
| 3174 |
template <class _Tp> |
| 3175 |
inline _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v) { |
| 3176 |
return __v.__end_; |
| 3177 |
} |
| 3178 |
|
| 3179 |
template <class _Tp> |
| 3180 |
inline _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v) { |
| 3181 |
return __v.__end_; |
| 3182 |
} |
| 3183 |
|
| 3184 |
_LIBCPP_END_NAMESPACE_STD |
| 3185 |
|
| 3186 |
_LIBCPP_POP_MACROS |
| 3187 |
|
| 3188 |
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) |
| 3189 |
# include <__cxx03/algorithm> |
| 3190 |
# include <__cxx03/cstdlib> |
| 3191 |
# include <__cxx03/cstring> |
| 3192 |
# include <__cxx03/functional> |
| 3193 |
# include <__cxx03/stdexcept> |
| 3194 |
# include <__cxx03/type_traits> |
| 3195 |
#endif |
| 3196 |
|
| 3197 |
#endif // _LIBCPP___CXX03_VALARRAY |