c++ - Are objects inside rvalue referenced object, also rvalue referenced? -
c++ - Are objects inside rvalue referenced object, also rvalue referenced? -
are objects within rvalue referenced object, rvalue referenced?
struct a{ }; struct b{ a2; }; //template<class b> void test(b &&b){ // 1. right way? auto &&in3 = std::forward<b>(b).a2; std::cout << std::is_rvalue_reference<decltype(in3)>::value; // homecoming true // 2. or this? auto &&in4 = b.a2; std::cout << std::is_rvalue_reference<decltype(in4)>::value; // homecoming false } test(b());
http://coliru.stacked-crooked.com/a/bcf0f7dc4cc0440e
yes, members of rvalues rvalues. clarified dr 421
but irrelevant here:
auto &&in4 = b.a2;
b
not rvalue, it's lvalue (simple rule of thumb: has name).
to restore value category had when passed function need forward
it
c++ c++11 rvalue-reference
Comments
Post a Comment