I have some code Similar to this
enum Days
{
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
};
typedef void (*DailyFunction)(int);
namespace DailyFunctions
{
void monday(int SomeData);
void tuesday(int SomeData);
void wednesday(int SomeData);
void thursday(int SomeData);
void friday(int SomeData);
void saturday(int SomeData);
void sunday(int SomeData);
}
and somewere else in my code I use a switch statement to assign one of the DailyFunctions to a DailyFunction ptr. When i was typing the (more or less) same switch statement for the third time, I had the Idea, that it would be great to have a map
std::map<Days, DailyFunction> MyPhonebookMap
which would allow me to do something like this:
DailyFunction Function_ptr = MyPhonebookMap[WeekDay];
To me it seems, like the optimal place to define such a map would be in the namespace DailyFunctions under the function-declarations
But how can i define a const map there (since it shouldnt change) and populate it at the same time?