diff options
author | Howard Hinnant <hhinnant@apple.com> | 2011-07-27 23:19:59 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2011-07-27 23:19:59 +0000 |
commit | f4a797e3d2352de73ddee7707bf9cc114fd49134 (patch) | |
tree | 77ce175c41076e9e8d947b8f4f498fbc33b36ea3 /libcxx | |
parent | 847f511300c3863504ecec5dc8b5b6a54304267d (diff) | |
download | bcm5719-llvm-f4a797e3d2352de73ddee7707bf9cc114fd49134.tar.gz bcm5719-llvm-f4a797e3d2352de73ddee7707bf9cc114fd49134.zip |
Optimizing valarray::operator=(some-valarray-expression)
llvm-svn: 136291
Diffstat (limited to 'libcxx')
-rw-r--r-- | libcxx/include/valarray | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libcxx/include/valarray b/libcxx/include/valarray index 40c1fe1205c..d7a173cf6fb 100644 --- a/libcxx/include/valarray +++ b/libcxx/include/valarray @@ -817,6 +817,8 @@ public: valarray& operator=(const gslice_array<value_type>& __ga); valarray& operator=(const mask_array<value_type>& __ma); valarray& operator=(const indirect_array<value_type>& __ia); + template <class _ValExpr> + valarray& operator=(const __val_expr<_ValExpr>& __v); // element access: _LIBCPP_INLINE_VISIBILITY @@ -2959,6 +2961,21 @@ valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) } template <class _Tp> +template <class _ValExpr> +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 <class _Tp> inline _LIBCPP_INLINE_VISIBILITY __val_expr<__slice_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](slice __s) const |