Is taking a reference from a temporary valid C++ code?
I used the following syntactic sugar:
for (auto& numberString: {"one", "two", "three", "four"}) { /* ... */}
Is this valid code? AFAIK, based on this question, this should be illegal, yet the code runs as expected. I don't think my understanding is correct on the matter.
As far as I know, only literals should not have memory addresses, yet the linked question is talking about temporaries and r-values.
Comments
Post a Comment