mirror of https://github.com/swig/swig.git
1 Commits
| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
c0754fbde2 |
Add test coverage and docs for alias templates as a base class and using-declaration qualifier
The test suite previously only exercised C++11 alias templates as function return
types (cpp11_alias_templates). These add coverage for an alias template instantiation
used in inheritance positions:
- cpp11_alias_template_inheritance: an identity alias template as a base with a member
using-declaration, an identity alias whose inherited enum is imported through the alias
qualifier (with the alias also naming a function parameter type), a non-identity alias
as the base of a class template where the using-declaration imports an overload that
merges with a local overload, and an inheriting constructor whose scope qualifier is an
alias template
- cpp17_using_pack_alias_template: a C++17 using-declaration pack over an alias template
base pack, both for inherited member functions ('using Identity<Ts>::g...;') and for
inherited constructors ('using Identity<Ts>::Identity...;') - the alias template
analogue of cpp17_inheriting_constructors_pack, which inherits through direct bases
Each follows the documented pattern: the underlying template is instantiated with a
named %template and the alias instantiation is registered with an empty %template(),
after which the alias resolves in these positions just like the underlying type.
A new using_member_typedef_overload test covers the related typedef-qualifier cases: an
overload imported through a typedef-to-template-instantiation qualifier that merges with a
local overload, and an inherited enum imported through a typedef qualifier.
Investigated as issue #3478: an alias template used as a base or using-declaration
qualifier appears to be unresolved (Warning 401 / Warning 315), but this is the
documented requirement that the alias instantiation be registered with %template();
it is not a SWIG defect.
In cpp17_using_pack_alias_template the Over method-pack overloads are ignored for D only
('#if defined(SWIGD) %ignore Over<A, B>::g;'): D wraps multiple inheritance as single
inheritance plus mix-in methods and marks the g(int) overload inherited from the second
base 'override', which ldmd2 rejects. The class is still wrapped for D and every other
language exercises the overloads. For Visual C++ the alias-template-as-base-pack classes
are guarded with '#ifndef _MSC_VER', falling back to the equivalent direct 'Ts...' base
(MSVC rejects an alias template base in a pack expansion with C3770); SWIG still parses and
wraps the alias form so coverage is unchanged, mirroring cpp17_using_typename_pack.
The C++11 chapter's 'Type alias and alias templates' section is split into separate
'Type aliases' and 'Alias templates' sections, and the alias template section is
rewritten to explain the two-%template requirement and the base class / using-declaration
usage that was previously only shown for return types.
The swig-doc and swig-test skills gain a note that code examples and .i test cases must
not place a class or struct definition on a single line. The swig-test skill also gains
guidance on handling a failure in a single target language (fix or work around it in that
language rather than excluding the test, except for experimental backends) and on
reporting which languages and tests were run.
Assisted-by: Claude Opus 4.8
|