[Webkit-unassigned] [Bug 32828] WTF should have an arraysize macro

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Oct 24 08:16:54 PDT 2010


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





--- Comment #21 from David Kilzer (ddkilzer) <ddkilzer at webkit.org>  2010-10-24 08:16:53 PST ---
(In reply to comment #18)
> > Can you make the macro an inline template method instead, or does that make declarations like this unhappy?
> There are some problem, since we need the size at compile time:
> E.g. the following won't work:
> template <typename T, size_t N>
> inline size_t array_size(const T (&)[N])
> {
>     return N;
> }
> size_t s = array_size(tokens);
> 
> But this should work, if we like it more:
> template <typename T, size_t N>
> struct array_info<T[N]>
> {
>     enum { size = N };
> };
> size_t s = array_info<tokens>::size;

Does the struct consume any space when compiled?  Or is it acting like a class here and declaring a scoped enum within itself?  I tend to prefer type-safe code over macros as long as there aren't any bad side-effects to using it.  :)

-- 
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