Fix compilation under MSVC

Use template for std::min and std::max