[ADT] Extend EnumeratedArray
EnumeratedArray is essentially a wrapper around a fixed-size array that uses enum values instead of integers as indices. * Add iterator support (begin/end/rbegin/rend), which enables the use of iterator/range based algorithms on EnumeratedArrays. * Add common container typedefs (value_type etc.), allowing drop-in replacements of other containers in cases relying on these. * Add a constructor that takes an std::initializer_list<T>. * Make the size() function const. * Add empty(). Iterator support slightly lowers the protection non-type-safe accesses, because iterator arithmetic is not enum-based, and one can now use *(begin() + IntIndex). However, it is and was also always possible to just cast arbitrary indices to the enum type. Differential Revision: https://reviews.llvm.org/D135594
Loading
Please sign in to comment