What can Rvalue change?
1 answer
It depends to some extent on the context of the phrase "modifiable rvalue". However, this is one possible example:
struct Modifiable
{
int x;
void modify() { std::cout << x << '\n'; x = -x; std::cout << x << '\n'; }
};
Modifiable demo()
{
Modifiable m;
m.x = 42;
return m;
}
int main()
{
demo().modify();
}
The return value demo()
is an rvalue (even a prvalue), but changed by the call modify()
.
+5
source to share