diff --git a/libcxx/include/__functional_base b/libcxx/include/__functional_base --- a/libcxx/include/__functional_base +++ b/libcxx/include/__functional_base @@ -49,6 +49,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool> { + typedef bool __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x < __y;} diff --git a/libcxx/include/functional b/libcxx/include/functional --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -532,6 +532,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS plus : binary_function<_Tp, _Tp, _Tp> { + typedef _Tp __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x + __y;} @@ -559,6 +560,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS minus : binary_function<_Tp, _Tp, _Tp> { + typedef _Tp __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x - __y;} @@ -586,6 +588,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS multiplies : binary_function<_Tp, _Tp, _Tp> { + typedef _Tp __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x * __y;} @@ -613,6 +616,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS divides : binary_function<_Tp, _Tp, _Tp> { + typedef _Tp __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x / __y;} @@ -640,6 +644,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS modulus : binary_function<_Tp, _Tp, _Tp> { + typedef _Tp __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x % __y;} @@ -667,6 +672,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS negate : unary_function<_Tp, _Tp> { + typedef _Tp __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return -__x;} @@ -694,6 +700,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS equal_to : binary_function<_Tp, _Tp, bool> { + typedef bool __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x == __y;} @@ -721,6 +728,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS not_equal_to : binary_function<_Tp, _Tp, bool> { + typedef bool __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x != __y;} @@ -748,6 +756,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool> { + typedef bool __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x > __y;} @@ -777,6 +786,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool> { + typedef bool __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x >= __y;} @@ -804,6 +814,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS less_equal : binary_function<_Tp, _Tp, bool> { + typedef bool __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x <= __y;} @@ -831,6 +842,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS logical_and : binary_function<_Tp, _Tp, bool> { + typedef bool __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x && __y;} @@ -858,6 +870,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS logical_or : binary_function<_Tp, _Tp, bool> { + typedef bool __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x || __y;} @@ -885,6 +898,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS logical_not : unary_function<_Tp, bool> { + typedef bool __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const {return !__x;} @@ -912,6 +926,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS bit_and : binary_function<_Tp, _Tp, _Tp> { + typedef _Tp __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x & __y;} @@ -939,6 +954,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS bit_or : binary_function<_Tp, _Tp, _Tp> { + typedef _Tp __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x | __y;} @@ -966,6 +982,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp> { + typedef _Tp __result_type; // used by valarray _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x ^ __y;} diff --git a/libcxx/include/valarray b/libcxx/include/valarray --- a/libcxx/include/valarray +++ b/libcxx/include/valarray @@ -413,7 +413,7 @@ template struct _UnaryOp { - typedef typename _Op::result_type result_type; + typedef typename _Op::__result_type __result_type; typedef typename _A0::value_type value_type; _Op __op_; @@ -423,7 +423,7 @@ _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {} _LIBCPP_INLINE_VISIBILITY - result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} + __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __a0_.size();} @@ -432,7 +432,7 @@ template struct _BinaryOp { - typedef typename _Op::result_type result_type; + typedef typename _Op::__result_type __result_type; typedef typename _A0::value_type value_type; _Op __op_; @@ -455,7 +455,7 @@ { public: typedef _Tp value_type; - typedef const _Tp& result_type; + typedef const _Tp& __result_type; private: const value_type& __t_; size_t __s_; @@ -464,50 +464,56 @@ explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {} _LIBCPP_INLINE_VISIBILITY - result_type operator[](size_t) const {return __t_;} + __result_type operator[](size_t) const {return __t_;} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __s_;} }; template -struct __unary_plus : unary_function<_Tp, _Tp> +struct __unary_plus { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return +__x;} }; template -struct __bit_not : unary_function<_Tp, _Tp> +struct __bit_not { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return ~__x;} }; template -struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp> +struct __bit_shift_left { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x << __y;} }; template -struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp> +struct __bit_shift_right { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x >> __y;} }; template -struct __apply_expr : unary_function<_Tp, _Tp> +struct __apply_expr { private: _Fp __f_; public: + typedef _Tp __result_type; + _LIBCPP_INLINE_VISIBILITY explicit __apply_expr(_Fp __f) : __f_(__f) {} @@ -517,128 +523,144 @@ }; template -struct __abs_expr : unary_function<_Tp, _Tp> +struct __abs_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return abs(__x);} }; template -struct __acos_expr : unary_function<_Tp, _Tp> +struct __acos_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return acos(__x);} }; template -struct __asin_expr : unary_function<_Tp, _Tp> +struct __asin_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return asin(__x);} }; template -struct __atan_expr : unary_function<_Tp, _Tp> +struct __atan_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return atan(__x);} }; template -struct __atan2_expr : binary_function<_Tp, _Tp, _Tp> +struct __atan2_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return atan2(__x, __y);} }; template -struct __cos_expr : unary_function<_Tp, _Tp> +struct __cos_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return cos(__x);} }; template -struct __cosh_expr : unary_function<_Tp, _Tp> +struct __cosh_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return cosh(__x);} }; template -struct __exp_expr : unary_function<_Tp, _Tp> +struct __exp_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return exp(__x);} }; template -struct __log_expr : unary_function<_Tp, _Tp> +struct __log_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return log(__x);} }; template -struct __log10_expr : unary_function<_Tp, _Tp> +struct __log10_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return log10(__x);} }; template -struct __pow_expr : binary_function<_Tp, _Tp, _Tp> +struct __pow_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return pow(__x, __y);} }; template -struct __sin_expr : unary_function<_Tp, _Tp> +struct __sin_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return sin(__x);} }; template -struct __sinh_expr : unary_function<_Tp, _Tp> +struct __sinh_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return sinh(__x);} }; template -struct __sqrt_expr : unary_function<_Tp, _Tp> +struct __sqrt_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return sqrt(__x);} }; template -struct __tan_expr : unary_function<_Tp, _Tp> +struct __tan_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return tan(__x);} }; template -struct __tanh_expr : unary_function<_Tp, _Tp> +struct __tanh_expr { + typedef _Tp __result_type; _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return tanh(__x);} @@ -650,7 +672,7 @@ typedef typename remove_reference<_ValExpr>::type _RmExpr; public: typedef typename _RmExpr::value_type value_type; - typedef value_type result_type; + typedef value_type __result_type; private: _ValExpr __expr_; @@ -668,7 +690,7 @@ public: _LIBCPP_INLINE_VISIBILITY - result_type operator[](size_t __i) const + __result_type operator[](size_t __i) const {return __expr_[__start_ + __i * __stride_];} _LIBCPP_INLINE_VISIBILITY @@ -690,7 +712,7 @@ typedef typename remove_reference<_ValExpr>::type _RmExpr; public: typedef typename _RmExpr::value_type value_type; - typedef value_type result_type; + typedef value_type __result_type; private: _ValExpr __expr_; @@ -714,7 +736,7 @@ public: _LIBCPP_INLINE_VISIBILITY - result_type operator[](size_t __j) const + __result_type operator[](size_t __j) const { ptrdiff_t __i = static_cast(__j); ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np; @@ -733,7 +755,7 @@ typedef typename remove_reference<_ValExpr>::type _RmExpr; public: typedef typename _RmExpr::value_type value_type; - typedef value_type result_type; + typedef value_type __result_type; private: _ValExpr __expr_; @@ -764,7 +786,7 @@ public: _LIBCPP_INLINE_VISIBILITY - result_type operator[](size_t __i) const + __result_type operator[](size_t __i) const { if (__i < __m_) return __expr_[__i + __o1_]; @@ -794,7 +816,7 @@ { public: typedef _Tp value_type; - typedef _Tp result_type; + typedef _Tp __result_type; private: value_type* __begin_; @@ -1065,7 +1087,7 @@ template struct _UnaryOp<_Op, valarray<_Tp> > { - typedef typename _Op::result_type result_type; + typedef typename _Op::__result_type __result_type; typedef _Tp value_type; _Op __op_; @@ -1075,7 +1097,7 @@ _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {} _LIBCPP_INLINE_VISIBILITY - result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} + __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __a0_.size();} @@ -1084,7 +1106,7 @@ template struct _BinaryOp<_Op, valarray<_Tp>, _A1> { - typedef typename _Op::result_type result_type; + typedef typename _Op::__result_type __result_type; typedef _Tp value_type; _Op __op_; @@ -1105,7 +1127,7 @@ template struct _BinaryOp<_Op, _A0, valarray<_Tp> > { - typedef typename _Op::result_type result_type; + typedef typename _Op::__result_type __result_type; typedef _Tp value_type; _Op __op_; @@ -1126,7 +1148,7 @@ template struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > { - typedef typename _Op::result_type result_type; + typedef typename _Op::__result_type __result_type; typedef _Tp value_type; _Op __op_; @@ -2199,7 +2221,7 @@ typedef typename remove_reference<_ValExpr>::type _RmExpr; public: typedef typename _RmExpr::value_type value_type; - typedef value_type result_type; + typedef value_type __result_type; private: _ValExpr __expr_; @@ -2218,7 +2240,7 @@ public: _LIBCPP_INLINE_VISIBILITY - result_type operator[](size_t __i) const + __result_type operator[](size_t __i) const {return __expr_[__1d_[__i]];} _LIBCPP_INLINE_VISIBILITY @@ -2562,7 +2584,7 @@ typedef typename remove_reference<_ValExpr>::type _RmExpr; public: typedef typename _RmExpr::value_type value_type; - typedef value_type result_type; + typedef value_type __result_type; private: _ValExpr __expr_; @@ -2586,7 +2608,7 @@ public: _LIBCPP_INLINE_VISIBILITY - result_type operator[](size_t __i) const + __result_type operator[](size_t __i) const {return __expr_[__1d_[__i]];} _LIBCPP_INLINE_VISIBILITY @@ -2604,13 +2626,13 @@ _ValExpr __expr_; public: typedef typename _RmExpr::value_type value_type; - typedef typename _RmExpr::result_type result_type; + typedef typename _RmExpr::__result_type __result_type; _LIBCPP_INLINE_VISIBILITY explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {} _LIBCPP_INLINE_VISIBILITY - result_type operator[](size_t __i) const + __result_type operator[](size_t __i) const {return __expr_[__i];} _LIBCPP_INLINE_VISIBILITY @@ -2673,29 +2695,29 @@ return __val_expr<_NewExpr>(_NewExpr(logical_not(), __expr_)); } - operator valarray() const; + operator valarray<__result_type>() const; _LIBCPP_INLINE_VISIBILITY size_t size() const {return __expr_.size();} _LIBCPP_INLINE_VISIBILITY - result_type sum() const + __result_type sum() const { size_t __n = __expr_.size(); - result_type __r = __n ? __expr_[0] : result_type(); + __result_type __r = __n ? __expr_[0] : __result_type(); for (size_t __i = 1; __i < __n; ++__i) __r += __expr_[__i]; return __r; } _LIBCPP_INLINE_VISIBILITY - result_type min() const + __result_type min() const { size_t __n = size(); - result_type __r = __n ? (*this)[0] : result_type(); + __result_type __r = __n ? (*this)[0] : __result_type(); for (size_t __i = 1; __i < __n; ++__i) { - result_type __x = __expr_[__i]; + __result_type __x = __expr_[__i]; if (__x < __r) __r = __x; } @@ -2703,13 +2725,13 @@ } _LIBCPP_INLINE_VISIBILITY - result_type max() const + __result_type max() const { size_t __n = size(); - result_type __r = __n ? (*this)[0] : result_type(); + __result_type __r = __n ? (*this)[0] : __result_type(); for (size_t __i = 1; __i < __n; ++__i) { - result_type __x = __expr_[__i]; + __result_type __x = __expr_[__i]; if (__r < __x) __r = __x; } @@ -2744,16 +2766,16 @@ }; template -__val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const +__val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const { - valarray __r; + valarray<__result_type> __r; size_t __n = __expr_.size(); if (__n) { __r.__begin_ = - __r.__end_ = allocator().allocate(__n); + __r.__end_ = allocator<__result_type>().allocate(__n); for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i) - ::new ((void*)__r.__end_) result_type(__expr_[__i]); + ::new ((void*)__r.__end_) __result_type(__expr_[__i]); } return __r; } @@ -3131,7 +3153,7 @@ resize(__n); value_type* __t = __begin_; for (size_t __i = 0; __i != __n; ++__t, ++__i) - *__t = result_type(__v[__i]); + *__t = __result_type(__v[__i]); return *this; }