[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

Yuanfang Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 27 12:44:23 PDT 2022


ychen added a comment.

In D133683#3818887 <https://reviews.llvm.org/D133683#3818887>, @mizvekov wrote:

> In D133683#3818858 <https://reviews.llvm.org/D133683#3818858>, @ychen wrote:
>
>> It is clear cut by https://eel.is/c++draft/temp.deduct.partial#3.1. It is orthogonal to the DRs implemented in D128745 <https://reviews.llvm.org/D128745> and here.
>> https://godbolt.org/z/s49sqrabY  : if you call `g(42,42)`, it would reveal that the function without pack indeed wins. It is ambiguous because the caller `g(42)` does not use the pack. So the wording prevents us from letting the non-pack version win. I do somewhat agree that it is more consistent and predictable to always consider all function parameters for partial ordering. Yeah, that needs a whole separate discussion on https://eel.is/c++draft/temp.deduct.partial#3.1.
>
> I think it's using the pack, the pack is just being deduced as an empty pack. This is different from a template parameter which is not being deduced because it does not appear in the arguments.
>
> To reiterate, what you said would make sense if the second overload was written as:
>
> `template <typename T, typename... U> void g(T);`
>
> Instead of `template <typename T, typename... U> void g(T, U...);` as it is.

This is described in https://eel.is/c++draft/temp.deduct.partial#13. Parietal ordering currently doesn't consider the number of deduced arguments. During the partial ordering stage, by https://eel.is/c++draft/temp.func.order#3, `template <typename T, typename... U> void g(T, U...);` would become `void g(UniqueT1, UniqueT2);`. And then it applies https://eel.is/c++draft/temp.deduct.partial#3.1 to decide which parameters are compared for partial ordering.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133683/new/

https://reviews.llvm.org/D133683



More information about the cfe-commits mailing list