I have this situation:
struct A {};
void foo(A& a) {};
void boo(const A& a) {};
void foo(int& a) {};
void boo(const int& a) {};
int main() {
foo(A()); //ok... but why?
boo(A()); //ok
foo(5); //error
boo(5); //ok
return 0;
}
Why foo(A())
works while foo(5)
does not? Wouldn't it be the same situation? Is A()
on foo(A())
an rvalue
? Can I consider A()
in this situation a temporary object?