Commit Graph

1 Commits

Author SHA1 Message Date
William S Fulton 7e282b8b16 C++17: parse and support pack expansion in a using-declaration
Accept 'using Ts::name...;' inside a class template (P0195), so the
canonical 'Overloaded' helper used with std::visit on a std::variant
becomes wrappable:

  template <typename... Ts>
  struct Overloaded : Ts... {
    using Ts::operator()...;
  };

Parser: a new grammar rule in parser.y emits a 'using' node with the
'pack' flag set, mirroring the sibling using-decl rules.  The pack name
(e.g. 'Ts') is unresolvable at parse time, so add_symbols has nothing
concrete to register; the placeholder node carries the pack flag
through to template instantiation.

Template instantiation: cparse_template_expand detects the 'pack' flag
and expands the node into one concrete using-declaration per base type,
each then processed by the ordinary 'using' path.  An empty pack
introduces no names ([temp.variadic]), so the placeholder node is
detached with removeNode(); a DohIncref/Delete pair guards the node's
refcount across the unlink, and the class child loop saves nextSibling
before recursing so iteration survives the detach.

The testcase wraps %rename(call) *::operator() and instantiates the
helper with two functor bases, a nested-qualifier base
('using Base<Ts>::operator()...;'), and empty packs - the empty cases
exercise node removal, including one with member methods either side of
the using-decl to verify the sibling chain stays intact across removal.

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