nfprojects / nfengine

Game engine
GNU General Public License v2.0
55 stars 4 forks source link

Advanced enum iteration helper class #169

Open mkulagowski opened 8 years ago

mkulagowski commented 8 years ago

Recently an enumeration iterator has been submitted to the review. It's a helper class, that allows enum class to be used with range-based for. Unfortunately there are a lot of cases, that require non-incremental enum values - those cannot be iterated with this simple template.

Consider creating helper class that would allow iteration over any type of enum class. Whole idea has to be researched, because it's not certain, that it can be done in a sensible way.

First idea to investigate:

Helper IterableEnum class that would be used while declaring an enum class with initializer_list ctors, so it could be declared the same way we declare enums. It would most likely:

  • create a string array (or other container for enum 'keys' - it needs to be as lightweight as possible)
  • declare an enum with given values
  • choose First/Last values as in EnumIterator template
  • provide needed interface for iteration