I have looked at the disassembly for the following code and found that the result is often the same (or very similar) for both test functions. I am wondering what the difference is between the two functions and if not, is there any history or reason for this existing?
struct test
{
int x;
test& testfunction1() { x++; return *this; }
void testfunction2() { x++; }
};
edit: with my question being answered so quickly I am now wondering what reasons you would choose to use one over the other? it seems for the sake of 'freedom' one should always use a reference over the directly modifying the data.