void foo(const C &);
foo(C());
In this case, temporary C
object lives until the end of foo()
.
But my question is:
struct C { operator int(); }
void bar(int i);
bar(C());
In that case, Does temporary C
object live until the end of bar()
? If not, Is there any way to make temporary object live until the end of bar()
?
edit: Thanks to user2109558, I know the code doesn't work. Then does the following code work well?
void bar(int i);
void bar(C &&c) { bar(c); }