LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
array_macros.hh
Go to the documentation of this file.
1 #ifndef artg4tk_util_array_macros_hh
2 #define artg4tk_util_array_macros_hh
3 
18 namespace {
19  typedef unsigned char byte_t;
20 
21  template <int N>
22  struct array_size_struct {
23  byte_t c[N];
24  };
25 }
26 
30 template <typename T, int N>
31 array_size_struct<N> static_array_size_fn(T (&)[N]);
32 
37 #define dimensionof(x) sizeof(static_array_size_fn(x).c)
38 
39 #if !defined(ARRAYEND)
40 
42 #define ARRAYEND(x) (x + dimensionof(x))
43 #else
44 #error ARRAYEND defined already!
45 #endif
46 
47 #if !defined(ARRAYBEGIN)
48 
50 #define ARRAYBEGIN(x) x
51 #else
52 #error ARRAYBEGIN defined already!
53 #endif
54 
55 #endif /* artg4tk_util_array_macros_hh */
array_size_struct< N > static_array_size_fn(T(&)[N])