I have edited the code. But strangely at work, I have VS2008 and it works in the meaning that debugger shows std::bad_alloc exception, but no PC suspend, so I assume that is just some issue...
I found out that when I use this syntax, Copy function doesn't work fine. The M matrix in Copy is undefined, and has random values. But Copy itself works well when
is used, but fails for
The reason is that at the moment of m(ii) returning reference to temp object, this object disappears. But why? Shouldn't it be automatically copied?