diff options
Diffstat (limited to 'contrib/libc++/include/complex')
-rw-r--r-- | contrib/libc++/include/complex | 153 |
1 files changed, 97 insertions, 56 deletions
diff --git a/contrib/libc++/include/complex b/contrib/libc++/include/complex index a09bf70..2943da1 100644 --- a/contrib/libc++/include/complex +++ b/contrib/libc++/include/complex @@ -23,12 +23,12 @@ class complex public: typedef T value_type; - complex(const T& re = T(), const T& im = T()); - complex(const complex&); - template<class X> complex(const complex<X>&); + complex(const T& re = T(), const T& im = T()); // constexpr in C++14 + complex(const complex&); // constexpr in C++14 + template<class X> complex(const complex<X>&); // constexpr in C++14 - T real() const; - T imag() const; + T real() const; // constexpr in C++14 + T imag() const; // constexpr in C++14 void real(T); void imag(T); @@ -149,12 +149,12 @@ template<class T> complex<T> operator/(const complex<T>&, const T&); template<class T> complex<T> operator/(const T&, const complex<T>&); template<class T> complex<T> operator+(const complex<T>&); template<class T> complex<T> operator-(const complex<T>&); -template<class T> bool operator==(const complex<T>&, const complex<T>&); -template<class T> bool operator==(const complex<T>&, const T&); -template<class T> bool operator==(const T&, const complex<T>&); -template<class T> bool operator!=(const complex<T>&, const complex<T>&); -template<class T> bool operator!=(const complex<T>&, const T&); -template<class T> bool operator!=(const T&, const complex<T>&); +template<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14 +template<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14 +template<class T> bool operator==(const T&, const complex<T>&); // constexpr in C++14 +template<class T> bool operator!=(const complex<T>&, const complex<T>&); // constexpr in C++14 +template<class T> bool operator!=(const complex<T>&, const T&); // constexpr in C++14 +template<class T> bool operator!=(const T&, const complex<T>&); // constexpr in C++14 template<class T, class charT, class traits> basic_istream<charT, traits>& @@ -165,17 +165,17 @@ template<class T, class charT, class traits> // 26.3.7 values: -template<class T> T real(const complex<T>&); - long double real(long double); - double real(double); -template<Integral T> double real(T); - float real(float); +template<class T> T real(const complex<T>&); // constexpr in C++14 + long double real(long double); // constexpr in C++14 + double real(double); // constexpr in C++14 +template<Integral T> double real(T); // constexpr in C++14 + float real(float); // constexpr in C++14 -template<class T> T imag(const complex<T>&); - long double imag(long double); - double imag(double); -template<Integral T> double imag(T); - float imag(float); +template<class T> T imag(const complex<T>&); // constexpr in C++14 + long double imag(long double); // constexpr in C++14 + double imag(double); // constexpr in C++14 +template<Integral T> double imag(T); // constexpr in C++14 + float imag(float); // constexpr in C++14 template<class T> T abs(const complex<T>&); @@ -255,13 +255,13 @@ template<class T, class charT, class traits> _LIBCPP_BEGIN_NAMESPACE_STD -template<class _Tp> class _LIBCPP_TYPE_VIS complex; +template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY complex; template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); template<class _Tp> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); template<class _Tp> -class _LIBCPP_TYPE_VIS complex +class _LIBCPP_TYPE_VIS_ONLY complex { public: typedef _Tp value_type; @@ -269,15 +269,15 @@ private: value_type __re_; value_type __im_; public: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 complex(const value_type& __re = value_type(), const value_type& __im = value_type()) : __re_(__re), __im_(__im) {} - template<class _Xp> _LIBCPP_INLINE_VISIBILITY + template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 complex(const complex<_Xp>& __c) : __re_(__c.real()), __im_(__c.imag()) {} - _LIBCPP_INLINE_VISIBILITY value_type real() const {return __re_;} - _LIBCPP_INLINE_VISIBILITY value_type imag() const {return __im_;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type real() const {return __re_;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type imag() const {return __im_;} _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;} _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;} @@ -309,21 +309,21 @@ public: } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { - *this = *this * __c; + *this = *this * complex(__c.real(), __c.imag()); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { - *this = *this / __c; + *this = *this / complex(__c.real(), __c.imag()); return *this; } }; -template<> class _LIBCPP_TYPE_VIS complex<double>; -template<> class _LIBCPP_TYPE_VIS complex<long double>; +template<> class _LIBCPP_TYPE_VIS_ONLY complex<double>; +template<> class _LIBCPP_TYPE_VIS_ONLY complex<long double>; template<> -class _LIBCPP_TYPE_VIS complex<float> +class _LIBCPP_TYPE_VIS_ONLY complex<float> { float __re_; float __im_; @@ -368,18 +368,18 @@ public: } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { - *this = *this * __c; + *this = *this * complex(__c.real(), __c.imag()); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { - *this = *this / __c; + *this = *this / complex(__c.real(), __c.imag()); return *this; } }; template<> -class _LIBCPP_TYPE_VIS complex<double> +class _LIBCPP_TYPE_VIS_ONLY complex<double> { double __re_; double __im_; @@ -424,18 +424,18 @@ public: } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { - *this = *this * __c; + *this = *this * complex(__c.real(), __c.imag()); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { - *this = *this / __c; + *this = *this / complex(__c.real(), __c.imag()); return *this; } }; template<> -class _LIBCPP_TYPE_VIS complex<long double> +class _LIBCPP_TYPE_VIS_ONLY complex<long double> { long double __re_; long double __im_; @@ -480,12 +480,12 @@ public: } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { - *this = *this * __c; + *this = *this * complex(__c.real(), __c.imag()); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { - *this = *this / __c; + *this = *this / complex(__c.real(), __c.imag()); return *this; } }; @@ -740,7 +740,7 @@ operator-(const complex<_Tp>& __x) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) { @@ -748,7 +748,7 @@ operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const complex<_Tp>& __x, const _Tp& __y) { @@ -756,7 +756,7 @@ operator==(const complex<_Tp>& __x, const _Tp& __y) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const _Tp& __x, const complex<_Tp>& __y) { @@ -764,7 +764,7 @@ operator==(const _Tp& __x, const complex<_Tp>& __y) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) { @@ -772,7 +772,7 @@ operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const complex<_Tp>& __x, const _Tp& __y) { @@ -780,7 +780,7 @@ operator!=(const complex<_Tp>& __x, const _Tp& __y) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const _Tp& __x, const complex<_Tp>& __y) { @@ -792,21 +792,21 @@ operator!=(const _Tp& __x, const complex<_Tp>& __y) // real template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp real(const complex<_Tp>& __c) { return __c.real(); } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 long double real(long double __re) { return __re; } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 double real(double __re) { @@ -814,7 +814,7 @@ real(double __re) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename enable_if < is_integral<_Tp>::value, @@ -825,7 +825,7 @@ real(_Tp __re) return __re; } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 float real(float __re) { @@ -835,21 +835,21 @@ real(float __re) // imag template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp imag(const complex<_Tp>& __c) { return __c.imag(); } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 long double imag(long double __re) { return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 double imag(double __re) { @@ -857,7 +857,7 @@ imag(double __re) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename enable_if < is_integral<_Tp>::value, @@ -868,7 +868,7 @@ imag(_Tp __re) return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 float imag(float __re) { @@ -1521,6 +1521,47 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) return __os << __s.str(); } +#if _LIBCPP_STD_VER > 11 +// Literal suffix for complex number literals [complex.literals] +inline namespace literals +{ + inline namespace complex_literals + { + constexpr complex<long double> operator""il(long double __im) + { + return { 0.0l, __im }; + } + + constexpr complex<long double> operator""il(unsigned long long __im) + { + return { 0.0l, static_cast<long double>(__im) }; + } + + + constexpr complex<double> operator""i(long double __im) + { + return { 0.0, static_cast<double>(__im) }; + } + + constexpr complex<double> operator""i(unsigned long long __im) + { + return { 0.0, static_cast<double>(__im) }; + } + + + constexpr complex<float> operator""if(long double __im) + { + return { 0.0f, static_cast<float>(__im) }; + } + + constexpr complex<float> operator""if(unsigned long long __im) + { + return { 0.0f, static_cast<float>(__im) }; + } + } +} +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_COMPLEX |