# 10 SWIG and C++20

- Introduction
- Core language changes
  - Spaceship operator
  - Lambda templates
  - Constexpr destructors
- Preprocessor changes
  - __VA_OPT__()
- Standard library changes

## 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 Preprocessor changes

### 10.3.1 __VA_OPT__()

Support for `__VA_OPT__()` was added in SWIG 4.3.0.

## 10.4 Standard library changes