Fix a number of bugs in __val_expr's subset operator[].
The current definitions were entirely broken. They didn't call any
existing constructor and the forgot to friend the expression types they
were trying to construct.
llvm-svn: 357453
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 0657197588ffea508426de1e0c2afa65e76e24fa
diff --git a/include/valarray b/include/valarray
index c9ca08c..1c4875e 100644
--- a/include/valarray
+++ b/include/valarray
@@ -673,6 +673,7 @@
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __size_;}
+ template <class> friend class __val_expr;
template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
};
@@ -2221,6 +2222,7 @@
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __1d_.size();}
+ template <class> friend class __val_expr;
template <class> friend class valarray;
};
@@ -2591,6 +2593,7 @@
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __1d_.size();}
+ template <class> friend class __val_expr;
template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
};
@@ -2613,19 +2616,31 @@
_LIBCPP_INLINE_VISIBILITY
__val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
- {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
+ {
+ typedef __slice_expr<_ValExpr> _NewExpr;
+ return __val_expr< _NewExpr >(_NewExpr(__s, __expr_));
+ }
_LIBCPP_INLINE_VISIBILITY
__val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
- {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
+ {
+ typedef __indirect_expr<_ValExpr> _NewExpr;
+ return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_));
+ }
_LIBCPP_INLINE_VISIBILITY
__val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
- {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
+ {
+ typedef __mask_expr<_ValExpr> _NewExpr;
+ return __val_expr< _NewExpr >( _NewExpr(__vb, __expr_));
+ }
_LIBCPP_INLINE_VISIBILITY
__val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
- {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
+ {
+ typedef __indirect_expr<_ValExpr> _NewExpr;
+ return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_));
+ }
_LIBCPP_INLINE_VISIBILITY
__val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >