I am wondering about this because of scope issues. For example, consider the code
typedef struct { int x1;/*top*/ int x2;/*bottom*/ int id; } sub
It will always return a copy.
If you want to avoid the performance hit of copying the object on return, you can declare a pointer, build an instance of the object using new, and return the pointer. In that case, the pointer will be copied, but the object won't be.