#if !defined(INCLUDED_GENERIC_ARRAYRANGE_H) #define INCLUDED_GENERIC_ARRAYRANGE_H /// \file /// \brief Macros for automatically converting a compile-time-sized array to a range. template struct ArrayRange { typedef Element* Iterator; ArrayRange(Iterator _begin, Iterator _end) : begin(_begin), end(_end) { } Iterator begin; Iterator end; }; template inline ArrayRange makeArrayRange(Element* begin, Element* end) { return ArrayRange(begin, end); } template struct ArrayConstRange { typedef const Element* Iterator; ArrayConstRange(Iterator _begin, Iterator _end) : begin(_begin), end(_end) { } Iterator begin; Iterator end; }; template inline ArrayConstRange makeArrayRange(const Element* begin, const Element* end) { return ArrayConstRange(begin, end); } #define ARRAY_SIZE(array) (sizeof(array) / sizeof(*array)) #define ARRAY_END(array) (array + ARRAY_SIZE(array)) #define ARRAY_RANGE(array) (makeArrayRange(array, ARRAY_END(array))) typedef ArrayConstRange StringArrayRange; #define STRING_ARRAY_RANGE(array) (StringArrayRange(array, ARRAY_END(array))) #endif