Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::complex<T>::complex

      From cppreference.com
      <cpp‎ |numeric‎ |complex
       
       
       
       
      Primary template (std::complex<T>)
      (1)
      complex(const T& re= T(),const T& im= T());
      (until C++14)
      constexpr complex(const T& re= T(),const T& im= T());
      (since C++14)
      (2)
      complex(const complex& other);
      (until C++14)
      constexpr complex(const complex& other);
      (since C++14)
      (until C++23)
      constexpr complex(const complex& other)=default;
      (since C++23)
      (3)
      template<class X>
      complex(const complex<X>& other);
      (until C++14)
      template<class X>
      constexpr complex(const complex<X>& other);
      (since C++14)
      (until C++23)
      template<class X>
      constexprexplicit(/* see below */) complex(const complex<X>& other);
      (since C++23)
      Standard explicit specializationstd::complex<float>(until C++23)
      (1)
      complex(float re=0.0f,float im=0.0f);
      (until C++11)
      constexpr complex(float re=0.0f,float im=0.0f);
      (since C++11)
      constexpr complex(const complex<float>& other)=default;
      (2)(since C++20)
      (3)
      explicit complex(const complex<double>& other);
      explicit complex(const complex<longdouble>& other);
      (until C++11)
      constexprexplicit complex(const complex<double>& other);
      constexprexplicit complex(const complex<longdouble>& other);
      (since C++11)
      Standard explicit specializationstd::complex<double>(until C++23)
      (1)
      complex(double re=0.0,double im=0.0);
      (until C++11)
      constexpr complex(double re=0.0,double im=0.0);
      (since C++11)
      constexpr complex(const complex<double>& other)=default;
      (2)(since C++20)
      (3)
      complex(const complex<float>& other);
      explicit complex(const complex<longdouble>& other);
      (until C++11)
      constexpr complex(const complex<float>& other);
      constexprexplicit complex(const complex<longdouble>& other);
      (since C++11)
      Standard explicit specializationstd::complex<longdouble>(until C++23)
      (1)
      complex(longdouble re= 0.0L,longdouble im= 0.0L);
      (until C++11)
      constexpr complex(longdouble re= 0.0L,longdouble im= 0.0L);
      (since C++11)
      constexpr complex(const complex<longdouble>& other)=default;
      (2)(since C++20)
      (3)
      complex(const complex<float>& other);
      complex(const complex<double>& other);
      (until C++11)
      constexpr complex(const complex<float>& other);
      constexpr complex(const complex<double>& other);
      (since C++11)

      Constructs thestd::complex object. The standard explicit specializations (std::complex<float>,std::complex<double> andstd::complex<longdouble>) have different constructor declarations from the main template.(until C++23)

      1) Constructs the complex number from real partre and imaginary partim.
      2) Copy constructor. Constructs the object with the copy of the contents ofother. The copy constructors are implicitly declared in the standard explicit specializations.(until C++20)
      3)Converting constructor. Constructs the object from a complex number of a different type.

      The main template provides a converting constructor template, while each standard explicit specialization provides two non-template constructors for the two other standard explicit specializations.

      The non-template constructors are converting constructors (i.e. non-explicit) if and only if the conversions of the real and imaginary parts are not narrowing.

      (until C++23)

      For the main template, the expression insideexplicit evaluates tofalse if and only if thefloating-point conversion rank ofT is greater than or equal to the floating-point conversion rank ofX.

      (since C++23)

      [edit]Parameters

      re - the real part
      im - the imaginary part
      other - another complex number to use as source

      [edit]Notes

      Since C++23, the copy constructor is required to betrivial in order to satisfy theTriviallyCopyable requirement, but implementations generally make it trivial in all modes.

      [edit]See also

      assigns the contents
      (public member function)[edit]
      astd::complex literal representing purely imaginary number
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/numeric/complex/complex&oldid=154487"

      [8]ページ先頭

      ©2009-2025 Movatter.jp