Let's consider this hunk of code that simply tries to initialize a map from a constexpr array:
#include <string>
#include <map>
#include <array>
#include <tuple>
constexpr std::array<std::pair<int, const char *>, 10> my_array {
{ { 0, "dd" },
{ 1, "dd" },
{ 2, "dd" },
{ 7, "dd" },
{ 8, "dd" },
{ 9, "dd" }}
};
std::map<int, std::string> my_map(std::begin(my_array), std::end(my_array));
int main() {
return my_map[0].size(); //dummy random operation
}
I know there is not way to predict initialization order for the two variables (my_array and my_map). That said, my_array is constexpr, thus should be available a compile time, thus there should be no "initialization order" problem at startup.
Is this code correct or does the initialization order problem remains?