Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Implement CWG2398 provisional TTP matching to class templates #92855

Merged

Commits on May 21, 2024

  1. [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument

    This is an enabler for a future patch.
    mizvekov committed May 21, 2024
    Configuration menu
    Copy the full SHA
    229cb63 View commit details
    Browse the repository at this point in the history

Commits on May 22, 2024

  1. [clang] Implement CWG2398 provisional TTP matching to class templates

    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.
    
    When performing template argument deduction, we extend the provisional
    wording introduced in #89807
    so it also covers deduction of class templates.
    
    Given the following example:
    ```C++
    template <class T1, class T2 = float> struct A;
    template <class T3> struct B;
    
    template <template <class T4> class TT1, class T5> struct B<TT1<T5>>;   // #1
    template <class T6, class T7>                      struct B<A<T6, T7>>; // #2
    
    template struct B<A<int>>;
    ```
    Prior to P0522, `#2` was picked. Afterwards, this became ambiguous.
    This patch restores the pre-P0522 behavior, `#2` is picked again.
    
    This has the beneficial side effect of making the following code valid:
    ```C++
    template<class T, class U> struct A {};
    A<int, float> v;
    template<template<class> class TT> void f(TT<int>);
    
    // OK: TT picks 'float' as the default argument for the second parameter.
    void g() { f(v); }
    ```
    
    ---
    
    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.
    mizvekov committed May 22, 2024
    Configuration menu
    Copy the full SHA
    73d456c View commit details
    Browse the repository at this point in the history