[all-commits] [llvm/llvm-project] b7df9a: [clang] Implement provisional wording for CWG2398 ...

Matheus Izvekov via All-commits all-commits at lists.llvm.org
Wed May 1 22:09:19 PDT 2024


  Branch: refs/heads/users/mizvekov/clang-cwg2398-disambiguate-packs
  Home:   https://github.com/llvm/llvm-project
  Commit: b7df9a342724479e129af252f2ff37229f30d41b
      https://github.com/llvm/llvm-project/commit/b7df9a342724479e129af252f2ff37229f30d41b
  Author: Matheus Izvekov <mizvekov at gmail.com>
  Date:   2024-05-02 (Thu, 02 May 2024)

  Changed paths:
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaTemplateDeduction.cpp
    M clang/test/SemaTemplate/cwg2398.cpp

  Log Message:
  -----------
  [clang] Implement provisional wording for CWG2398 regarding packs

This solves some ambuguity introduced in P0522 regarding how
template template parameters are partially ordered, and should reduce
the negative impact of enabling `-frelaxed-template-template-args`
by default.

A template template parameter containing no packs should be more
specialized than one that does.

Given the following example:
```C++
template<class T2> struct A;
template<template<class ...T3s> class TT1, class T4> struct A<TT1<T4>>; #1
template<template<class    T5 > class TT2, class T6> struct A<TT2<T6>>; #2

template<class T1> struct B;
template struct A<B<char>>;
```

Prior to P0522, #2 would be the only viable candidate.
After P0522, #1 is also viable, and neither is considered more specialized,
so this becomes ambiguous.
With this change, #2 is considered more specialized, so that is what is picked
and we remain compatible with pre-P0522 implementations.

The problem we solve here is that the specialization rules in
`[temp.arg.template]/4` are defined in terms of a rewrite to
function templates, but in the case of partial ordering, the
rules on how P and A lists are matched to each other
is swapped regarding how specialization makes sense conceptually.

---

Since this changes provisional implementation of CWG2398 which has
not been released yet, and already contains a changelog entry,
we don't provide a changelog entry here.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list