Namespaces
Variants

Standard library header <complex>

From cppreference.net
Standard library headers

此头文件是 数值 库的组成部分。

目录

复数类型
(类模板)

函数

操作
对复数应用一元运算符
(函数模板)
对两个复数或一个复数与标量执行复数算术运算
(函数模板)
(C++20 中移除)
比较两个复数或一个复数与标量
(函数模板)
序列化与反序列化复数
(函数模板)
返回实部
(函数模板)
返回虚部
(函数模板)
返回复数的模
(函数模板)
返回相位角
(函数模板)
返回模的平方
(函数模板)
返回复共轭
(函数模板)
(C++11)
返回黎曼球面上的投影
(函数模板)
根据模和相位角构造复数
(函数模板)
指数函数
复数以 e 为底的指数
(函数模板)
沿负实轴分割的复自然对数
(函数模板)
沿负实轴分割的复常用对数
(函数模板)
幂函数
复幂运算,一个或两个参数可以是复数
(函数模板)
右半平面范围内的复平方根
(函数模板)
三角函数
计算复数的正弦 ( sin(z) )
(函数模板)
计算复数的余弦 ( cos(z) )
(函数模板)
计算复数的正切 ( tan(z) )
(函数模板)
计算复数的反正弦 (

概要

namespace std {
    template<class T> class complex;
    template<> class complex<float>;
    template<> class complex<double>;
    template<> class complex<long double>;
    // 运算符:
    template<class T> constexpr complex<T> operator+(
        const complex<T>&, const complex<T>&);
    template<class T> constexpr complex<T> operator+(const complex<T>&, const T&);
    template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
    template<class T> constexpr complex<T> operator-(
        const complex<T>&, const complex<T>&);
    template<class T> constexpr complex<T> operator-(const complex<T>&, const T&);
    template<class T> constexpr complex<T> operator-(const T&, const complex<T>&);
    template<class T> constexpr complex<T> operator*(
        const complex<T>&, const complex<T>&);
    template<class T> constexpr complex<T> operator*(const complex<T>&, const T&);
    template<class T> constexpr complex<T> operator*(const T&, const complex<T>&);
    template<class T> constexpr complex<T> operator/(
        const complex<T>&, const complex<T>&);
    template<class T> constexpr complex<T> operator/(const complex<T>&, const T&);
    template<class T> constexpr complex<T> operator/(const T&, const complex<T>&);
    template<class T> constexpr complex<T> operator+(const complex<T>&);
    template<class T> constexpr complex<T> operator-(const complex<T>&);
    template<class T> constexpr bool operator==(const complex<T>&, const complex<T>&);
    template<class T> constexpr bool operator==(const complex<T>&, const T&);
    template<class T> constexpr bool operator==(const T&, const complex<T>&);
    template<class T> constexpr bool operator!=(const complex<T>&, const complex<T>&);
    template<class T> constexpr bool operator!=(const complex<T>&, const T&);
    template<class T> constexpr bool operator!=(const T&, const complex<T>&);
    template<class T, class CharT, class Traits>
    basic_istream<CharT, Traits>&amp

std::complex

template<class T>
class complex {
public:
    typedef T value_type;
    constexpr complex(const T& re = T(), const T& im = T());
    constexpr complex(const complex&) = default;
    template<class X> constexpr explicit(/* 参见构造函数页面 */)
        complex(const complex<X>&);
    constexpr T real() const;
    constexpr void real(T);
    constexpr T imag() const;
    constexpr void imag(T);
    constexpr complex<T>& operator= (const T&);
    constexpr complex<T>& operator+=(const T&);
    constexpr complex<T>& operator-=(const T&);
    constexpr complex<T>& operator*=(const T&);
    constexpr complex<T>& operator/=(const T&);
    constexpr complex& operator=(const complex&);
    template<class X> constexpr complex<T>& operator= (const complex<X>&);
    template<class X> constexpr complex<T>& operator+=(const complex<X>&);
    template<class X> constexpr complex<T>& operator-=(const complex<X>&);
    template<class X> constexpr complex<T>& operator*=(const complex<X>&);
    template<class X> constexpr complex<T>& operator/=(const complex<X>&);
};

缺陷报告

下列行为变更缺陷报告被追溯应用于先前发布的 C++ 标准。

DR 适用范围 发布时的行为 正确行为
LWG 79 C++98 polar 函数的第二个参数的默认参数
在概要说明中缺失
已添加