The only temporary ones in your code are s1 + s2 . The first is tied to const-ref s , and thus its lifetime increases to s . Nothing in your code is temporary. In particular, neither s nor ss are temporary, as they are explicitly called variables.
The second s1 + s2 , of course, is also temporary, but it dies at the end of the line, which was used only to initialize ss .
Update: perhaps one point deserves attention: in the final line g(s, ss); the point is that s is a legitimate link, and itβs not a chatty link, as you might expect, precisely because of the extended life rule for temporary links associated with const links.
source share