I have something similar to this:
//file1.h
class Base {
private:
static std::unordered_map<int, std::unordered_map<int, std::string>> table;
}
And to make everything work as expect I write this:
//file1.cpp
std::unordered_map<int, std::unordered_map<int, std::string>> Base::table = {
{
1, std::unordered_map<int, std::string> {
{12, "asset:12/"},
{-3, "asset:24/"},
//...
}
},
//...
};
I use visual studio 2017 latest update (15.8.5) and this code fails:
//file1.h
class Base {
private:
inline static std::unordered_map<int, std::unordered_map<int, std::string>> table = {
{
1, std::unordered_map<int, std::string> {
{12, "asset:12/"},
{-3, "asset:24/"},
//...
}
},
//...
};
Why does this inline declaration fail? I have seen that since C++17
you can have inline static declarations. The problem is in the list header and it states:
**_Pnode** was 0xDDDDDDDD.
Is it a problem with maps? I have run the code in coliru and I didn't have the issue that I've found in VS. Screen:
The output dialog is:
The thread 0x3790 has exited with code 0 (0x0). Exception thrown: read access violation. _Pnode was 0xDDDDDDDD.
Exit code is 0 but I don't understand where the access violation could happen.