tmp/tmp6ao0wmsl/{from.md → to.md}
RENAMED
|
@@ -2,73 +2,67 @@
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<class T> complex<T> operator+(const complex<T>& lhs);
|
| 5 |
```
|
| 6 |
|
| 7 |
-
*Remarks:* unary operator.
|
| 8 |
-
|
| 9 |
*Returns:* `complex<T>(lhs)`.
|
| 10 |
|
|
|
|
|
|
|
| 11 |
``` cpp
|
| 12 |
-
template<class T>
|
| 13 |
-
complex<T> operator+(const complex<T>& lhs, const complex<T>& rhs);
|
| 14 |
template<class T> complex<T> operator+(const complex<T>& lhs, const T& rhs);
|
| 15 |
template<class T> complex<T> operator+(const T& lhs, const complex<T>& rhs);
|
| 16 |
```
|
| 17 |
|
| 18 |
*Returns:* `complex<T>(lhs) += rhs`.
|
| 19 |
|
| 20 |
``` cpp
|
| 21 |
template<class T> complex<T> operator-(const complex<T>& lhs);
|
| 22 |
```
|
| 23 |
|
| 24 |
-
*Remarks:* unary operator.
|
| 25 |
-
|
| 26 |
*Returns:* `complex<T>(-lhs.real(),-lhs.imag())`.
|
| 27 |
|
|
|
|
|
|
|
| 28 |
``` cpp
|
| 29 |
-
template<class T>
|
| 30 |
-
complex<T> operator-(const complex<T>& lhs, const complex<T>& rhs);
|
| 31 |
template<class T> complex<T> operator-(const complex<T>& lhs, const T& rhs);
|
| 32 |
template<class T> complex<T> operator-(const T& lhs, const complex<T>& rhs);
|
| 33 |
```
|
| 34 |
|
| 35 |
*Returns:* `complex<T>(lhs) -= rhs`.
|
| 36 |
|
| 37 |
``` cpp
|
| 38 |
-
template<class T>
|
| 39 |
-
complex<T> operator*(const complex<T>& lhs, const complex<T>& rhs);
|
| 40 |
template<class T> complex<T> operator*(const complex<T>& lhs, const T& rhs);
|
| 41 |
template<class T> complex<T> operator*(const T& lhs, const complex<T>& rhs);
|
| 42 |
```
|
| 43 |
|
| 44 |
*Returns:* `complex<T>(lhs) *= rhs`.
|
| 45 |
|
| 46 |
``` cpp
|
| 47 |
-
template<class T>
|
| 48 |
-
complex<T> operator/(const complex<T>& lhs, const complex<T>& rhs);
|
| 49 |
template<class T> complex<T> operator/(const complex<T>& lhs, const T& rhs);
|
| 50 |
template<class T> complex<T> operator/(const T& lhs, const complex<T>& rhs);
|
| 51 |
```
|
| 52 |
|
| 53 |
*Returns:* `complex<T>(lhs) /= rhs`.
|
| 54 |
|
| 55 |
``` cpp
|
| 56 |
-
template<class T>
|
| 57 |
-
constexpr bool operator==(const complex<T>& lhs, const complex<T>& rhs);
|
| 58 |
template<class T> constexpr bool operator==(const complex<T>& lhs, const T& rhs);
|
| 59 |
template<class T> constexpr bool operator==(const T& lhs, const complex<T>& rhs);
|
| 60 |
```
|
| 61 |
|
| 62 |
*Returns:* `lhs.real() == rhs.real() && lhs.imag() == rhs.imag()`.
|
| 63 |
|
| 64 |
*Remarks:* The imaginary part is assumed to be `T()`, or 0.0, for the
|
| 65 |
`T` arguments.
|
| 66 |
|
| 67 |
``` cpp
|
| 68 |
-
template<class T>
|
| 69 |
-
constexpr bool operator!=(const complex<T>& lhs, const complex<T>& rhs);
|
| 70 |
template<class T> constexpr bool operator!=(const complex<T>& lhs, const T& rhs);
|
| 71 |
template<class T> constexpr bool operator!=(const T& lhs, const complex<T>& rhs);
|
| 72 |
```
|
| 73 |
|
| 74 |
*Returns:* `rhs.real() != lhs.real() || rhs.imag() != lhs.imag()`.
|
|
@@ -77,16 +71,16 @@ template<class T> constexpr bool operator!=(const T& lhs, const complex<T>& rhs)
|
|
| 77 |
template<class T, class charT, class traits>
|
| 78 |
basic_istream<charT, traits>&
|
| 79 |
operator>>(basic_istream<charT, traits>& is, complex<T>& x);
|
| 80 |
```
|
| 81 |
|
|
|
|
|
|
|
| 82 |
*Effects:* Extracts a complex number `x` of the form: `u`, `(u)`, or
|
| 83 |
`(u,v)`, where `u` is the real part and `v` is the imaginary
|
| 84 |
part ([[istream.formatted]]).
|
| 85 |
|
| 86 |
-
*Requires:* The input values shall be convertible to `T`.
|
| 87 |
-
|
| 88 |
If bad input is encountered, calls `is.setstate(ios_base::failbit)`
|
| 89 |
(which may throw `ios::failure` ([[iostate.flags]])).
|
| 90 |
|
| 91 |
*Returns:* `is`.
|
| 92 |
|
|
@@ -98,27 +92,23 @@ the same for each of the simpler extractions.
|
|
| 98 |
template<class T, class charT, class traits>
|
| 99 |
basic_ostream<charT, traits>&
|
| 100 |
operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
|
| 101 |
```
|
| 102 |
|
| 103 |
-
*Effects:*
|
| 104 |
were implemented as follows:
|
| 105 |
|
| 106 |
``` cpp
|
| 107 |
-
template<class T, class charT, class traits>
|
| 108 |
-
basic_ostream<charT, traits>&
|
| 109 |
-
operator<<(basic_ostream<charT, traits>& o, const complex<T>& x) {
|
| 110 |
basic_ostringstream<charT, traits> s;
|
| 111 |
s.flags(o.flags());
|
| 112 |
s.imbue(o.getloc());
|
| 113 |
s.precision(o.precision());
|
| 114 |
s << '(' << x.real() << "," << x.imag() << ')';
|
| 115 |
return o << s.str();
|
| 116 |
-
}
|
| 117 |
```
|
| 118 |
|
| 119 |
-
*Note
|
| 120 |
-
the use of comma as a field separator can be ambiguous.
|
| 121 |
-
`
|
| 122 |
-
explicit decimal point character; as a result, all inserted sequences
|
| 123 |
-
complex numbers can be extracted unambiguously.
|
| 124 |
|
|
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<class T> complex<T> operator+(const complex<T>& lhs);
|
| 5 |
```
|
| 6 |
|
|
|
|
|
|
|
| 7 |
*Returns:* `complex<T>(lhs)`.
|
| 8 |
|
| 9 |
+
*Remarks:* unary operator.
|
| 10 |
+
|
| 11 |
``` cpp
|
| 12 |
+
template<class T> complex<T> operator+(const complex<T>& lhs, const complex<T>& rhs);
|
|
|
|
| 13 |
template<class T> complex<T> operator+(const complex<T>& lhs, const T& rhs);
|
| 14 |
template<class T> complex<T> operator+(const T& lhs, const complex<T>& rhs);
|
| 15 |
```
|
| 16 |
|
| 17 |
*Returns:* `complex<T>(lhs) += rhs`.
|
| 18 |
|
| 19 |
``` cpp
|
| 20 |
template<class T> complex<T> operator-(const complex<T>& lhs);
|
| 21 |
```
|
| 22 |
|
|
|
|
|
|
|
| 23 |
*Returns:* `complex<T>(-lhs.real(),-lhs.imag())`.
|
| 24 |
|
| 25 |
+
*Remarks:* unary operator.
|
| 26 |
+
|
| 27 |
``` cpp
|
| 28 |
+
template<class T> complex<T> operator-(const complex<T>& lhs, const complex<T>& rhs);
|
|
|
|
| 29 |
template<class T> complex<T> operator-(const complex<T>& lhs, const T& rhs);
|
| 30 |
template<class T> complex<T> operator-(const T& lhs, const complex<T>& rhs);
|
| 31 |
```
|
| 32 |
|
| 33 |
*Returns:* `complex<T>(lhs) -= rhs`.
|
| 34 |
|
| 35 |
``` cpp
|
| 36 |
+
template<class T> complex<T> operator*(const complex<T>& lhs, const complex<T>& rhs);
|
|
|
|
| 37 |
template<class T> complex<T> operator*(const complex<T>& lhs, const T& rhs);
|
| 38 |
template<class T> complex<T> operator*(const T& lhs, const complex<T>& rhs);
|
| 39 |
```
|
| 40 |
|
| 41 |
*Returns:* `complex<T>(lhs) *= rhs`.
|
| 42 |
|
| 43 |
``` cpp
|
| 44 |
+
template<class T> complex<T> operator/(const complex<T>& lhs, const complex<T>& rhs);
|
|
|
|
| 45 |
template<class T> complex<T> operator/(const complex<T>& lhs, const T& rhs);
|
| 46 |
template<class T> complex<T> operator/(const T& lhs, const complex<T>& rhs);
|
| 47 |
```
|
| 48 |
|
| 49 |
*Returns:* `complex<T>(lhs) /= rhs`.
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
+
template<class T> constexpr bool operator==(const complex<T>& lhs, const complex<T>& rhs);
|
|
|
|
| 53 |
template<class T> constexpr bool operator==(const complex<T>& lhs, const T& rhs);
|
| 54 |
template<class T> constexpr bool operator==(const T& lhs, const complex<T>& rhs);
|
| 55 |
```
|
| 56 |
|
| 57 |
*Returns:* `lhs.real() == rhs.real() && lhs.imag() == rhs.imag()`.
|
| 58 |
|
| 59 |
*Remarks:* The imaginary part is assumed to be `T()`, or 0.0, for the
|
| 60 |
`T` arguments.
|
| 61 |
|
| 62 |
``` cpp
|
| 63 |
+
template<class T> constexpr bool operator!=(const complex<T>& lhs, const complex<T>& rhs);
|
|
|
|
| 64 |
template<class T> constexpr bool operator!=(const complex<T>& lhs, const T& rhs);
|
| 65 |
template<class T> constexpr bool operator!=(const T& lhs, const complex<T>& rhs);
|
| 66 |
```
|
| 67 |
|
| 68 |
*Returns:* `rhs.real() != lhs.real() || rhs.imag() != lhs.imag()`.
|
|
|
|
| 71 |
template<class T, class charT, class traits>
|
| 72 |
basic_istream<charT, traits>&
|
| 73 |
operator>>(basic_istream<charT, traits>& is, complex<T>& x);
|
| 74 |
```
|
| 75 |
|
| 76 |
+
*Requires:* The input values shall be convertible to `T`.
|
| 77 |
+
|
| 78 |
*Effects:* Extracts a complex number `x` of the form: `u`, `(u)`, or
|
| 79 |
`(u,v)`, where `u` is the real part and `v` is the imaginary
|
| 80 |
part ([[istream.formatted]]).
|
| 81 |
|
|
|
|
|
|
|
| 82 |
If bad input is encountered, calls `is.setstate(ios_base::failbit)`
|
| 83 |
(which may throw `ios::failure` ([[iostate.flags]])).
|
| 84 |
|
| 85 |
*Returns:* `is`.
|
| 86 |
|
|
|
|
| 92 |
template<class T, class charT, class traits>
|
| 93 |
basic_ostream<charT, traits>&
|
| 94 |
operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
|
| 95 |
```
|
| 96 |
|
| 97 |
+
*Effects:* Inserts the complex number `x` onto the stream `o` as if it
|
| 98 |
were implemented as follows:
|
| 99 |
|
| 100 |
``` cpp
|
|
|
|
|
|
|
|
|
|
| 101 |
basic_ostringstream<charT, traits> s;
|
| 102 |
s.flags(o.flags());
|
| 103 |
s.imbue(o.getloc());
|
| 104 |
s.precision(o.precision());
|
| 105 |
s << '(' << x.real() << "," << x.imag() << ')';
|
| 106 |
return o << s.str();
|
|
|
|
| 107 |
```
|
| 108 |
|
| 109 |
+
[*Note 1*: In a locale in which comma is used as a decimal point
|
| 110 |
+
character, the use of comma as a field separator can be ambiguous.
|
| 111 |
+
Inserting `showpoint` into the output stream forces all outputs to show
|
| 112 |
+
an explicit decimal point character; as a result, all inserted sequences
|
| 113 |
+
of complex numbers can be extracted unambiguously. — *end note*]
|
| 114 |
|