Permalink
Browse files

Revert behaviour of zero() to use memset blindly.

This will allow it to be used on non-POD data, but historically it was used
on technically C++98 non-POD data which is really POD and is now POD in C++11.
  • Loading branch information...
1 parent 39f5f01 commit 1b423904e30d8e0e86022be2d2863abd38911132 Edward Rosten committed Nov 5, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 cvd/image.h
View
@@ -394,9 +394,13 @@ template<class T> class SubImage
}
/// Set all the pixels in the image to zero. This is a relatively fast operation, using <code>memset</code>.
+ /// WARNING WARNING WARNING!
+ /// This function blindly uses memset. If you use it on sufficiently non-POD data, then it will put objects
+ /// into an invalid state.
inline void zero()
{
- fill(0);
+ for(int y=0; y < my_size.y; y++)
+ memset((*this)[y], 0, sizeof(T) * my_size.x);
}
/// Set all the pixels in the image to a value. This is a relatively fast operation, using <code>memfill</code>.

0 comments on commit 1b42390

Please sign in to comment.