diff --git a/docs/standard-library/system-error-operators.md b/docs/standard-library/system-error-operators.md index ad43985bc5..58a4e804c3 100644 --- a/docs/standard-library/system-error-operators.md +++ b/docs/standard-library/system-error-operators.md @@ -1,13 +1,12 @@ --- -description: "Learn more about: operators" title: " operators" -ms.date: "11/04/2016" +description: "Learn more about: operators" +ms.date: "3/17/2025" f1_keywords: ["system_error/std::operator!=", "system_error/std::operator=="] -ms.assetid: c14edefb-bd8a-4e90-88d3-c59c98e6f73c --- # `` operators -## operator== +## `operator==` Tests if the object on the left side of the operator is equal to the object on the right side. @@ -24,11 +23,11 @@ bool operator==(const error_condition& left, ### Parameters -*left*\ -The object to be tested for equality. +*`left`*\ +The object to test for equality. -*right*\ -The object to be tested for equality. +*`right`*\ +The object to test for equality. ### Return Value @@ -38,7 +37,7 @@ The object to be tested for equality. This function returns `left.category() == right.category() && left.value() == right.value()`. -## operator!= +## `operator!=` Tests if the object on the left side of the operator is not equal to the object on the right side. @@ -51,15 +50,15 @@ bool operator!=(const error_condition& left, const error_condition& right); ### Parameters -*left*\ -The object to be tested for inequality. +*`left`*\ +The object to test for inequality. -*right*\ -The object to be tested for inequality. +*`right`*\ +The object to test for inequality. ### Return Value -**`true`** if the object passed in *left* is not equal to the object passed in *right*; otherwise **`false`**. +**`true`** if the object passed in *left* is not equal to the object passed in *`right`*; otherwise **`false`**. ### Remarks @@ -95,15 +94,15 @@ inline bool operator<( ### Parameters -*left*\ -The object to be compared. +*`left`*\ +The object to compare. -*right*\ -The object to be compared. +*`right`*\ +The object to compare. ### Return Value -**`true`** if the object passed in *left* is less than the object passed in *right*; Otherwise, **`false`**. +**`true`** if the object passed in *`left`* is less than the object passed in *`right`*; Otherwise, **`false`**. ### Remarks @@ -111,7 +110,42 @@ This function tests the error order. ## `operator<<` +Inserts an [`error_code`](error-code-class.md) object into the output stream. + ```cpp template - basic_ostream& operator<<(basic_ostream& os, const error_code& ec); +basic_ostream& operator<<(basic_ostream& os, const error_code& ec); +``` + +### Parameters + +*`os`*\ +The target output stream. + +*`ec`*\ +The `error_code` object to output. + +### Return Value + +A reference to the modified output stream. + +### Remarks + +This operator does the equivalent of `os << ec.category().name() << ':' << ec.value()`. + +### Example + +```cpp +#include +#include + +int main() +{ + std::error_code ec(1234, std::generic_category()); + std::cout << ec; +} +``` + +```Output +generic:1234 ```