/* * Copyright (C) 2014 Cloudius Systems, Ltd. */ #ifndef ARRAY_MAP_HH_ #define ARRAY_MAP_HH_ #include // unordered_map implemented as a simple array template class array_map { std::array _a {}; public: array_map(std::initializer_list> i) { for (auto kv : i) { _a[kv.first] = kv.second; } } Value& operator[](size_t key) { return _a[key]; } const Value& operator[](size_t key) const { return _a[key]; } Value& at(size_t key) { if (key >= Max) { throw std::out_of_range(std::to_string(key) + " >= " + std::to_string(Max)); } return _a[key]; } }; #endif /* ARRAY_MAP_HH_ */