mirror of
https://github.com/nlohmann/json.git
synced 2026-10-16 19:18:12 +00:00
deploy: 4e294f4b18
This commit is contained in:
1 parent
dcc7a74a18
commit
98c9bea1d1
105 files changed
+537
-508
No files matched your search
@@ -3,7 +3,7 @@
|
||||
|
||||
<span class=k>template</span><span class=o><</span><span class=k>typename</span><span class=w> </span><span class=nc>ScalarType</span><span class=o>></span>
|
||||
<span class=n>std</span><span class=o>::</span><span class=n>partial_ordering</span><span class=w> </span><span class=k>operator</span><span class=o><=></span><span class=p>(</span><span class=k>const</span><span class=w> </span><span class=n>ScalarType</span><span class=w> </span><span class=n>rhs</span><span class=p>)</span><span class=w> </span><span class=k>const</span><span class=w> </span><span class=k>noexcept</span><span class=p>(</span><span class=cm>/* see below */</span><span class=p>);</span><span class=w> </span><span class=c1>// (2)</span>
|
||||
</code></pre></div> <ol> <li> <p>3-way compares two <abbr title="JavaScript Object Notation">JSON</abbr> values producing a result of type <code>std::partial_ordering</code> according to the following rules:</p> <ul> <li>Two <abbr title="JavaScript Object Notation">JSON</abbr> values compare with a result of <code>std::partial_ordering::unordered</code> if either value is discarded.</li> <li>If both <abbr title="JavaScript Object Notation">JSON</abbr> values are of the same type, the result is produced by 3-way comparing their stored values using their respective <code>operator<=></code>.</li> <li>Integer and floating-point numbers are converted to their common type and then 3-way compared using their respective <code>operator<=></code>. For instance, comparing an integer and a floating-point value will 3-way compare the first value converted to floating-point with the second value.</li> <li>Otherwise, yields a result by comparing the type (see <a href=../value_t/ ><code>value_t</code></a>).</li> </ul> </li> <li> <p>3-way compares a <abbr title="JavaScript Object Notation">JSON</abbr> value and a scalar or a scalar and a <abbr title="JavaScript Object Notation">JSON</abbr> value by converting the scalar to a <abbr title="JavaScript Object Notation">JSON</abbr> value and 3-way comparing both <abbr title="JavaScript Object Notation">JSON</abbr> values (see 1).</p> </li> </ol> <h2 id=template-parameters>Template parameters<a class=headerlink href=#template-parameters title="Permanent link">¶</a></h2> <dl> <dt><code>ScalarType</code></dt> <dd>a scalar type according to <code>std::is_scalar<ScalarType>::value</code></dd> </dl> <h2 id=parameters>Parameters<a class=headerlink href=#parameters title="Permanent link">¶</a></h2> <dl> <dt><code>rhs</code> (in)</dt> <dd>second value to consider </dd> </dl> <h2 id=return-value>Return value<a class=headerlink href=#return-value title="Permanent link">¶</a></h2> <p>the <code>std::partial_ordering</code> of the 3-way comparison of <code>*this</code> and <code>rhs</code></p> <h2 id=exception-safety>Exception safety<a class=headerlink href=#exception-safety title="Permanent link">¶</a></h2> <ol> <li>No-throw guarantee: this function never throws exceptions.</li> <li>No-throw guarantee if converting the scalar to a <abbr title="JavaScript Object Notation">JSON</abbr> value cannot throw, as for numbers, Booleans, and <code class=highlight><span class=nb>nullptr</span></code>; the function is <code class=highlight><span class=k>noexcept</span></code> exactly in that case. Otherwise, it throws what the conversion throws, for example <code>std::bad_alloc</code> when converting a string, or <a href=../../../home/exceptions/#jsonexceptionout_of_range410><code>out_of_range.410</code></a> for an enum value not mapped by <a href=../../macros/nlohmann_json_serialize_enum_strict/ ><code>NLOHMANN_JSON_SERIALIZE_ENUM_STRICT</code></a>.</li> </ol> <h2 id=complexity>Complexity<a class=headerlink href=#complexity title="Permanent link">¶</a></h2> <p>Linear.</p> <h2 id=notes>Notes<a class=headerlink href=#notes title="Permanent link">¶</a></h2> <div class="admonition note"> <p class=admonition-title>Comparing <code>NaN</code></p> <ul> <li><code>NaN</code> values are unordered within the domain of numbers. The following comparisons all yield <code>std::partial_ordering::unordered</code>:<ol> <li>Comparing a <code>NaN</code> with itself.</li> <li>Comparing a <code>NaN</code> with another <code>NaN</code>.</li> <li>Comparing a <code>NaN</code> and any other number.</li> </ol> </li> </ul> </div> <h2 id=examples>Examples<a class=headerlink href=#examples title="Permanent link">¶</a></h2> <details class=example> <summary>Example: (1) comparing <abbr title="JavaScript Object Notation">JSON</abbr> values</summary> <p>The example demonstrates comparing several <abbr title="JavaScript Object Notation">JSON</abbr> values.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><compare></span>
|
||||
</code></pre></div> <ol> <li> <p>3-way compares two <abbr title="JavaScript Object Notation">JSON</abbr> values producing a result of type <code>std::partial_ordering</code> according to the following rules:</p> <ul> <li>Two <abbr title="JavaScript Object Notation">JSON</abbr> values compare with a result of <code>std::partial_ordering::unordered</code> if either value is discarded.</li> <li>If both <abbr title="JavaScript Object Notation">JSON</abbr> values are of the same type, the result is produced by 3-way comparing their stored values using their respective <code>operator<=></code>.</li> <li>Integer and floating-point numbers are 3-way compared by their exact values, without converting the integer to floating-point. For instance, <code>9007199254740993</code> compares greater than <code>9007199254740992.0</code>.</li> <li>Otherwise, yields a result by comparing the type (see <a href=../value_t/ ><code>value_t</code></a>).</li> </ul> </li> <li> <p>3-way compares a <abbr title="JavaScript Object Notation">JSON</abbr> value and a scalar or a scalar and a <abbr title="JavaScript Object Notation">JSON</abbr> value by converting the scalar to a <abbr title="JavaScript Object Notation">JSON</abbr> value and 3-way comparing both <abbr title="JavaScript Object Notation">JSON</abbr> values (see 1).</p> </li> </ol> <h2 id=template-parameters>Template parameters<a class=headerlink href=#template-parameters title="Permanent link">¶</a></h2> <dl> <dt><code>ScalarType</code></dt> <dd>a scalar type according to <code>std::is_scalar<ScalarType>::value</code></dd> </dl> <h2 id=parameters>Parameters<a class=headerlink href=#parameters title="Permanent link">¶</a></h2> <dl> <dt><code>rhs</code> (in)</dt> <dd>second value to consider </dd> </dl> <h2 id=return-value>Return value<a class=headerlink href=#return-value title="Permanent link">¶</a></h2> <p>the <code>std::partial_ordering</code> of the 3-way comparison of <code>*this</code> and <code>rhs</code></p> <h2 id=exception-safety>Exception safety<a class=headerlink href=#exception-safety title="Permanent link">¶</a></h2> <ol> <li>No-throw guarantee: this function never throws exceptions.</li> <li>No-throw guarantee if converting the scalar to a <abbr title="JavaScript Object Notation">JSON</abbr> value cannot throw, as for numbers, Booleans, and <code class=highlight><span class=nb>nullptr</span></code>; the function is <code class=highlight><span class=k>noexcept</span></code> exactly in that case. Otherwise, it throws what the conversion throws, for example <code>std::bad_alloc</code> when converting a string, or <a href=../../../home/exceptions/#jsonexceptionout_of_range410><code>out_of_range.410</code></a> for an enum value not mapped by <a href=../../macros/nlohmann_json_serialize_enum_strict/ ><code>NLOHMANN_JSON_SERIALIZE_ENUM_STRICT</code></a>.</li> </ol> <h2 id=complexity>Complexity<a class=headerlink href=#complexity title="Permanent link">¶</a></h2> <p>Linear.</p> <h2 id=notes>Notes<a class=headerlink href=#notes title="Permanent link">¶</a></h2> <div class="admonition note"> <p class=admonition-title>Comparing <code>NaN</code></p> <ul> <li><code>NaN</code> values are unordered within the domain of numbers. The following comparisons all yield <code>std::partial_ordering::unordered</code>:<ol> <li>Comparing a <code>NaN</code> with itself.</li> <li>Comparing a <code>NaN</code> with another <code>NaN</code>.</li> <li>Comparing a <code>NaN</code> and any other number.</li> </ol> </li> </ul> </div> <h2 id=examples>Examples<a class=headerlink href=#examples title="Permanent link">¶</a></h2> <details class=example> <summary>Example: (1) comparing <abbr title="JavaScript Object Notation">JSON</abbr> values</summary> <p>The example demonstrates comparing several <abbr title="JavaScript Object Notation">JSON</abbr> values.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><compare></span>
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><nlohmann/json.hpp></span>
|
||||
|
||||
@@ -91,4 +91,4 @@
|
||||
<span class=mi>17</span><span class=w> </span><span class=err><=></span><span class=w> </span><span class=mf>17.000000</span><span class=w> </span><span class=p>:</span><span class=err>=</span><span class=w> </span><span class=err>equivale</span><span class=kc>nt</span>
|
||||
<span class=mi>17</span><span class=w> </span><span class=err><=></span><span class=w> </span><span class=kc>nan</span><span class=w> </span><span class=p>:</span><span class=err>=</span><span class=w> </span><span class=err>u</span><span class=kc>n</span><span class=err>ordered</span>
|
||||
<span class=s2>"17"</span><span class=w> </span><span class=err><=></span><span class=w> </span><span class=mi>17</span><span class=w> </span><span class=p>:</span><span class=err>=</span><span class=w> </span><span class=err>grea</span><span class=kc>ter</span>
|
||||
</code></pre></div> </details> <h2 id=see-also>See also<a class=headerlink href=#see-also title="Permanent link">¶</a></h2> <ul> <li><a href=../operator_eq/ ><strong>operator==</strong></a> - comparison: equal</li> <li><a href=../operator_ne/ ><strong>operator!=</strong></a> - comparison: not equal</li> <li><a href=../operator_lt/ ><strong>operator<</strong></a> - comparison: less than</li> <li><a href=../operator_le/ ><strong>operator<=</strong></a> - comparison: less than or equal</li> <li><a href=../operator_gt/ ><strong>operator></strong></a> - comparison: greater than</li> <li><a href=../operator_ge/ ><strong>operator>=</strong></a> - comparison: greater than or equal</li> </ul> <h2 id=version-history>Version history<a class=headerlink href=#version-history title="Permanent link">¶</a></h2> <ol> <li>Added in version 3.11.0.</li> <li>Added in version 3.11.0. Made conditionally <code class=highlight><span class=k>noexcept</span></code> in version 3.13.0 <span class=unreleased-version title="Not part of a release yet; the latest release is 3.12.0.">unreleased</span>; before, a throwing conversion called <code>std::terminate</code>.</li> </ol> <!-- https://squidfunk.github.io/mkdocs-material/reference/tooltips/#adding-a-glossary --> <aside class=md-source-file> <span class=md-source-file__fact> <span class=md-icon title="Last update"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M21 13.1c-.1 0-.3.1-.4.2l-1 1 2.1 2.1 1-1c.2-.2.2-.6 0-.8l-1.3-1.3c-.1-.1-.2-.2-.4-.2m-1.9 1.8-6.1 6V23h2.1l6.1-6.1zM12.5 7v5.2l4 2.4-1 1L11 13V7zM11 21.9c-5.1-.5-9-4.8-9-9.9C2 6.5 6.5 2 12 2c5.3 0 9.6 4.1 10 9.3-.3-.1-.6-.2-1-.2s-.7.1-1 .2C19.6 7.2 16.2 4 12 4c-4.4 0-8 3.6-8 8 0 4.1 3.1 7.5 7.1 7.9l-.1.2z"/></svg> </span> <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date" title="October 13, 2026 18:06:14 UTC">October 13, 2026</span> </span> </aside> </article> </div> <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type=button class="md-top md-icon" data-md-component=top hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class=md-footer> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-copyright> <div class=md-copyright__highlight> Copyright © 2013-2026 Niels Lohmann </div> </div> <div class=md-social> <a href="https://github.com/nlohmann" target="_blank" rel="noopener" title="github.com" class="md-social__link"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 512 512"><!-- Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M173.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M252.8 8C114.1 8 8 113.3 8 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C436.2 457.8 504 362.9 504 252 504 113.3 391.5 8 252.8 8M105.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg> </a> <a href="https://www.linkedin.com/in/nielslohmann/" target="_blank" rel="noopener" title="www.linkedin.com" class="md-social__link"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 448 512"><!-- Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SLine truncated
|
||||
</code></pre></div> </details> <h2 id=see-also>See also<a class=headerlink href=#see-also title="Permanent link">¶</a></h2> <ul> <li><a href=../operator_eq/ ><strong>operator==</strong></a> - comparison: equal</li> <li><a href=../operator_ne/ ><strong>operator!=</strong></a> - comparison: not equal</li> <li><a href=../operator_lt/ ><strong>operator<</strong></a> - comparison: less than</li> <li><a href=../operator_le/ ><strong>operator<=</strong></a> - comparison: less than or equal</li> <li><a href=../operator_gt/ ><strong>operator></strong></a> - comparison: greater than</li> <li><a href=../operator_ge/ ><strong>operator>=</strong></a> - comparison: greater than or equal</li> </ul> <h2 id=version-history>Version history<a class=headerlink href=#version-history title="Permanent link">¶</a></h2> <ol> <li>Added in version 3.11.0.</li> <li>Added in version 3.11.0. Made conditionally <code class=highlight><span class=k>noexcept</span></code> in version 3.13.0 <span class=unreleased-version title="Not part of a release yet; the latest release is 3.12.0.">unreleased</span>; before, a throwing conversion called <code>std::terminate</code>.</li> </ol> <!-- https://squidfunk.github.io/mkdocs-material/reference/tooltips/#adding-a-glossary --> <aside class=md-source-file> <span class=md-source-file__fact> <span class=md-icon title="Last update"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M21 13.1c-.1 0-.3.1-.4.2l-1 1 2.1 2.1 1-1c.2-.2.2-.6 0-.8l-1.3-1.3c-.1-.1-.2-.2-.4-.2m-1.9 1.8-6.1 6V23h2.1l6.1-6.1zM12.5 7v5.2l4 2.4-1 1L11 13V7zM11 21.9c-5.1-.5-9-4.8-9-9.9C2 6.5 6.5 2 12 2c5.3 0 9.6 4.1 10 9.3-.3-.1-.6-.2-1-.2s-.7.1-1 .2C19.6 7.2 16.2 4 12 4c-4.4 0-8 3.6-8 8 0 4.1 3.1 7.5 7.1 7.9l-.1.2z"/></svg> </span> <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date" title="October 14, 2026 15:40:55 UTC">October 14, 2026</span> </span> </aside> </article> </div> <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type=button class="md-top md-icon" data-md-component=top hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class=md-footer> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-copyright> <div class=md-copyright__highlight> Copyright © 2013-2026 Niels Lohmann </div> </div> <div class=md-social> <a href="https://github.com/nlohmann" target="_blank" rel="noopener" title="github.com" class="md-social__link"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 512 512"><!-- Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M173.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M252.8 8C114.1 8 8 113.3 8 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C436.2 457.8 504 362.9 504 252 504 113.3 391.5 8 252.8 8M105.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg> </a> <a href="https://www.linkedin.com/in/nielslohmann/" target="_blank" rel="noopener" title="www.linkedin.com" class="md-social__link"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 448 512"><!-- Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SLine truncated
|
||||
@@ -12,7 +12,7 @@ std::partial_ordering operator<=>(const ScalarType rhs) const noexcept(/* see be
|
||||
|
||||
- Two JSON values compare with a result of `std::partial_ordering::unordered` if either value is discarded.
|
||||
- If both JSON values are of the same type, the result is produced by 3-way comparing their stored values using their respective `operator<=>`.
|
||||
- Integer and floating-point numbers are converted to their common type and then 3-way compared using their respective `operator<=>`. For instance, comparing an integer and a floating-point value will 3-way compare the first value converted to floating-point with the second value.
|
||||
- Integer and floating-point numbers are 3-way compared by their exact values, without converting the integer to floating-point. For instance, `9007199254740993` compares greater than `9007199254740992.0`.
|
||||
- Otherwise, yields a result by comparing the type (see [`value_t`](https://json.nlohmann.me/api/basic_json/value_t/index.md)).
|
||||
|
||||
1. 3-way compares a JSON value and a scalar or a scalar and a JSON value by converting the scalar to a JSON value and 3-way comparing both JSON values (see 1).
|
||||
|
||||
Reference in new issue
Block a user