File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -1214,7 +1214,7 @@ void Mat::forEach(const Functor& operation) {
1214
1214
template <typename _Tp, typename Functor> inline
1215
1215
void Mat::forEach (const Functor& operation) const {
1216
1216
// call as not const
1217
- (const_cast <Mat*>(this ))->forEach <const _Tp>(operation);
1217
+ (const_cast <Mat*>(this ))->forEach <_Tp>(operation);
1218
1218
}
1219
1219
1220
1220
template <typename _Tp> inline
Original file line number Diff line number Diff line change @@ -671,6 +671,13 @@ struct InitializerFunctor5D{
671
671
}
672
672
};
673
673
674
+ template <typename Pixel>
675
+ struct EmptyFunctor
676
+ {
677
+ void operator ()(const Pixel &, const int *) const {}
678
+ };
679
+
680
+
674
681
void Core_ArrayOpTest::run ( int /* start_from */ )
675
682
{
676
683
int errcount = 0 ;
@@ -799,6 +806,17 @@ void Core_ArrayOpTest::run( int /* start_from */)
799
806
}
800
807
}
801
808
809
+ // test const cv::Mat::forEach
810
+ {
811
+ const Mat a (10 , 10 , CV_32SC3);
812
+ Mat b (10 , 10 , CV_32SC3);
813
+ const Mat & c = b;
814
+ a.forEach <Point3i>(EmptyFunctor<Point3i>());
815
+ b.forEach <Point3i>(EmptyFunctor<const Point3i>());
816
+ c.forEach <Point3i>(EmptyFunctor<Point3i>());
817
+ // tests compilation, no runtime check is needed
818
+ }
819
+
802
820
RNG rng;
803
821
const int MAX_DIM = 5 , MAX_DIM_SZ = 10 ;
804
822
// sparse matrix operations
You can’t perform that action at this time.
0 commit comments