#ifndef _LIBCPP_COMPLEX
#define _LIBCPP_COMPLEX
#include <__config>
#include <__fwd/complex.h>
#include <__fwd/tuple.h>
#include <__tuple/tuple_element.h>
#include <__tuple/tuple_size.h>
#include <__type_traits/conditional.h>
#include <__utility/move.h>
#include <cmath>
#include <version>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
# include <sstream>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
class _LIBCPP_TEMPLATE_VIS complex;
template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
template <class _Tp>
class _LIBCPP_TEMPLATE_VIS complex { … };
template <>
class _LIBCPP_TEMPLATE_VIS complex<double>;
template <>
class _LIBCPP_TEMPLATE_VIS complex<long double>;
struct __from_builtin_tag { … };
__complex_t;
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re, _Tp __im) { … }
template <>
class _LIBCPP_TEMPLATE_VIS complex<float> { … };
template <>
class _LIBCPP_TEMPLATE_VIS complex<double> { … };
template <>
class _LIBCPP_TEMPLATE_VIS complex<long double> { … };
inline _LIBCPP_CONSTEXPR complex<float>::complex(const complex<double>& __c) : … { … }
inline _LIBCPP_CONSTEXPR complex<float>::complex(const complex<long double>& __c)
: … { … }
inline _LIBCPP_CONSTEXPR complex<double>::complex(const complex<float>& __c) : … { … }
inline _LIBCPP_CONSTEXPR complex<double>::complex(const complex<long double>& __c)
: … { … }
inline _LIBCPP_CONSTEXPR complex<long double>::complex(const complex<float>& __c)
: … { … }
inline _LIBCPP_CONSTEXPR complex<long double>::complex(const complex<double>& __c)
: … { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator+(const complex<_Tp>& __x, const _Tp& __y) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator+(const _Tp& __x, const complex<_Tp>& __y) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator-(const complex<_Tp>& __x, const _Tp& __y) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator-(const _Tp& __x, const complex<_Tp>& __y) { … }
template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator*(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { … }
template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator*(const complex<_Tp>& __x, const _Tp& __y) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator*(const _Tp& __x, const complex<_Tp>& __y) { … }
template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator/(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { … }
template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator/(const complex<_Tp>& __x, const _Tp& __y) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator/(const _Tp& __x, const complex<_Tp>& __y) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator+(const complex<_Tp>& __x) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator-(const complex<_Tp>& __x) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const complex<_Tp>& __x, const _Tp& __y) { … }
#if _LIBCPP_STD_VER <= 17
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const _Tp& __x, const complex<_Tp>& __y) {
return __x == __y.real() && 0 == __y.imag();
}
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) {
return !(__x == __y);
}
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator!=(const complex<_Tp>& __x, const _Tp& __y) {
return !(__x == __y);
}
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator!=(const _Tp& __x, const complex<_Tp>& __y) {
return !(__x == __y);
}
#endif
template <class _Tp, bool = is_integral<_Tp>::value, bool = is_floating_point<_Tp>::value >
struct __libcpp_complex_overload_traits { … };
__libcpp_complex_overload_traits<_Tp, true, false>;
__libcpp_complex_overload_traits<_Tp, false, true>;
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp real(const complex<_Tp>& __c) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __libcpp_complex_overload_traits<_Tp>::_ValueType
real(_Tp __re) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp imag(const complex<_Tp>& __c) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __libcpp_complex_overload_traits<_Tp>::_ValueType
imag(_Tp) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _Tp abs(const complex<_Tp>& __c) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _Tp arg(const complex<_Tp>& __c) { … }
template <class _Tp, __enable_if_t<is_same<_Tp, long double>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI long double arg(_Tp __re) { … }
template <class _Tp, __enable_if_t<is_integral<_Tp>::value || is_same<_Tp, double>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI double arg(_Tp __re) { … }
template <class _Tp, __enable_if_t<is_same<_Tp, float>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI float arg(_Tp __re) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp norm(const complex<_Tp>& __c) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __libcpp_complex_overload_traits<_Tp>::_ValueType
norm(_Tp __re) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> conj(const complex<_Tp>& __c) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
conj(_Tp __re) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) { … }
template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) { … }
template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = _Tp()) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log(const complex<_Tp>& __x) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const complex<_Tp>& __y) { … }
template <class _Tp, class _Up>
inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type>
pow(const complex<_Tp>& __x, const complex<_Up>& __y) { … }
template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Up>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) { … }
template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const _Tp& __x, const complex<_Up>& __y) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> __sqr(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> atan(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> sin(const complex<_Tp>& __x) { … }
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> cos(const complex<_Tp>& __x) { … }
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> tan(const complex<_Tp>& __x) { … }
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template <class _Tp, class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) { … }
template <class _Tp, class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) { … }
#endif
#if _LIBCPP_STD_VER >= 26
template <class _Tp>
struct tuple_size<complex<_Tp>> : integral_constant<size_t, 2> {};
template <size_t _Ip, class _Tp>
struct tuple_element<_Ip, complex<_Tp>> {
static_assert(_Ip < 2, "Index value is out of range.");
using type = _Tp;
};
template <size_t _Ip, class _Xp>
_LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>& __z) noexcept {
static_assert(_Ip < 2, "Index value is out of range.");
if constexpr (_Ip == 0) {
return __z.__re_;
} else {
return __z.__im_;
}
}
template <size_t _Ip, class _Xp>
_LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&& __z) noexcept {
static_assert(_Ip < 2, "Index value is out of range.");
if constexpr (_Ip == 0) {
return std::move(__z.__re_);
} else {
return std::move(__z.__im_);
}
}
template <size_t _Ip, class _Xp>
_LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>& __z) noexcept {
static_assert(_Ip < 2, "Index value is out of range.");
if constexpr (_Ip == 0) {
return __z.__re_;
} else {
return __z.__im_;
}
}
template <size_t _Ip, class _Xp>
_LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexcept {
static_assert(_Ip < 2, "Index value is out of range.");
if constexpr (_Ip == 0) {
return std::move(__z.__re_);
} else {
return std::move(__z.__im_);
}
}
#endif
#if _LIBCPP_STD_VER >= 14
inline namespace literals {
inline namespace complex_literals {
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<long double> operator""il(long double __im) { … }
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<long double> operator""il(unsigned long long __im) { … }
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<double> operator""i(long double __im) { … }
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<double> operator""i(unsigned long long __im) { … }
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(long double __im) { … }
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long long __im) { … }
}
}
#endif
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <iosfwd>
# include <stdexcept>
# include <type_traits>
#endif
#endif