jjzjj

theContainer

全部标签

c++ - 对于 GCC 和 GCC 版本中的每个

我如何在GCC中使用foreach循环?我如何获得GCC版本?(在代码中) 最佳答案 使用lambda,例如//C++0xonly.std::for_each(theContainer.begin(),theContainer.end(),[](someTypex){//dostuffwithx.});range-basedforloop自4.6起受GCC支持。//C++0xonlyfor(autox:theContainer){//dostuffwithx.}"foreach"loopsyntax是MSVC扩展。它在其他编译器中不