Is a data member of a temporary object an xvalue in C++11?
问题 #include <vector> using namespace std; struct A { vector<int> coll; }; void f(const vector<int>&){} void f(vector<int>&&){} int main() { f(A().coll); // Is "A().coll" an xvalue? } Does C++11 guarantee f(A().coll) will call void f(vector<int>&&) ? 回答1: Yes. C++14 standard, §5.2.5/4.2, given E1.E2 : If E2 is a non-static data member and the type of E1 is “ cq1 vq1 X ”, and the type of E2 is “ cq2 vq2 T ”, the expression designates the named member of the object designated by the first