[Webkit-unassigned] [Bug 36849] Add zero() method to Vector class

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Mar 31 15:02:09 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=36849





--- Comment #12 from Chris Rogers <crogers at google.com>  2010-03-31 15:02:08 PST ---
(In reply to comment #10)
> What about something like either of these.
> 
> 
> 
> namespace WTF {
> 
> template <bool canZero, typename T>
> struct ZeroFiller;
> 
> template<typename T>
> struct ZeroFiller<true, T> {
>     static void zero(T* begin, T* end)
>     {
>         memset(begin, 0, reinterpret_cast<char*>(end) -
> reinterpret_cast<char*>(begin));
>     }
> };
> 
> template<typename T>
> void zeroFill(T* begin, T* end)
> {
>     ZeroFiller::zero<IsPod<T>::value, T>(first, last)
> }
> 
> } // namespace WTF
> 
> 
> or
> 
> 
> namespace WTF {
> 
> template<typename T>
> void zeroFill(T* begin, T* end)
> {
>     COMPILE_ASSERT(IsPod<T>);
>     memset(begin, 0, reinterpret_cast<char*>(end) -
> reinterpret_cast<char*>(begin));
> }
> 
> } // namespace WTF

Sam, thanks that looks pretty good.  Which file do you think this code belongs
in?

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list