Index: include/complex =================================================================== --- include/complex +++ include/complex @@ -33,18 +33,18 @@ void real(T); void imag(T); - complex& operator= (const T&); - complex& operator+=(const T&); - complex& operator-=(const T&); - complex& operator*=(const T&); - complex& operator/=(const T&); + complex& operator= (const T&); // constexpr in C++2a + complex& operator+=(const T&); // constexpr in C++2a + complex& operator-=(const T&); // constexpr in C++2a + complex& operator*=(const T&); // constexpr in C++2a + complex& operator/=(const T&); // constexpr in C++2a complex& operator=(const complex&); - template complex& operator= (const complex&); - template complex& operator+=(const complex&); - template complex& operator-=(const complex&); - template complex& operator*=(const complex&); - template complex& operator/=(const complex&); + template complex& operator= (const complex&); // constexpr in C++2a + template complex& operator+=(const complex&); // constexpr in C++2a + template complex& operator-=(const complex&); // constexpr in C++2a + template complex& operator*=(const complex&); // constexpr in C++2a + template complex& operator/=(const complex&); // constexpr in C++2a }; template<> @@ -57,23 +57,23 @@ explicit constexpr complex(const complex&); explicit constexpr complex(const complex&); - constexpr float real() const; - void real(float); - constexpr float imag() const; - void imag(float); + constexpr float real() const; // constexpr in C++14 + void real(float); // constexpr in C++2a + constexpr float imag() const; // constexpr in C++14 + void imag(float); // constexpr in C++2a - complex& operator= (float); - complex& operator+=(float); - complex& operator-=(float); - complex& operator*=(float); - complex& operator/=(float); + complex& operator= (float); // constexpr in C++2a + complex& operator+=(float); // constexpr in C++2a + complex& operator-=(float); // constexpr in C++2a + complex& operator*=(float); // constexpr in C++2a + complex& operator/=(float); // constexpr in C++2a complex& operator=(const complex&); - template complex& operator= (const complex&); - template complex& operator+=(const complex&); - template complex& operator-=(const complex&); - template complex& operator*=(const complex&); - template complex& operator/=(const complex&); + template complex& operator= (const complex&); // constexpr in C++2a + template complex& operator+=(const complex&); // constexpr in C++2a + template complex& operator-=(const complex&); // constexpr in C++2a + template complex& operator*=(const complex&); // constexpr in C++2a + template complex& operator/=(const complex&); // constexpr in C++2a }; template<> @@ -86,23 +86,23 @@ constexpr complex(const complex&); explicit constexpr complex(const complex&); - constexpr double real() const; - void real(double); - constexpr double imag() const; - void imag(double); + constexpr double real() const; // constexpr in C++14 + void real(double); // constexpr in C++2a + constexpr double imag() const; // constexpr in C++14 + void imag(double); // constexpr in C++2a - complex& operator= (double); - complex& operator+=(double); - complex& operator-=(double); - complex& operator*=(double); - complex& operator/=(double); + complex& operator= (double); // constexpr in C++2a + complex& operator+=(double); // constexpr in C++2a + complex& operator-=(double); // constexpr in C++2a + complex& operator*=(double); // constexpr in C++2a + complex& operator/=(double); // constexpr in C++2a complex& operator=(const complex&); - template complex& operator= (const complex&); - template complex& operator+=(const complex&); - template complex& operator-=(const complex&); - template complex& operator*=(const complex&); - template complex& operator/=(const complex&); + template complex& operator= (const complex&); // constexpr in C++2a + template complex& operator+=(const complex&); // constexpr in C++2a + template complex& operator-=(const complex&); // constexpr in C++2a + template complex& operator*=(const complex&); // constexpr in C++2a + template complex& operator/=(const complex&); // constexpr in C++2a }; template<> @@ -115,46 +115,46 @@ constexpr complex(const complex&); constexpr complex(const complex&); - constexpr long double real() const; - void real(long double); - constexpr long double imag() const; - void imag(long double); + constexpr long double real() const; // constexpr in C++14 + void real(long double); // constexpr in C++2a + constexpr long double imag() const; // constexpr in C++14 + void imag(double); // constexpr in C++2a + complex& operator= (long double); // constexpr in C++2a + complex& operator+=(long double); // constexpr in C++2a + complex& operator-=(long double); // constexpr in C++2a + complex& operator*=(long double); // constexpr in C++2a + complex& operator/=(long double); // constexpr in C++2a complex& operator=(const complex&); - complex& operator= (long double); - complex& operator+=(long double); - complex& operator-=(long double); - complex& operator*=(long double); - complex& operator/=(long double); - template complex& operator= (const complex&); - template complex& operator+=(const complex&); - template complex& operator-=(const complex&); - template complex& operator*=(const complex&); - template complex& operator/=(const complex&); + template complex& operator= (const complex&); // constexpr in C++2a + template complex& operator+=(const complex&); // constexpr in C++2a + template complex& operator-=(const complex&); // constexpr in C++2a + template complex& operator*=(const complex&); // constexpr in C++2a + template complex& operator/=(const complex&); // constexpr in C++2a }; // 26.3.6 operators: -template complex operator+(const complex&, const complex&); -template complex operator+(const complex&, const T&); -template complex operator+(const T&, const complex&); -template complex operator-(const complex&, const complex&); -template complex operator-(const complex&, const T&); -template complex operator-(const T&, const complex&); -template complex operator*(const complex&, const complex&); -template complex operator*(const complex&, const T&); -template complex operator*(const T&, const complex&); -template complex operator/(const complex&, const complex&); -template complex operator/(const complex&, const T&); -template complex operator/(const T&, const complex&); -template complex operator+(const complex&); -template complex operator-(const complex&); -template bool operator==(const complex&, const complex&); // constexpr in C++14 -template bool operator==(const complex&, const T&); // constexpr in C++14 -template bool operator==(const T&, const complex&); // constexpr in C++14 -template bool operator!=(const complex&, const complex&); // constexpr in C++14 -template bool operator!=(const complex&, const T&); // constexpr in C++14 -template bool operator!=(const T&, const complex&); // constexpr in C++14 +template complex operator+(const complex&, const complex&); // constexpr in C++2a +template complex operator+(const complex&, const T&); // constexpr in C++2a +template complex operator+(const T&, const complex&); // constexpr in C++2a +template complex operator-(const complex&, const complex&); // constexpr in C++2a +template complex operator-(const complex&, const T&); // constexpr in C++2a +template complex operator-(const T&, const complex&); // constexpr in C++2a +template complex operator*(const complex&, const complex&); // constexpr in C++2a +template complex operator*(const complex&, const T&); // constexpr in C++2a +template complex operator*(const T&, const complex&); // constexpr in C++2a +template complex operator/(const complex&, const complex&); // constexpr in C++2a +template complex operator/(const complex&, const T&); // constexpr in C++2a +template complex operator/(const T&, const complex&); // constexpr in C++2a +template complex operator+(const complex&); // constexpr in C++2a +template complex operator-(const complex&); // constexpr in C++2a +template bool operator==(const complex&, const complex&); // constexpr in C++14 +template bool operator==(const complex&, const T&); // constexpr in C++14 +template bool operator==(const T&, const complex&); // constexpr in C++14 +template bool operator!=(const complex&, const complex&); // constexpr in C++14 +template bool operator!=(const complex&, const T&); // constexpr in C++14 +template bool operator!=(const T&, const complex&); // constexpr in C++14 template basic_istream& @@ -185,19 +185,19 @@ template double arg(T); float arg(float); -template T norm(const complex&); +template T norm(const complex&); // constexpr in C++2a long double norm(long double); double norm(double); template double norm(T); float norm(float); -template complex conj(const complex&); +template complex conj(const complex&); // constexpr in C++2a complex conj(long double); complex conj(double); template complex conj(T); complex conj(float); -template complex proj(const complex&); +template complex proj(const complex&); // constexpr in C++2a complex proj(long double); complex proj(double); template complex proj(T); @@ -254,7 +254,7 @@ template class _LIBCPP_TEMPLATE_VIS complex; -template complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); +template _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); template complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); template @@ -276,40 +276,58 @@ _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;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void real(value_type __re) {__re_ = __re;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void imag(value_type __im) {__im_ = __im;} - _LIBCPP_INLINE_VISIBILITY complex& operator= (const value_type& __re) - {__re_ = __re; __im_ = value_type(); return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator+=(const value_type& __re) {__re_ += __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator= (const value_type& __re) {__re_ = __re; __im_ = value_type(); return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator+=(const value_type& __re) {__re_ += __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;} - template _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c) + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator= (const complex<_Xp>& __c) { __re_ = __c.real(); __im_ = __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator+=(const complex<_Xp>& __c) { __re_ += __c.real(); __im_ += __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator-=(const complex<_Xp>& __c) { __re_ -= __c.real(); __im_ -= __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator*=(const complex<_Xp>& __c) { *this = *this * complex(__c.real(), __c.imag()); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY // _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator/=(const complex<_Xp>& __c) { *this = *this / complex(__c.real(), __c.imag()); return *this; @@ -337,40 +355,56 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float imag() const {return __im_;} - _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;} - _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void real(value_type __re) {__re_ = __re;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void imag(value_type __im) {__im_ = __im;} - _LIBCPP_INLINE_VISIBILITY complex& operator= (float __re) - {__re_ = __re; __im_ = value_type(); return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator+=(float __re) {__re_ += __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator-=(float __re) {__re_ -= __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator= (float __re) {__re_ = __re; __im_ = value_type(); return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator+=(float __re) {__re_ += __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator-=(float __re) {__re_ -= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;} - template _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c) + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator= (const complex<_Xp>& __c) { __re_ = __c.real(); __im_ = __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator+=(const complex<_Xp>& __c) { __re_ += __c.real(); __im_ += __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c) + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator-=(const complex<_Xp>& __c) { __re_ -= __c.real(); __im_ -= __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator*=(const complex<_Xp>& __c) { *this = *this * complex(__c.real(), __c.imag()); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY // _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator/=(const complex<_Xp>& __c) { *this = *this / complex(__c.real(), __c.imag()); return *this; @@ -395,40 +429,58 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double imag() const {return __im_;} - _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;} - _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void real(value_type __re) {__re_ = __re;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void imag(value_type __im) {__im_ = __im;} - _LIBCPP_INLINE_VISIBILITY complex& operator= (double __re) - {__re_ = __re; __im_ = value_type(); return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator+=(double __re) {__re_ += __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator-=(double __re) {__re_ -= __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator= (double __re) {__re_ = __re; __im_ = value_type(); return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator+=(double __re) {__re_ += __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator-=(double __re) {__re_ -= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;} - template _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c) + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator= (const complex<_Xp>& __c) { __re_ = __c.real(); __im_ = __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator+=(const complex<_Xp>& __c) { __re_ += __c.real(); __im_ += __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator-=(const complex<_Xp>& __c) { __re_ -= __c.real(); __im_ -= __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator*=(const complex<_Xp>& __c) { *this = *this * complex(__c.real(), __c.imag()); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY // _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator/=(const complex<_Xp>& __c) { *this = *this / complex(__c.real(), __c.imag()); return *this; @@ -453,40 +505,58 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double imag() const {return __im_;} - _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;} - _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;} + _LIBCPP_INLINE_VISIBILITY void _LIBCPP_CONSTEXPR_AFTER_CXX17 real(value_type __re) {__re_ = __re;} + _LIBCPP_INLINE_VISIBILITY void _LIBCPP_CONSTEXPR_AFTER_CXX17 imag(value_type __im) {__im_ = __im;} - _LIBCPP_INLINE_VISIBILITY complex& operator= (long double __re) - {__re_ = __re; __im_ = value_type(); return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator+=(long double __re) {__re_ += __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator-=(long double __re) {__re_ -= __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __re; return *this;} - _LIBCPP_INLINE_VISIBILITY complex& operator/=(long double __re) {__re_ /= __re; __im_ /= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator= (long double __re) {__re_ = __re; __im_ = value_type(); return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator+=(long double __re) {__re_ += __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator-=(long double __re) {__re_ -= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __re; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator/=(long double __re) {__re_ /= __re; __im_ /= __re; return *this;} - template _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c) + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator= (const complex<_Xp>& __c) { __re_ = __c.real(); __im_ = __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator+=(const complex<_Xp>& __c) { __re_ += __c.real(); __im_ += __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator-=(const complex<_Xp>& __c) { __re_ -= __c.real(); __im_ -= __c.imag(); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator*=(const complex<_Xp>& __c) { *this = *this * complex(__c.real(), __c.imag()); return *this; } - template _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) + + template + _LIBCPP_INLINE_VISIBILITY // _LIBCPP_CONSTEXPR_AFTER_CXX17 + complex& operator/=(const complex<_Xp>& __c) { *this = *this / complex(__c.real(), __c.imag()); return *this; @@ -526,7 +596,7 @@ // 26.3.6 operators: template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) { @@ -536,7 +606,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator+(const complex<_Tp>& __x, const _Tp& __y) { @@ -546,7 +616,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator+(const _Tp& __x, const complex<_Tp>& __y) { @@ -556,7 +626,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) { @@ -566,7 +636,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator-(const complex<_Tp>& __x, const _Tp& __y) { @@ -576,7 +646,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator-(const _Tp& __x, const complex<_Tp>& __y) { @@ -586,6 +656,7 @@ } template +_LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { @@ -645,7 +716,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator*(const complex<_Tp>& __x, const _Tp& __y) { @@ -655,7 +726,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator*(const _Tp& __x, const complex<_Tp>& __y) { @@ -665,6 +736,7 @@ } template +// _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) { @@ -709,7 +781,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY // _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator/(const complex<_Tp>& __x, const _Tp& __y) { @@ -717,7 +789,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY // _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator/(const _Tp& __x, const complex<_Tp>& __y) { @@ -727,7 +799,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator+(const complex<_Tp>& __x) { @@ -735,7 +807,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> operator-(const complex<_Tp>& __x) { @@ -906,7 +978,7 @@ // norm template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp norm(const complex<_Tp>& __c) { @@ -918,7 +990,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename __libcpp_complex_overload_traits<_Tp>::_ValueType norm(_Tp __re) { @@ -929,7 +1001,7 @@ // conj template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> conj(const complex<_Tp>& __c) { @@ -937,7 +1009,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename __libcpp_complex_overload_traits<_Tp>::_ComplexType conj(_Tp __re) { @@ -950,7 +1022,7 @@ // proj template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 complex<_Tp> proj(const complex<_Tp>& __c) { @@ -961,7 +1033,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < is_floating_point<_Tp>::value, @@ -975,7 +1047,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < is_integral<_Tp>::value, Index: test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp +++ test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp @@ -10,11 +10,21 @@ // // complex& operator= (const T&); +// constexpr in C++20 #include #include +#include "test_macros.h" + template +TEST_CONSTEXPR bool +constexpr_test(std::complex lhs, const T& rhs) +{ + return (lhs = rhs) == rhs; +} + +template void test() { @@ -27,6 +37,11 @@ c = -1.5; assert(c.real() == -1.5); assert(c.imag() == 0); + +#if TEST_STD_VER > 17 + TEST_CONSTEXPR std::complex c1{8,-2}; + static_assert(constexpr_test(c1, T(2)), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp +++ test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp @@ -10,11 +10,21 @@ // // complex& operator/=(const T& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template +TEST_CONSTEXPR bool +constexpr_test(std::complex lhs, const T& rhs, const std::complex& expected) +{ + return (lhs /= rhs) == expected; +} + +template void test() { @@ -34,6 +44,12 @@ c /= 0.5; assert(c.real() == -16); assert(c.imag() == 4); + +#if TEST_STD_VER > 17 + TEST_CONSTEXPR std::complex c1{8,-2}; + TEST_CONSTEXPR std::complex c2{4,-1}; + static_assert(constexpr_test(c1, T(2), c2), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp +++ test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp @@ -10,11 +10,21 @@ // // complex& operator-=(const T& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template +TEST_CONSTEXPR bool +constexpr_test(std::complex lhs, const T& rhs, const std::complex& expected) +{ + return (lhs -= rhs) == expected; +} + +template void test() { @@ -30,6 +40,12 @@ c -= -1.5; assert(c.real() == -1.5); assert(c.imag() == 0); + +#if TEST_STD_VER > 17 + TEST_CONSTEXPR std::complex c1{6,-1}; + TEST_CONSTEXPR std::complex c2{4,-1}; + static_assert(constexpr_test(c1, T(2), c2), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp +++ test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp @@ -10,11 +10,21 @@ // // complex& operator+=(const T& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template +TEST_CONSTEXPR bool +constexpr_test(std::complex lhs, const T& rhs, const std::complex& expected) +{ + return (lhs += rhs) == expected; +} + +template void test() { @@ -30,6 +40,12 @@ c += -1.5; assert(c.real() == 1.5); assert(c.imag() == 0); + +#if TEST_STD_VER > 17 + TEST_CONSTEXPR std::complex c1{4,-1}; + TEST_CONSTEXPR std::complex c2{6,-1}; + static_assert(constexpr_test(c1, T(2), c2), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp +++ test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp @@ -10,11 +10,21 @@ // // complex& operator*=(const T& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template +TEST_CONSTEXPR bool +constexpr_test(std::complex lhs, const T& rhs, const std::complex& expected) +{ + return (lhs *= rhs) == expected; +} + +template void test() { @@ -34,6 +44,12 @@ c *= 1.5; assert(c.real() == -5.0625); assert(c.imag() == 3); + +#if TEST_STD_VER > 17 + TEST_CONSTEXPR std::complex c1{4,-1}; + TEST_CONSTEXPR std::complex c2{8,-2}; + static_assert(constexpr_test(c1, T(2), c2), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.members/real_imag.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.members/real_imag.pass.cpp +++ test/std/numerics/complex.number/complex.members/real_imag.pass.cpp @@ -18,6 +18,24 @@ #include "test_macros.h" template +TEST_CONSTEXPR bool +constexpr_real(T val) +{ + std::complex c1{}; + c1.real(val); + return c1.real() == val; +} + +template +TEST_CONSTEXPR bool +constexpr_imag(T val) +{ + std::complex c1{}; + c1.imag(val); + return c1.imag() == val; +} + +template void test_constexpr() { @@ -32,6 +50,10 @@ static_assert(c3.real() == 3, ""); static_assert(c3.imag() == 4, ""); #endif +#if TEST_STD_VER > 17 + static_assert(constexpr_real(T(4.7)), "" ); + static_assert(constexpr_imag(T(4.7)), "" ); +#endif } template Index: test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp +++ test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator/(const complex& lhs, const complex& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + #include "../cases.h" template @@ -26,13 +29,23 @@ } template +TEST_CONSTEXPR bool +constexpr_test(const std::complex& lhs, const std::complex& rhs, std::complex x) +{ + return lhs / rhs == x; +} + +template void test() { - std::complex lhs(-4.0, 7.5); - std::complex rhs(1.5, 2.5); - std::complex x(1.5, 2.5); + TEST_CONSTEXPR std::complex lhs(-4.0, 7.5); + TEST_CONSTEXPR std::complex rhs(1.5, 2.5); + TEST_CONSTEXPR std::complex x(1.5, 2.5); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } void test_edges() Index: test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp +++ test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator/(const complex& lhs, const T& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template void test(const std::complex& lhs, const T& rhs, std::complex x) @@ -24,13 +27,23 @@ } template +TEST_CONSTEXPR bool +constexpr_test (const std::complex& lhs, const T& rhs, std::complex x) +{ + return lhs / rhs == x; +} + +template void test() { - std::complex lhs(-4.0, 7.5); - T rhs(2); - std::complex x(-2, 3.75); + TEST_CONSTEXPR std::complex lhs(-4.0, 7.5); + TEST_CONSTEXPR T rhs(2); + TEST_CONSTEXPR std::complex x(-2, 3.75); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp +++ test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator-(const complex& lhs, const complex& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template void test(const std::complex& lhs, const std::complex& rhs, std::complex x) @@ -24,20 +27,33 @@ } template +TEST_CONSTEXPR bool +constexpr_test(const std::complex& lhs, const std::complex& rhs, std::complex x) +{ + return lhs - rhs == x; +} + +template void test() { { - std::complex lhs(1.5, 2.5); - std::complex rhs(3.5, 4.5); - std::complex x(-2.0, -2.0); + TEST_CONSTEXPR std::complex lhs(1.5, 2.5); + TEST_CONSTEXPR std::complex rhs(3.5, 4.5); + TEST_CONSTEXPR std::complex x(-2.0, -2.0); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } { - std::complex lhs(1.5, -2.5); - std::complex rhs(-3.5, 4.5); - std::complex x(5.0, -7.0); + TEST_CONSTEXPR std::complex lhs(1.5, -2.5); + TEST_CONSTEXPR std::complex rhs(-3.5, 4.5); + TEST_CONSTEXPR std::complex x(5.0, -7.0); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } } Index: test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp +++ test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator+(const complex& lhs, const complex& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template void test(const std::complex& lhs, const std::complex& rhs, std::complex x) @@ -24,20 +27,33 @@ } template +TEST_CONSTEXPR bool +constexpr_test(const std::complex& lhs, const std::complex& rhs, std::complex x) +{ + return lhs + rhs == x; +} + +template void test() { { - std::complex lhs(1.5, 2.5); - std::complex rhs(3.5, 4.5); - std::complex x(5.0, 7.0); + TEST_CONSTEXPR std::complex lhs(1.5, 2.5); + TEST_CONSTEXPR std::complex rhs(3.5, 4.5); + TEST_CONSTEXPR std::complex x(5.0, 7.0); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } { - std::complex lhs(1.5, -2.5); - std::complex rhs(-3.5, 4.5); - std::complex x(-2.0, 2.0); + TEST_CONSTEXPR std::complex lhs(1.5, -2.5); + TEST_CONSTEXPR std::complex rhs(-3.5, 4.5); + TEST_CONSTEXPR std::complex x(-2.0, 2.0); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } } Index: test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp +++ test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator+(const complex& lhs, const T& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template void test(const std::complex& lhs, const T& rhs, std::complex x) @@ -24,20 +27,33 @@ } template +TEST_CONSTEXPR bool +constexpr_test(const std::complex& lhs, const T& rhs, std::complex x) +{ + return lhs + rhs == x; +} + +template void test() { { - std::complex lhs(1.5, 2.5); - T rhs(3.5); - std::complex x(5.0, 2.5); + TEST_CONSTEXPR std::complex lhs(1.5, 2.5); + TEST_CONSTEXPR T rhs(3.5); + TEST_CONSTEXPR std::complex x(5.0, 2.5); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } { - std::complex lhs(1.5, -2.5); - T rhs(-3.5); - std::complex x(-2.0, -2.5); + TEST_CONSTEXPR std::complex lhs(1.5, -2.5); + TEST_CONSTEXPR T rhs(-3.5); + TEST_CONSTEXPR std::complex x(-2.0, -2.5); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } } Index: test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp +++ test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator*(const complex& lhs, const complex& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + #include "../cases.h" template @@ -26,13 +29,23 @@ } template +TEST_CONSTEXPR bool +constexpr_test(const std::complex& lhs, const std::complex& rhs, std::complex x) +{ + return lhs * rhs == x; +} + +template void test() { - std::complex lhs(1.5, 2.5); - std::complex rhs(1.5, 2.5); - std::complex x(-4.0, 7.5); + TEST_CONSTEXPR std::complex lhs(1.5, 2.5); + TEST_CONSTEXPR std::complex rhs(1.5, 2.5); + TEST_CONSTEXPR std::complex x(-4.0, 7.5); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } // test edges Index: test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp +++ test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator*(const complex& lhs, const T& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template void test(const std::complex& lhs, const T& rhs, std::complex x) @@ -24,13 +27,23 @@ } template +TEST_CONSTEXPR bool +constexpr_test(const std::complex& lhs, const T& rhs, std::complex x) +{ + return lhs * rhs == x; +} + +template void test() { - std::complex lhs(1.5, 2.5); - T rhs(1.5); - std::complex x(2.25, 3.75); + TEST_CONSTEXPR std::complex lhs(1.5, 2.5); + TEST_CONSTEXPR T rhs(1.5); + TEST_CONSTEXPR std::complex x(2.25, 3.75); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp +++ test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator/(const T& lhs, const complex& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template void test(const T& lhs, const std::complex& rhs, std::complex x) @@ -24,13 +27,23 @@ } template +TEST_CONSTEXPR bool +constexpr_test(const T& lhs, const std::complex& rhs, std::complex x) +{ + return lhs / rhs == x; +} + +template void test() { - T lhs(-8.5); - std::complex rhs(1.5, 2.5); - std::complex x(-1.5, 2.5); + TEST_CONSTEXPR T lhs(-8.5); + TEST_CONSTEXPR std::complex rhs(1.5, 2.5); + TEST_CONSTEXPR std::complex x(-1.5, 2.5); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp +++ test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator-(const T& lhs, const complex& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template void test(const T& lhs, const std::complex& rhs, std::complex x) @@ -24,20 +27,33 @@ } template +TEST_CONSTEXPR bool +constexpr_test(const T& lhs, const std::complex& rhs, std::complex x) +{ + return lhs - rhs == x; +} + +template void test() { { - T lhs(1.5); - std::complex rhs(3.5, 4.5); - std::complex x(-2.0, -4.5); + TEST_CONSTEXPR T lhs(1.5); + TEST_CONSTEXPR std::complex rhs(3.5, 4.5); + TEST_CONSTEXPR std::complex x(-2.0, -4.5); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } { - T lhs(1.5); - std::complex rhs(-3.5, 4.5); - std::complex x(5.0, -4.5); + TEST_CONSTEXPR T lhs(1.5); + TEST_CONSTEXPR std::complex rhs(-3.5, 4.5); + TEST_CONSTEXPR std::complex x(5.0, -4.5); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } } Index: test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp +++ test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator+(const T& lhs, const complex& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template void test(const T& lhs, const std::complex& rhs, std::complex x) @@ -24,20 +27,33 @@ } template +TEST_CONSTEXPR bool +constexpr_test(const T& lhs, const std::complex& rhs, std::complex x) +{ + return lhs + rhs == x; +} + +template void test() { { - T lhs(1.5); - std::complex rhs(3.5, 4.5); - std::complex x(5.0, 4.5); + TEST_CONSTEXPR T lhs(1.5); + TEST_CONSTEXPR std::complex rhs(3.5, 4.5); + TEST_CONSTEXPR std::complex x(5.0, 4.5); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } { - T lhs(1.5); - std::complex rhs(-3.5, 4.5); - std::complex x(-2.0, 4.5); + TEST_CONSTEXPR T lhs(1.5); + TEST_CONSTEXPR std::complex rhs(-3.5, 4.5); + TEST_CONSTEXPR std::complex x(-2.0, 4.5); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } } Index: test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp +++ test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp @@ -12,10 +12,13 @@ // template // complex // operator*(const T& lhs, const complex& rhs); +// constexpr in C++20 #include #include +#include "test_macros.h" + template void test(const T& lhs, const std::complex& rhs, std::complex x) @@ -24,13 +27,23 @@ } template +TEST_CONSTEXPR bool +constexpr_test(const T& lhs, const std::complex& rhs, std::complex x) +{ + return lhs * rhs == x; +} + +template void test() { - T lhs(1.5); - std::complex rhs(1.5, 2.5); - std::complex x(2.25, 3.75); + TEST_CONSTEXPR T lhs(1.5); + TEST_CONSTEXPR std::complex rhs(1.5, 2.5); + TEST_CONSTEXPR std::complex x(2.25, 3.75); test(lhs, rhs, x); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(lhs, rhs, x), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp +++ test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp @@ -12,20 +12,34 @@ // template // complex // operator-(const complex& lhs); +// constexpr in c++20 #include #include +#include "test_macros.h" + template +TEST_CONSTEXPR bool +constexpr_test(const std::complex &z) +{ + std::complex c = -z; + return c.real() == -z.real() && c.imag() == -z.imag(); +} + +template void test() { - std::complex z(1.5, 2.5); + TEST_CONSTEXPR std::complex z(1.5, 2.5); assert(z.real() == 1.5); assert(z.imag() == 2.5); - std::complex c = -z; + TEST_CONSTEXPR std::complex c = -z; assert(c.real() == -1.5); assert(c.imag() == -2.5); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(z), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp +++ test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp @@ -12,20 +12,34 @@ // template // complex // operator+(const complex&); +// constexpr in C++20 #include #include +#include "test_macros.h" + template +TEST_CONSTEXPR bool +constexpr_test(const std::complex &z) +{ + std::complex c = +z; + return c.real() == z.real() && c.imag() == z.imag(); +} + +template void test() { - std::complex z(1.5, 2.5); + TEST_CONSTEXPR std::complex z(1.5, 2.5); assert(z.real() == 1.5); assert(z.imag() == 2.5); - std::complex c = +z; + TEST_CONSTEXPR std::complex c = +z; assert(c.real() == 1.5); assert(c.imag() == 2.5); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(z), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp +++ test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp @@ -12,11 +12,21 @@ // template // complex // conj(const complex& x); +// constexpr in C++20 #include #include +#include "test_macros.h" + template +TEST_CONSTEXPR bool +constexpr_test(const std::complex &z, std::complex x) +{ + return conj(z) == x; +} + +template void test(const std::complex& z, std::complex x) { @@ -27,10 +37,25 @@ void test() { - test(std::complex(1, 2), std::complex(1, -2)); - test(std::complex(-1, 2), std::complex(-1, -2)); - test(std::complex(1, -2), std::complex(1, 2)); - test(std::complex(-1, -2), std::complex(-1, 2)); + typedef std::complex C; + + TEST_CONSTEXPR C v12 ( 1, 2); + TEST_CONSTEXPR C v1_2 ( 1, -2); + TEST_CONSTEXPR C v_12 (-1, 2); + TEST_CONSTEXPR C v_1_2(-1, -2); + + test(v12, v1_2); + test(v_12, v_1_2); + test(v1_2, v12); + test(v_1_2, v_12); + +#if TEST_STD_VER > 17 + static_assert(constexpr_test(v12, v1_2 ), ""); + static_assert(constexpr_test(v_12, v_1_2), ""); + static_assert(constexpr_test(v1_2, v12 ), ""); + static_assert(constexpr_test(v_1_2, v_12 ), ""); +#endif + } int main() Index: test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp +++ test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp @@ -12,16 +12,30 @@ // template // T // imag(const complex& x); +// constexpr in C++20 #include #include +#include "test_macros.h" + template +TEST_CONSTEXPR bool +constexpr_test() +{ + std::complex z(1.5, 2.5); + return imag(z) == 2.5; +} + +template void test() { std::complex z(1.5, 2.5); assert(imag(z) == 2.5); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(), ""); +#endif } int main() Index: test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp +++ test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp @@ -12,18 +12,31 @@ // template // T // norm(const complex& x); +// constexpr in C++20 #include #include +#include "test_macros.h" + #include "../cases.h" template +TEST_CONSTEXPR bool +constexpr_test(const std::complex &z, T expected) +{ + return norm(z) == expected; +} + +template void test() { - std::complex z(3, 4); + TEST_CONSTEXPR std::complex z(3, 4); assert(norm(z) == 25); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(z, 25), ""); +#endif } void test_edges() Index: test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp +++ test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp @@ -12,13 +12,24 @@ // template // complex // proj(const complex& x); +// constexpr in C++20 #include #include +#include "test_macros.h" + #include "../cases.h" template +TEST_CONSTEXPR bool +constexpr_test(const std::complex &z, std::complex x) +{ + return proj(z) == x; +} + + +template void test(const std::complex& z, std::complex x) { @@ -29,10 +40,24 @@ void test() { - test(std::complex(1, 2), std::complex(1, 2)); - test(std::complex(-1, 2), std::complex(-1, 2)); - test(std::complex(1, -2), std::complex(1, -2)); - test(std::complex(-1, -2), std::complex(-1, -2)); + typedef std::complex C; + + TEST_CONSTEXPR C v12 ( 1, 2); + TEST_CONSTEXPR C v1_2 ( 1, -2); + TEST_CONSTEXPR C v_12 (-1, 2); + TEST_CONSTEXPR C v_1_2(-1, -2); + + test(v12, v12); + test(v_12, v_12); + test(v1_2, v1_2); + test(v_1_2, v_1_2); + +#if TEST_STD_VER > 17 + static_assert(constexpr_test(v12, v12), ""); + static_assert(constexpr_test(v_12, v_12), ""); + static_assert(constexpr_test(v1_2, v1_2), ""); + static_assert(constexpr_test(v_1_2, v_1_2), ""); +#endif } void test_edges() Index: test/std/numerics/complex.number/complex.value.ops/real.pass.cpp =================================================================== --- test/std/numerics/complex.number/complex.value.ops/real.pass.cpp +++ test/std/numerics/complex.number/complex.value.ops/real.pass.cpp @@ -12,16 +12,30 @@ // template // T // real(const complex& x); +// constexpr in C++20 #include #include +#include "test_macros.h" + template +TEST_CONSTEXPR bool +constexpr_test() +{ + std::complex z(1.5, 2.5); + return real(z) == 1.5; +} + +template void test() { std::complex z(1.5, 2.5); assert(real(z) == 1.5); +#if TEST_STD_VER > 17 + static_assert(constexpr_test(), ""); +#endif } int main()