diff options
Diffstat (limited to 'contrib/llvm-project/libcxx/include/valarray')
| -rw-r--r-- | contrib/llvm-project/libcxx/include/valarray | 108 |
1 files changed, 61 insertions, 47 deletions
diff --git a/contrib/llvm-project/libcxx/include/valarray b/contrib/llvm-project/libcxx/include/valarray index 92521ed3819c..09a7c9016c99 100644 --- a/contrib/llvm-project/libcxx/include/valarray +++ b/contrib/llvm-project/libcxx/include/valarray @@ -116,6 +116,8 @@ public: size_t start() const; size_t size() const; size_t stride() const; + + friend bool operator==(const slice& x, const slice& y); // since C++20 }; template <class T> @@ -351,8 +353,10 @@ template <class T> unspecified2 end(const valarray<T>& v); #include <__assert> // all public C++ headers provide the assertion handler #include <__config> #include <__functional/operations.h> +#include <__memory/addressof.h> #include <__memory/allocator.h> #include <__memory/uninitialized_algorithms.h> +#include <__type_traits/decay.h> #include <__type_traits/remove_reference.h> #include <__utility/move.h> #include <__utility/swap.h> @@ -400,10 +404,18 @@ public: _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;} _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;} + +#if _LIBCPP_STD_VER >= 20 + + _LIBCPP_HIDE_FROM_ABI friend bool operator==(const slice& __x, const slice& __y) { + return __x.start() == __y.start() && __x.size() == __y.size() && __x.stride() == __y.stride(); + } + +#endif }; template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array; -class _LIBCPP_TYPE_VIS gslice; +class _LIBCPP_EXPORTED_FROM_ABI gslice; template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array; template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array; template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array; @@ -432,7 +444,7 @@ template <class _Op, class _A0> struct _UnaryOp { typedef typename _Op::__result_type __result_type; - typedef typename decay<__result_type>::type value_type; + using value_type = __decay_t<__result_type>; _Op __op_; _A0 __a0_; @@ -451,7 +463,7 @@ template <class _Op, class _A0, class _A1> struct _BinaryOp { typedef typename _Op::__result_type __result_type; - typedef typename decay<__result_type>::type value_type; + using value_type = __decay_t<__result_type>; _Op __op_; _A0 __a0_; @@ -1104,18 +1116,18 @@ private: valarray& __assign_range(const value_type* __f, const value_type* __l); }; -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 template<class _Tp, size_t _Size> valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>; #endif -extern template _LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t); +extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t); template <class _Op, class _Tp> struct _UnaryOp<_Op, valarray<_Tp> > { typedef typename _Op::__result_type __result_type; - typedef typename decay<__result_type>::type value_type; + using value_type = __decay_t<__result_type>; _Op __op_; const valarray<_Tp>& __a0_; @@ -1134,7 +1146,7 @@ template <class _Op, class _Tp, class _A1> struct _BinaryOp<_Op, valarray<_Tp>, _A1> { typedef typename _Op::__result_type __result_type; - typedef typename decay<__result_type>::type value_type; + using value_type = __decay_t<__result_type>; _Op __op_; const valarray<_Tp>& __a0_; @@ -1155,7 +1167,7 @@ template <class _Op, class _A0, class _Tp> struct _BinaryOp<_Op, _A0, valarray<_Tp> > { typedef typename _Op::__result_type __result_type; - typedef typename decay<__result_type>::type value_type; + using value_type = __decay_t<__result_type>; _Op __op_; _A0 __a0_; @@ -1176,7 +1188,7 @@ template <class _Op, class _Tp> struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > { typedef typename _Op::__result_type __result_type; - typedef typename decay<__result_type>::type value_type; + using value_type = __decay_t<__result_type>; _Op __op_; const valarray<_Tp>& __a0_; @@ -1326,7 +1338,6 @@ private: {} template <class> friend class valarray; - template <class> friend class sliceExpr; }; template <class _Tp> @@ -1527,7 +1538,7 @@ slice_array<_Tp>::operator=(const value_type& __x) const // gslice -class _LIBCPP_TYPE_VIS gslice +class _LIBCPP_EXPORTED_FROM_ABI gslice { valarray<size_t> __size_; valarray<size_t> __stride_; @@ -2818,20 +2829,20 @@ valarray<_Tp>::valarray(size_t __n) if (__n) { __begin_ = __end_ = allocator<value_type>().allocate(__n); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) ::new ((void*)__end_) value_type(); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -2852,20 +2863,20 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n) if (__n) { __begin_ = __end_ = allocator<value_type>().allocate(__n); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) ::new ((void*)__end_) value_type(*__p); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -2877,20 +2888,20 @@ valarray<_Tp>::valarray(const valarray& __v) if (__v.size()) { __begin_ = __end_ = allocator<value_type>().allocate(__v.size()); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) ::new ((void*)__end_) value_type(*__p); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __clear(__v.size()); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -2914,21 +2925,21 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il) if (__n) { __begin_ = __end_ = allocator<value_type>().allocate(__n); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS size_t __n_left = __n; for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) ::new ((void*)__end_) value_type(*__p); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -2943,21 +2954,21 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa) if (__n) { __begin_ = __end_ = allocator<value_type>().allocate(__n); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS size_t __n_left = __n; for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) ::new ((void*)__end_) value_type(*__p); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -2970,23 +2981,23 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) if (__n) { __begin_ = __end_ = allocator<value_type>().allocate(__n); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef const size_t* _Ip; const value_type* __s = __ga.__vp_; for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_) ::new ((void*)__end_) value_type(__s[*__i]); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -2999,23 +3010,23 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma) if (__n) { __begin_ = __end_ = allocator<value_type>().allocate(__n); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef const size_t* _Ip; const value_type* __s = __ma.__vp_; for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_) ::new ((void*)__end_) value_type(__s[*__i]); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -3028,23 +3039,23 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) if (__n) { __begin_ = __end_ = allocator<value_type>().allocate(__n); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef const size_t* _Ip; const value_type* __s = __ia.__vp_; for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_) ::new ((void*)__end_) value_type(__s[*__i]); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -3753,20 +3764,20 @@ valarray<_Tp>::resize(size_t __n, value_type __x) if (__n) { __begin_ = __end_ = allocator<value_type>().allocate(__n); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) ::new ((void*)__end_) value_type(__x); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -4933,8 +4944,11 @@ _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <algorithm> # include <concepts> +# include <cstdlib> # include <cstring> # include <functional> +# include <stdexcept> +# include <type_traits> #endif #endif // _LIBCPP_VALARRAY |
