#pragma once #ifndef ENUM_INDEXED_ARRAY_INL_H_ #error "Direct inclusion of this file is not allowed, include enum.h" // For the sake of sane code completion. #include "enum_indexed_array.h" #endif #include namespace NYT { //////////////////////////////////////////////////////////////////////////////// template TEnumIndexedArray::TEnumIndexedArray(std::initializer_list> elements) { for (const auto& [index, value] : elements) { (*this)[index] = value; } } template T& TEnumIndexedArray::operator[] (E index) { YT_ASSERT(IsValidIndex(index)); return Items_[ToUnderlying(index) - ToUnderlying(Min)]; } template const T& TEnumIndexedArray::operator[] (E index) const { return const_cast(*this)[index]; } template T* TEnumIndexedArray::begin() { return Items_.data(); } template const T* TEnumIndexedArray::begin() const { return Items_.data(); } template T* TEnumIndexedArray::end() { return begin() + Size; } template const T* TEnumIndexedArray::end() const { return begin() + Size; } template constexpr size_t TEnumIndexedArray::size() const { return Size; } template bool TEnumIndexedArray::IsValidIndex(E index) { return index >= Min && index <= Max; } //////////////////////////////////////////////////////////////////////////////// } // namespace NYT