
26 Jun
2006
26 Jun
'06
3:26 p.m.
Gennaro Prota <gennaro_prota@yahoo.com> writes:
On Sun, 25 Jun 2006 17:43:26 -0400, David Abrahams <dave@boost-consulting.com> wrote:
That somersault is easy enough (although I've forgotten what it was exactly, there's an easy workaround).
Indeed I found it at the first try :)
template <std::size_t n> struct counter { enum { n = n }; // yep :)
template <typename t> static char(&count(t(*)[n]))[n];
};
#define COUNT_OF(x) \ (sizeof counter<(sizeof x / sizeof x[0])>::count(&x))
PS: note the enum!
Wow, great! That trick is a new one to me. ...but is learning a new vc6 hack a virtue? -- Dave Abrahams Boost Consulting www.boost-consulting.com