From 9394486147b1ac7f53e7cc7995377555256b02cf Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 16 Jun 2015 17:56:00 +0300 Subject: [PATCH] fix issue 3891 --- modules/core/include/opencv2/core/mat.inl.hpp | 12 ++++++++++++ modules/core/test/test_mat.cpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index 3779b83f82..2b648718c2 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -1586,7 +1586,13 @@ template template inline Mat_<_Tp>::operator Vec::channel_type, n>() const { CV_Assert(n % DataType<_Tp>::channels == 0); + +#if defined _MSC_VER + const Mat* pMat = (const Mat*)this; // workaround for MSVS <= 2012 compiler bugs (but GCC 4.6 dislikes this workaround) + return pMat->operator Vec::channel_type, n>(); +#else return this->Mat::operator Vec::channel_type, n>(); +#endif } template template inline @@ -1594,8 +1600,14 @@ Mat_<_Tp>::operator Matx::channel_type, m, n>() const { CV_Assert(n % DataType<_Tp>::channels == 0); +#if defined _MSC_VER + const Mat* pMat = (const Mat*)this; // workaround for MSVS <= 2012 compiler bugs (but GCC 4.6 dislikes this workaround) + Matx::channel_type, m, n> res = pMat->operator Matx::channel_type, m, n>(); + return res; +#else Matx::channel_type, m, n> res = this->Mat::operator Matx::channel_type, m, n>(); return res; +#endif } template inline diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 897ac40a43..19992433b2 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -1214,7 +1214,7 @@ TEST(Core_Matx, fromMat_) { Mat_ a = (Mat_(2,2) << 10, 11, 12, 13); Matx22d b(a); - ASSERT_EQ( norm(a, b, NORM_INF), 0.); + ASSERT_EQ( cvtest::norm(a, b, NORM_INF), 0.); } TEST(Core_InputArray, empty)