In modern C++, given a 2D matrix of floats, write a C++ function to transpose it.
This problem asks you to transpose a 2D matrix of floats in modern C++. The key idea is straightforward: allocate a result matrix with swapped dimensions and copy each element from position <code>(i, j)</code> to <code>(j, i)</code>. If an in-place solution is requested, you would also need to consider whether the matrix is square and how the data is stored. It is a basic matrix-manipulation question focused on indexing and array traversal.