Brain Teaser: Streaming An Enumeration In C++
Streaming an enumeratoin in C++, what could be easier? Can you spot the bug in the following code? typedef enum { SEASON_UNDEF, SEASON_SUMMER, SEASON_AUTUMN, SEASON_WINTER, SEASON_SPRING, SEASON_NUM_TYPES, } SEASON; std::ostream& operator<<(std::ostream& rOs, const SEASON & rRhs) { switch (rRhs) { case SEASON_UNDEF: rOs << "SEASON_UNDEF"; break; case SEASON_SUMMER: rOs << "SEASON_SUMMER"; break; …
Continue reading ‘Brain Teaser: Streaming An Enumeration In C++’ »