/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include #include namespace facebook::react::jsinspector_modern { /** * A statically-sized array with an enum class as the index type. * Values are value-initialized (i.e. zero-initialized for integral types). * Requires that the enum class has a kMaxValue member. */ template requires std::is_enum_v && std::is_same_v, int> && requires { IndexType::kMaxValue; } && (static_cast(IndexType::kMaxValue) < std::numeric_limits::max()) class EnumArray { public: constexpr ValueType &operator[](IndexType i) { return array_[static_cast(i)]; } constexpr const ValueType &operator[](IndexType i) const { return array_[static_cast(i)]; } constexpr int size() const { return size_; } private: constexpr static int size_ = static_cast(IndexType::kMaxValue) + 1; std::array array_{}; }; } // namespace facebook::react::jsinspector_modern