diff --git a/docs/mkdocs/docs/api/basic_json/operator_ge.md b/docs/mkdocs/docs/api/basic_json/operator_ge.md index 54383c1e8..91334bc2c 100644 --- a/docs/mkdocs/docs/api/basic_json/operator_ge.md +++ b/docs/mkdocs/docs/api/basic_json/operator_ge.md @@ -60,6 +60,14 @@ Linear. 2. Comparing a `NaN` with another `NaN`. 3. Comparing a `NaN` and any other number. + For arrays and objects, the elements are compared in order. If the comparison reaches a `NaN` and a number (or + another `NaN`) before any other difference, the result depends on the language standard. Before C++20, the pair + counts as equivalent and the following elements (or the sizes) decide: for instance, `[NaN] < [1, NaN]` and + `[1] <= [NaN]` are `#!cpp true`. Since C++20, the whole comparison is unordered, and `<`, `<=`, `>`, and `>=` all + yield `#!cpp false`. Otherwise (for example `[1, NaN] < [2, NaN]`, or objects whose keys differ), the result is the + same for all language standards. The same program can therefore order such values differently when it is compiled + with a different language standard. + !!! note "Operator overload resolution" Since C++20 overload resolution will consider the _rewritten candidate_ generated from diff --git a/docs/mkdocs/docs/api/basic_json/operator_gt.md b/docs/mkdocs/docs/api/basic_json/operator_gt.md index dea5ef76c..d105fd9ab 100644 --- a/docs/mkdocs/docs/api/basic_json/operator_gt.md +++ b/docs/mkdocs/docs/api/basic_json/operator_gt.md @@ -60,6 +60,14 @@ Linear. 2. Comparing a `NaN` with another `NaN`. 3. Comparing a `NaN` and any other number. + For arrays and objects, the elements are compared in order. If the comparison reaches a `NaN` and a number (or + another `NaN`) before any other difference, the result depends on the language standard. Before C++20, the pair + counts as equivalent and the following elements (or the sizes) decide: for instance, `[NaN] < [1, NaN]` and + `[1] <= [NaN]` are `#!cpp true`. Since C++20, the whole comparison is unordered, and `<`, `<=`, `>`, and `>=` all + yield `#!cpp false`. Otherwise (for example `[1, NaN] < [2, NaN]`, or objects whose keys differ), the result is the + same for all language standards. The same program can therefore order such values differently when it is compiled + with a different language standard. + !!! note "Operator overload resolution" Since C++20 overload resolution will consider the _rewritten candidate_ generated from diff --git a/docs/mkdocs/docs/api/basic_json/operator_le.md b/docs/mkdocs/docs/api/basic_json/operator_le.md index 8818b221a..a9b2cd836 100644 --- a/docs/mkdocs/docs/api/basic_json/operator_le.md +++ b/docs/mkdocs/docs/api/basic_json/operator_le.md @@ -61,6 +61,14 @@ Linear. 2. Comparing a `NaN` with another `NaN`. 3. Comparing a `NaN` and any other number. + For arrays and objects, the elements are compared in order. If the comparison reaches a `NaN` and a number (or + another `NaN`) before any other difference, the result depends on the language standard. Before C++20, the pair + counts as equivalent and the following elements (or the sizes) decide: for instance, `[NaN] < [1, NaN]` and + `[1] <= [NaN]` are `#!cpp true`. Since C++20, the whole comparison is unordered, and `<`, `<=`, `>`, and `>=` all + yield `#!cpp false`. Otherwise (for example `[1, NaN] < [2, NaN]`, or objects whose keys differ), the result is the + same for all language standards. The same program can therefore order such values differently when it is compiled + with a different language standard. + !!! note "Operator overload resolution" Since C++20 overload resolution will consider the _rewritten candidate_ generated from diff --git a/docs/mkdocs/docs/api/basic_json/operator_lt.md b/docs/mkdocs/docs/api/basic_json/operator_lt.md index e18d591ca..f3ebd4d64 100644 --- a/docs/mkdocs/docs/api/basic_json/operator_lt.md +++ b/docs/mkdocs/docs/api/basic_json/operator_lt.md @@ -71,6 +71,14 @@ Linear. 2. Comparing a `NaN` with another `NaN`. 3. Comparing a `NaN` and any other number. + For arrays and objects, the elements are compared in order. If the comparison reaches a `NaN` and a number (or + another `NaN`) before any other difference, the result depends on the language standard. Before C++20, the pair + counts as equivalent and the following elements (or the sizes) decide: for instance, `[NaN] < [1, NaN]` and + `[1] <= [NaN]` are `#!cpp true`. Since C++20, the whole comparison is unordered, and `<`, `<=`, `>`, and `>=` all + yield `#!cpp false`. Otherwise (for example `[1, NaN] < [2, NaN]`, or objects whose keys differ), the result is the + same for all language standards. The same program can therefore order such values differently when it is compiled + with a different language standard. + !!! note "Operator overload resolution" Since C++20 overload resolution will consider the _rewritten candidate_ generated from diff --git a/docs/mkdocs/docs/api/basic_json/operator_spaceship.md b/docs/mkdocs/docs/api/basic_json/operator_spaceship.md index 7aed091ef..b85bda52f 100644 --- a/docs/mkdocs/docs/api/basic_json/operator_spaceship.md +++ b/docs/mkdocs/docs/api/basic_json/operator_spaceship.md @@ -55,6 +55,10 @@ Linear. 1. Comparing a `NaN` with itself. 2. Comparing a `NaN` with another `NaN`. 3. Comparing a `NaN` and any other number. + - For arrays and objects, the elements are compared in order. If the comparison reaches a `NaN` and a number (or + another `NaN`) before any other difference, the result is `std::partial_ordering::unordered`. (Without C++20, the + comparison operators `<`, `<=`, `>`, and `>=` use the comparison of the containers, which treats such a pair as + equivalent; see [**operator<**](operator_lt.md).) ## Examples