mirror of
https://github.com/opencv/opencv.git
synced 2025-06-29 16:11:00 +08:00
Enabled forEach for const Mats
This commit is contained in:
parent
2ac57a2b1f
commit
c92c99ed0b
@ -1214,7 +1214,7 @@ void Mat::forEach(const Functor& operation) {
|
|||||||
template<typename _Tp, typename Functor> inline
|
template<typename _Tp, typename Functor> inline
|
||||||
void Mat::forEach(const Functor& operation) const {
|
void Mat::forEach(const Functor& operation) const {
|
||||||
// call as not const
|
// call as not const
|
||||||
(const_cast<Mat*>(this))->forEach<const _Tp>(operation);
|
(const_cast<Mat*>(this))->forEach<_Tp>(operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp> inline
|
template<typename _Tp> inline
|
||||||
|
@ -671,6 +671,13 @@ struct InitializerFunctor5D{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename Pixel>
|
||||||
|
struct EmptyFunctor
|
||||||
|
{
|
||||||
|
void operator()(const Pixel &, const int *) const {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void Core_ArrayOpTest::run( int /* start_from */)
|
void Core_ArrayOpTest::run( int /* start_from */)
|
||||||
{
|
{
|
||||||
int errcount = 0;
|
int errcount = 0;
|
||||||
@ -799,6 +806,17 @@ void Core_ArrayOpTest::run( int /* start_from */)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test const cv::Mat::forEach
|
||||||
|
{
|
||||||
|
const Mat a(10, 10, CV_32SC3);
|
||||||
|
Mat b(10, 10, CV_32SC3);
|
||||||
|
const Mat & c = b;
|
||||||
|
a.forEach<Point3i>(EmptyFunctor<Point3i>());
|
||||||
|
b.forEach<Point3i>(EmptyFunctor<const Point3i>());
|
||||||
|
c.forEach<Point3i>(EmptyFunctor<Point3i>());
|
||||||
|
// tests compilation, no runtime check is needed
|
||||||
|
}
|
||||||
|
|
||||||
RNG rng;
|
RNG rng;
|
||||||
const int MAX_DIM = 5, MAX_DIM_SZ = 10;
|
const int MAX_DIM = 5, MAX_DIM_SZ = 10;
|
||||||
// sparse matrix operations
|
// sparse matrix operations
|
||||||
|
Loading…
Reference in New Issue
Block a user