![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/include/llvm-10/llvm/ADT/ |
Upload File : |
//===- llvm/ADT/EnumeratedArray.h - Enumerated Array-------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file defines an array type that can be indexed using scoped enum values. // //===----------------------------------------------------------------------===// #ifndef LLVM_ADT_ENUMERATEDARRAY_H #define LLVM_ADT_ENUMERATEDARRAY_H #include <cassert> namespace llvm { template <typename ValueType, typename Enumeration, Enumeration LargestEnum = Enumeration::Last, typename IndexType = int, IndexType Size = 1 + static_cast<IndexType>(LargestEnum)> class EnumeratedArray { public: EnumeratedArray() = default; EnumeratedArray(ValueType V) { for (IndexType IX = 0; IX < Size; ++IX) { Underlying[IX] = V; } } inline const ValueType &operator[](const Enumeration Index) const { auto IX = static_cast<const IndexType>(Index); assert(IX >= 0 && IX < Size && "Index is out of bounds."); return Underlying[IX]; } inline ValueType &operator[](const Enumeration Index) { return const_cast<ValueType &>( static_cast<const EnumeratedArray<ValueType, Enumeration, LargestEnum, IndexType, Size> &>(*this)[Index]); } private: ValueType Underlying[Size]; }; } // namespace llvm #endif // LLVM_ADT_ENUMERATEDARRAY_H