Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::complex<T>::real

      From cppreference.com
      <cpp‎ |numeric‎ |complex
       
       
       
       
      primary templatestd::complex<T>
      (1)
      T real()const;
      (until C++14)
      constexpr T real()const;
      (since C++14)
      (2)
      void real( T value);
      (until C++20)
      constexprvoid real( T value);
      (since C++20)
      specializationstd::complex<float>
      (1)
      float real()const;
      (until C++11)
      constexprfloat real()const;
      (since C++11)
      (2)
      void real(float value);
      (until C++20)
      constexprvoid real(float value);
      (since C++20)
      specializationstd::complex<double>
      (1)
      double real()const;
      (until C++11)
      constexprdouble real()const;
      (since C++11)
      (2)
      void real(double value);
      (until C++20)
      constexprvoid real(double value);
      (since C++20)
      specializationstd::complex<longdouble>
      (1)
      longdouble real()const;
      (until C++11)
      constexprlongdouble real()const;
      (since C++11)
      (2)
      void real(longdouble value);
      (until C++20)
      constexprvoid real(longdouble value);
      (since C++20)

      Accesses the real part of the complex number.

      1) Returns the real part.
      2) Sets the real part tovalue.

      Contents

      [edit]Parameters

      value - the value to set the real part to

      [edit]Return value

      1) The real part of*this.
      2) (none)

      [edit]Notes

      In C++11, overload(1) instd::complex specializations used to be specified withoutconst qualifier. However, in C++11, aconstexpr specifier used in a non-static member function impliesconst, and thus the behavior is as ifconst is specified.

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 387C++98the real part could not be set directlycan be set directly via a newreal overload

      [edit]See also

      returns the real part
      (function template)[edit]
      accesses the imaginary part of the complex number
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/numeric/complex/real&oldid=147508"

      [8]ページ先頭

      ©2009-2025 Movatter.jp