This should fix some ambiguities in the enum_map

This commit is contained in:
2020-01-12 12:21:18 -05:00
parent e39ccf745b
commit e42baa0971

View File

@@ -14,17 +14,21 @@
// This is designed for contiguous enums, it'll waste space otherwise.
template<typename E, typename T, int n>
struct enum_map_impl : public std::array<T, n> {
// Since the superclass is a dependent type we need to explicitly import these to use them in the class definition
using typename array::reference;
using typename array::const_reference;
using typename array::size_type;
enum_map_impl() = default;
enum_map_impl(std::initializer_list<T> l) {
std::copy(l.begin(), l.end(), begin());
std::copy(l.begin(), l.end(), this->begin());
}
reference at(size_type pos) = delete;
const_reference at(size_type pos) const = delete;
reference operator[](size_type pos) = delete;
const_reference operator[](size_type pos) const = delete;
reference at(E pos) {return array::at(static_cast<int>(pos));};
const_reference at(E pos) const {return array::operator[](static_cast<int>(pos));};
reference operator[](E pos) {return array::operator[](static_cast<int>(pos));};
reference at(E pos) {return this->array::at(static_cast<int>(pos));};
const_reference at(E pos) const {return this->array::operator[](static_cast<int>(pos));};
reference operator[](E pos) {return this->array::operator[](static_cast<int>(pos));};
const_reference operator[](E pos) const = delete;
static const std::array<E, n> keys() {
static std::array<E, n> keys;