Skip to content

Commit 8ac274f

Browse files
authored
Improve <system_error> operators reference
1 parent 32361f2 commit 8ac274f

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

docs/standard-library/system-error-operators.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
---
2-
description: "Learn more about: <system_error> operators"
32
title: "<system_error> operators"
3+
description: "Learn more about: <system_error> operators"
44
ms.date: "11/04/2016"
55
f1_keywords: ["system_error/std::operator!=", "system_error/std::operator=="]
6-
ms.assetid: c14edefb-bd8a-4e90-88d3-c59c98e6f73c
76
---
87
# `<system_error>` operators
98

10-
## <a name="op_eq_eq"></a> operator==
9+
## <a name="op_eq_eq"></a> `operator==`
1110

1211
Tests if the object on the left side of the operator is equal to the object on the right side.
1312

@@ -38,7 +37,7 @@ The object to be tested for equality.
3837

3938
This function returns `left.category() == right.category() && left.value() == right.value()`.
4039

41-
## <a name="op_neq"></a> operator!=
40+
## <a name="op_neq"></a> `operator!=`
4241

4342
Tests if the object on the left side of the operator is not equal to the object on the right side.
4443

@@ -111,7 +110,42 @@ This function tests the error order.
111110

112111
## <a name="op_ostream"></a> `operator<<`
113112

113+
Inserts an [`error_code`](error-code-class.md) object into the output stream.
114+
114115
```cpp
115116
template <class charT, class traits>
116-
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const error_code& ec);
117+
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const error_code& ec);
118+
```
119+
120+
### Parameters
121+
122+
*os*\
123+
The target output stream.
124+
125+
*ec*\
126+
The `error_code` object to be output.
127+
128+
### Return Value
129+
130+
A reference to the modified output stream.
131+
132+
### Remarks
133+
134+
This operator does the equivalent of `os << ec.category().name() << ':' << ec.value()`.
135+
136+
### Example
137+
138+
```cpp
139+
#include <iostream>
140+
#include <system_error>
141+
142+
int main()
143+
{
144+
std::error_code ec(1234, std::generic_category());
145+
std::cout << ec;
146+
}
147+
```
148+
149+
```Output
150+
generic:1234
117151
```

0 commit comments

Comments
 (0)