R
red floyd
Once again, I'm fighting a port from the (allegedly standard compliant)
VC7.1 to G++.
VC compiles this, G++ doesn't.
Am I allowed to pass the anonymous temporary returned by f() to a
function requiring a non-const reference? I suspect G++ is correct, and
VC is (again) braindead.
class A
{
public:
A() { }
A(const A&) { }
~A() { }
};
A& operator<<(A& a, const char* p)
{
return a;
}
A f()
{
return A();
}
int main()
{
f() << "Hello";
return 0;
}
VC7.1 to G++.
VC compiles this, G++ doesn't.
Am I allowed to pass the anonymous temporary returned by f() to a
function requiring a non-const reference? I suspect G++ is correct, and
VC is (again) braindead.
class A
{
public:
A() { }
A(const A&) { }
~A() { }
};
A& operator<<(A& a, const char* p)
{
return a;
}
A f()
{
return A();
}
int main()
{
f() << "Hello";
return 0;
}