引用作为参数的模板参数推导

Template argument deduction for references as arguments

我正在努力深入理解模板参数推导。 我不明白的一点是,我应该如何应用标准中的规则 here 类型 AP 对于以下情况(遗憾的是 cppreference.com 上没有示例,请参阅下面的相关部分)

template<typename T>
void foo(T t);

void call_with_reference(int& r) {
    foo(r)
}

-> 匹配 PA 给出: T 推导为 int&

这显然是错误的。标准中说 来自 A 的引用被删除 的规则在哪里?非常感谢一个不混淆、明确的答案。

相关栏目:

A 是表达式的类型。表达式类型描述为 [expr.type]/1:

If an expression initially has the type “reference to T” ([dcl.ref], [dcl.init.ref]), the type is adjusted to T.

所以这里 Aint

这个表达式是一个 lvalue 但不会发挥任何作用,因为 P 不是引用。