书中"rvalue"和"rvalue reference"的混淆

Confusion between "rvalue" and "rvalue reference" in book

(我搜索了 [c++] "functional programming in c++" book,只给出了 4 个不相关的结果。)

我正在阅读 C++ 中的函数式编程 来自 Ivan Čukić,在第 118 页有一句话我不确定我是否理解。该节是关于成员函数的右值和左值重载,句子如下,其中第二次重载是使用&&引用类型限定符的:

The second overload will be called on objects from which you're allowed to stead the data -- temporary objects and other rvalue references.

我的疑惑是:

下面的代码是为了支持我的理解。

确实,我的理解是,如果我说 rvalue reference,我说的是函数参数(所以它有一个名称;例如:a in自由函数 f 的声明)声明为对实际参数的右值引用,或者我声明的变量(因此它有一个名称;示例:rr)作为对另一个变量的右值引用; (首先,两个 referenc-ed 实体都必须是右值,否则引用不会绑定)。在任何一种情况下,因为它有一个名字,调用成员函数 f 会导致调用左值重载,不是吗?

那本书是不是写错了,还是我遗漏了什么?

#include <iostream>

struct A {
  void f() &  { std::cout << "lvalue\n"; } // const & in the book, but it shouldn't make any difference
  void f() && { std::cout << "rvalue\n"; }
};

void f(A&& a) { a.f(); } // a is an lvalue (of type rvalue ref to)

int main() {
  A a;          // "normal" object
  A&& rr = A{}; // rvalue reference to a temporary (with life extended)

  a.f();
  A{}.f(); // only here I expect the rvalue overload to be called, and this is the case
  f(A{});
  rr.f();
}

the word in bold really puzzles me, in that the sentence seems meaningful to me only if I remove that word.

我同意。国际海事组织更准确地说,句子应该是

第二个重载将在允许您替换数据的对象上调用——右值(右值或 x 值)。

右值引用用于类型,右值用于value categories,它们是独立的东西。在这种情况下,将调用哪个重载取决于值类别,即要调用的对象是左值还是右值,与其类型无关。

the part in italic puzzles me in the first place, as in what else could it be if not a temporary?, but maybe this is just because I still haven't got a firm understanding of what xvalues are;

是的,xvalues 也是 rvalues。鉴于 int x = 0; std::move(x) 是一个 xvalue 但它不是临时值。