带有用户类型的C++ 20模板<auto>导致GCC 9中的T/const T类型不匹配

man*_*anu 8 c++ gcc templates c++20

我正在尝试使用自定义类型的非类型模板.

struct T {};

template <auto value> struct U {};

template <auto value> 
void f (U <value>) {}

int main()
{
    constexpr T t;
    f    (U<1>{});  // OK
    f<t> (U<t>{});  // OK
    f    (U<t>{});  // Error
}
Run Code Online (Sandbox Code Playgroud)

模板参数推断失败,gcc trunk使用-std = c ++ 2a获取

yop.cpp:10:5: note:   template argument deduction/substitution failed:
yop.cpp:19:21: note:   mismatched types ‘T’ and ‘const T’
   19 |         f    (U<t>{});  // Error
      |                     ^
Run Code Online (Sandbox Code Playgroud)

我错过了什么或这是一个错误吗?

man*_*anu 1

好的,正在浏览最新的草稿...

[temp.arg.nontype] 说

如果模板参数 (12.1) 的类型 T 包含占位符类型 (9.1.7.5) 或推导类类型 (9.1.7.6) 的占位符,则参数的类型是为变量 x 推导的类型发明声明

T x = template-argument ;
Run Code Online (Sandbox Code Playgroud)

作为插入

auto x = t;
static_assert (std::is_same_v <decltype (x), T>);
Run Code Online (Sandbox Code Playgroud)

在上面编译的代码片段中,我正在提交一个错误。