Skip to content

Commit 91ef0b9

Browse files
committed
Merge pull request opencv#9507 from delftrobotics-forks:restrict-initializer-list-constructor
2 parents 964dda2 + 3571e8f commit 91ef0b9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

modules/core/include/opencv2/core/mat.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353

5454
#include "opencv2/core/bufferpool.hpp"
5555

56+
#ifdef CV_CXX11
57+
#include <type_traits>
58+
#endif
59+
5660
namespace cv
5761
{
5862

@@ -988,7 +992,8 @@ class CV_EXPORTS Mat
988992
#ifdef CV_CXX11
989993
/** @overload
990994
*/
991-
template<typename _Tp> explicit Mat(const std::initializer_list<_Tp> list);
995+
template<typename _Tp, typename = typename std::enable_if<std::is_arithmetic<_Tp>::value>::type>
996+
explicit Mat(const std::initializer_list<_Tp> list);
992997
#endif
993998

994999
#ifdef CV_CXX_STD_ARRAY

modules/core/include/opencv2/core/mat.inl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
575575
}
576576

577577
#ifdef CV_CXX11
578-
template<typename _Tp> inline
578+
template<typename _Tp, typename> inline
579579
Mat::Mat(const std::initializer_list<_Tp> list)
580580
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows((int)list.size()),
581581
cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)

0 commit comments

Comments
 (0)