17#ifndef GZ_COMMON_ENUMITERATOR_HH_
18#define GZ_COMMON_ENUMITERATOR_HH_
25#include <gz/common/Export.hh>
39 public: EnumIface(T _start, T _end,
43 this->range[0] = _start;
44 this->range[1] = _end;
69 if (
static_cast<unsigned int>(_e) < names.size())
70 ret = names[
static_cast<unsigned int>(_e)];
129 template<
typename Enum>
133 public:
using value_type = Enum;
135 public:
using pointer = Enum*;
136 public:
using reference = Enum&;
139 public: EnumIterator() =
default;
144 public:
explicit EnumIterator(
const Enum &_c) : c(_c)
150 public: EnumIterator &operator=(
const Enum &_c)
158 public: EnumIterator &operator++()
160 this->c =
static_cast<Enum
>(
static_cast<int>(this->c) + 1);
166 public: EnumIterator operator++(
const int)
168 EnumIterator cpy(*
this);
175 public: EnumIterator &operator--()
177 this->c =
static_cast<Enum
>(
static_cast<int>(this->c) - 1);
183 public: EnumIterator operator--(
const int)
185 EnumIterator cpy(*
this);
192 public: Enum operator*()
const
199 public: Enum Value()
const
214 template<
typename Enum>
215 bool operator==(EnumIterator<Enum> _e1, EnumIterator<Enum> _e2)
217 return _e1.Value() == _e2.Value();
224 template<
typename Enum>
225 bool operator!=(EnumIterator<Enum> _e1, EnumIterator<Enum> _e2)
227 return !(_e1 == _e2);
239 static constexpr gz::common::EnumIface<T> gzEnum(
242 return gz::common::EnumIface<T>(_enumBegin, _enumEnd, _enumVals);
257#define GZ_ENUM(name, enumType, begin, end, ...) \
258static auto name = gz::common::gzEnum(begin, end, {__VA_ARGS__});