c++11 - C++ access rvalue referenced object from non rvalue object -



c++11 - C++ access rvalue referenced object from non rvalue object -

this question has reply here:

most vexing parse: why doesn't a(()); work? 5 answers

this question may sound stupid. want create sure. , maybe point me described in standard.

we cannot have rvalue referenced objects within lvalue. right?

struct a{int value;}; struct b{ b(a &&value) : a(std::forward<a>(value)){} a&& a; }; int main() { // allowed b(a()).a; // error b b(a()); b.a; homecoming 0; }

http://coliru.stacked-crooked.com/a/ea6bd617d421a8b8

b b(a()); declares function (most vexing parse). compiler error because b has no fellow member a.

to prepare issue write b b{a()} instead.

c++ c++11 rvalue-reference

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -