mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 22:44:01 +00:00
Remove enum_iter_t
This was unused.
This commit is contained in:
parent
8203fdf631
commit
7fa13e4451
2 changed files with 0 additions and 48 deletions
|
@ -97,45 +97,4 @@ class enum_array_t : public std::array<Elem, enum_count<T>()> {
|
||||||
const Elem &operator[](T t) const { return super::operator[](index_of(t)); }
|
const Elem &operator[](T t) const { return super::operator[](index_of(t)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A counting iterator for an enum class.
|
|
||||||
/// This enumerates the values of an enum class from 0 up to (not including) count.
|
|
||||||
/// Example:
|
|
||||||
/// for (auto v : enum_iter_t<MyEnum>) {...}
|
|
||||||
template <typename T>
|
|
||||||
class enum_iter_t {
|
|
||||||
using base_type_t = typename std::underlying_type<T>::type;
|
|
||||||
struct iterator_t {
|
|
||||||
friend class enum_iter_t;
|
|
||||||
using iterator_category = std::forward_iterator_tag;
|
|
||||||
using value_type = T;
|
|
||||||
using difference_type = long;
|
|
||||||
|
|
||||||
explicit iterator_t(base_type_t v) : v_(v) {}
|
|
||||||
|
|
||||||
T operator*() const { return static_cast<T>(v_); }
|
|
||||||
const T *operator->() const { return static_cast<const T *>(v_); }
|
|
||||||
|
|
||||||
iterator_t &operator++() {
|
|
||||||
v_ += 1;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const iterator_t operator++(int) {
|
|
||||||
auto res = *this;
|
|
||||||
v_ += 1;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(iterator_t rhs) const { return v_ == rhs.v_; }
|
|
||||||
bool operator!=(iterator_t rhs) const { return v_ != rhs.v_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
base_type_t v_{};
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
iterator_t begin() const { return iterator_t{0}; }
|
|
||||||
iterator_t end() const { return iterator_t{static_cast<base_type_t>(enum_count<T>())}; }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -347,13 +347,6 @@ static void test_enum_set() {
|
||||||
do_test((enum_set_t<test_enum>{test_enum::beta} | test_enum::alpha).to_raw() == 3);
|
do_test((enum_set_t<test_enum>{test_enum::beta} | test_enum::alpha).to_raw() == 3);
|
||||||
do_test((enum_set_t<test_enum>{test_enum::beta} | enum_set_t<test_enum>{test_enum::alpha})
|
do_test((enum_set_t<test_enum>{test_enum::beta} | enum_set_t<test_enum>{test_enum::alpha})
|
||||||
.to_raw() == 3);
|
.to_raw() == 3);
|
||||||
|
|
||||||
unsigned idx = 0;
|
|
||||||
for (auto v : enum_iter_t<test_enum>{}) {
|
|
||||||
do_test(static_cast<unsigned>(v) == idx);
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
do_test(static_cast<unsigned>(test_enum::COUNT) == idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_enum_array() {
|
static void test_enum_array() {
|
||||||
|
|
Loading…
Reference in a new issue