10 SWIG and C++20

10.1 Introduction

This chapter gives you a brief overview about the SWIG implementation of the C++20 standard. Work has only just begun on adding C++20 support.

Compatibility note: SWIG-4.1.0 is the first version to support any C++20 features.

10.2 Core language changes

10.2.1 Spaceship operator

SWIG supports the spaceship operator <=> in constant expressions. To simplify handling of the return value type, it is currently treated as an integer rather than std::strong_ordering, etc. In practice we think that should do the right thing in most cases.

SWIG also recognises operator<=> which can be wrapped if renamed. There is not currently any default renaming for the operator or any attempt to automatically map it to a three-way comparison operator in any of the target languages.

10.2.2 Lambda templates

SWIG should parse lambda templates, but like non-templated lambdas they aren't currently wrapped.

10.2.3 Constexpr destructors

Destructors that are declared constexpr are parsed and handled like any other constructor. For example:

class DtorA {
public:
  constexpr ~DtorA() {}
};

10.3 Standard library changes