Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Well, yes you can do that and normaly it should not leak any memory, but it is not a very good practice. Mat is a smart pointer and as such should release its memory. But smart pointers may leak memory when initialized in function call. It is hard to create situation in which the memory is leaked, but it is possible. So it is better to spend extra line to read image and only after that to call transpose.

If you want to know more about how and why this may happen read 'Item 17' of 'Effective C++' 3rd edition: "Store newed objects in smart pointers in standalone statements".