Commit Graph

2 Commits

Author SHA1 Message Date
William S Fulton 86b46b3649 C++17: parse user-defined deduction guides
A user-defined deduction guide steers class template argument deduction.
It is written at the same scope as the class template, either as a plain
declaration or, when generic, under a template parameter list:

    Box(int) -> Box<int>;
    template <typename T> Box(T) -> Box<T>;

A deduction guide is not a function: it has no body and emits no symbol,
and only steers argument deduction at compile time.  There is nothing for
SWIG to wrap, so a new deduction_guide grammar rule parses the guide and
discards it.  The optional explicit specifier and a C++20 trailing
requires-clause are accepted.  Previously any deduction guide resulted in
a syntax error.

Assisted-by: Claude Code (Opus 4.8)
2026-05-30 10:56:19 +01:00
William S Fulton 74f7b4bb48 C++17: skip class template argument deduction variables
A variable whose declared type is a bare class template name uses class
template argument deduction (CTAD), added in C++17 - the arguments are
deduced from the initializer using guides synthesised from the class's
constructors.  C++20 P1816 also allows CTAD for aggregates with no
deduction guide, e.g. 'Overloaded ov{...};'.  SWIG performs no template
argument deduction, so it cannot determine the instantiated type; it
previously treated the bare template name as a concrete type and
generated a wrapper naming the template without arguments, which does
not compile.

cDeclaration now detects this, issues Warning 347 and skips the
declaration.  Declarations alongside it are unaffected.

Assisted-by: Claude Code (Opus 4.8)
2026-05-30 00:51:25 +01:00