Is it allowed to directly return while we are sending to ostream?
For example, instead of writing:
ostream& operator<<(ostream& os, Foo foo) {
os << foo.a << foo.b;
return os;
}
Instead, can I directly write:
ostream& operator<<(ostream& os, Foo foo) {
return os << foo.a << foo.b;
}
I tried it, and it seems to work but I don't know if it's the right thing to do. Is there any problem with doing the second version?