std::complex<T>::real
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Numerics library
Interpolations
Generic numeric operations
C-style checked integer arithmetic
Mathematical special functions (C++17)
Mathematical constants (C++20)
Basic linear algebra algorithms (C++26)
Data-parallel types (SIMD) (C++26)
Floating-point environment (C++11)
Bit manipulation (C++20)
Saturation arithmetic (C++26)
(C++17)
(C++17)
(C++20)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++26)
primary template std::complex <T>
(1)
T real() const;
(until C++14)
constexpr T real() const;
(since C++14)
(2)
void real( T value );
(until C++20)
constexpr void real( T value );
(since C++20)
specialization std::complex <float>
(1)
float real() const;
(until C++11)
constexpr float real() const;
(since C++11)
(2)
void real( float value );
(until C++20)
constexpr void real( float value );
(since C++20)
specialization std::complex <double>
(1)
double real() const;
(until C++11)
constexpr double real() const;
(since C++11)
(2)
void real( double value );
(until C++20)
constexpr void real( double value );
(since C++20)
specialization std::complex <long double>
(1)
long double real() const;
(until C++11)
constexpr long double real() const;
(since C++11)
(2)
void real( long double value );
(until C++20)
constexpr void real( long double value );
(since C++20)
Accesses the real part of the complex number.
1) Returns the real part.
2) Sets the real part to value.
[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) in std::complex specializations used to be specified without const qualifier. However, in C++11, a constexpr specifier used in a non-static member function implies const, and thus the behavior is as if const is specified.
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 387 | C++98 | the real part could not be set directly | can be set directly via a new real overload
|