Fix spaceship operator bugs, document, add tests

Remove some erroneously added brackets_increment() calls.

Reject <=> in preprocessor expressions with a clear error message (it
seems it isn't supported here - clang and gcc don't at least).

The type returned by `<=>` is not `bool`.  We pretend it's
`int` for now, which should work for how it's likely to be used
in constant expressions.

Fixes #1622
This commit is contained in:
Olly Betts 2022-03-09 10:08:17 +13:00
commit 02b4bd8eca
10 changed files with 91 additions and 7 deletions

View file

@ -34,6 +34,21 @@ Work has only just begun on adding C++20 support.
<H2><a name="CPlusPlus20_core_language_changes">10.2 Core language changes</a></H2>
<H3><a name="CPlusPlus20_spaceship_operator">10.2.1 Spaceship operator</a></H3>
<p>
SWIG supports the spaceship operator <tt>&lt;=&gt;</tt> in constant
expressions. To simplifying handling the return value is currently
treated as an integer rather than <tt>std::strong_ordering</tt>, etc.
In practice we think that should do the right thing in most cases.
</p>
<p>
SWIG also recognises <tt>operator&lt;=&gt;</tt> which can be wrapped
if renamed. There's not currently any default renaming for the operator
or attempts to automatically map it to a three-way comparison operator
in any target languages that have one.
</p>
<H2><a name="CPlusPlus20_standard_library_changes">10.3 Standard library changes</a></H2>