On Fri, 2016-04-15 at 18:06 -0700, Barry Gold wrote: > I've written a program that uses the STL, and recently came across > the > concept of automatic type determination. Which I think is *brilliant* > btw. > > My code includes the following: > > In game.h: > map<string, string> idlist; > > In Game.cpp: > void Game::addID(string id) > { > auto eltp = idlist.find(id); > if (eltp == map::end) { > idlist.insert(pair<string,string>(id, id)); > } else { > // Found in map, so it's a duplicate > string emsg = "Duplicate ID: %s"; > emsg += id; > yyerror(emsg); > } > } > > ===== > > My make log includes the following error message: > > g++ -c -o Game.o Game.cpp > Game.cpp: In member function ‘void Game::addID(std::string)’: > Game.cpp:12:10: error: ‘eltp’ does not name a type > auto eltp = idlist.find(id); > ^ > Game.cpp:13:9: error: ‘eltp’ was not declared in this scope > if (eltp == map::end) { > ^ > > This seems to imply that g++ is using the old meaning of "auto": > allocate the variable on the stack. Yet my gcc/g++ identifies as > version > 5.3.0, which the docs claim supports C++ version 11. > > Do I have to add a command-line flag to enable C++ version 11 and/or > the > new meaning of "auto"? > Yes, you have to add -std=c++11 to the list of g++ options to enable C++11 support. Cheers, Oleg