I'm bound to C++03 and I have a non-copyable object (e.g. holding a resource).
I need to use move-and-swap semantics to be able to do something similar and avoid copies:
MyClass returnMyClass(void)
{
MyClass temp;
// fill 'temp' members with actual data
return temp;
}
int main(void)
{
MyClass test;
test = returnMyClass(); // need to avoid copies
}
Is it possible to respect all these requirements in C++03?
It is basically the same case of this, but for C++03.
To put the question in other words:
Given a non-copyable class MyClass
, is it somehow possible in C++03 to do MyClass test = returnMyClass();
?
I'm afraid the answer is simply no, but maybe I'm missing some trick.