While this works for enums, the real problem is that a static array is created and initialized. But what if the elements[] contain values that are different the next time through? What if someone takes the address of this static array? I have strong reservations about fixing this this way.