class Myclass
{
public:
Myclass() = default;
~Myclass() = default;
Myclass(Myclass&&) = default;
Myclass& operator=(Myclass&&) = default;
Myclass(const Myclass&) = delete;
Myclass& operator=(const Myclass&) = delete;
int i = 0;
};
Myclass GetObj()
{
Myclass obj;
return obj;
}
Myclass WrapperOfGetObj()
{
Myclass&& Wrapobj = GetObj();
Wrapobj.i = 1; // Will it work?
return std::move(Wrapobj);
}
int main()
{
return 0;
}
I have few questions:
1) In WrapperOfGetObj function, Wrapobj is xvalue, so can I assign value to any member of it (xvalue - going to expire!!)
2) What is the storage of xvalue? Is this not automatic storage?
3) When xvalue becomes glvalue and when it becomes rvalue.(Any example in above context will make this clear to me).