I'm trying to figure out why dereferencing the empty list iterator is preventing the rest of the code from running. Comment out the line and everything seems fine, but leave it in and the program doesn't seem to get past that point.
I guess it's supposed to be an error since the list is empty, but I'm not getting any warnings or errors.
I'm using codeblocks with MinGW
std::list<std::string> slist;
std::string word;
auto iter = slist.begin();
//what is this doing?
std::cout << (*iter) << std::endl;
while(std::cin >> word)
{
iter = slist.insert(iter, word);
}
slist.insert(slist.begin(), {"foo", "bar"});
for(auto item: slist)
std::cout << item << std::endl;