Code section:
struct id_s {
std::string name1;
std::string name2;
};
static const std::map<uint8_t, id_s> list = {
{ 0x00, { "Fred", "Apple" } },
{ 0x01, { "John", "Banana" } },
{ 0x02, { "Mark", "Mango" } }
};
int main()
{
for(const auto& it: list) {
std::cout<<it.first<<"\t"<<it.second.name1<<"\t"<<it.second.name2<<std::endl;
}
return 0;
}
Problem is that once initialized all fields are correctly assigned, except "John" and "Mark", which are left as "".
How to correctly assign this with C++11 initialization lists?
Output from VS 2013 debug console: