From db8666322374d523784200a9c2288e5d82b8e865 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Wed, 27 Jul 2011 23:19:59 +0000 Subject: [PATCH] Optimizing valarray::operator=(some-valarray-expression) git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@136291 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/valarray | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/valarray b/include/valarray index 40c1fe120..d7a173cf6 100644 --- a/include/valarray +++ b/include/valarray @@ -817,6 +817,8 @@ public: valarray& operator=(const gslice_array& __ga); valarray& operator=(const mask_array& __ma); valarray& operator=(const indirect_array& __ia); + template + valarray& operator=(const __val_expr<_ValExpr>& __v); // element access: _LIBCPP_INLINE_VISIBILITY @@ -2958,6 +2960,21 @@ valarray<_Tp>::operator=(const indirect_array& __ia) return *this; } +template +template +inline _LIBCPP_INLINE_VISIBILITY +valarray<_Tp>& +valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) +{ + size_t __n = __v.size(); + if (size() != __n) + resize(__n); + value_type* __t = __begin_; + for (size_t __i = 0; __i != __n; ++__t, ++__i) + *__t = result_type(__v[__i]); + return *this; +} + template inline _LIBCPP_INLINE_VISIBILITY __val_expr<__slice_expr&> >