GoingNative 2012のスライドを眺めていたらびっくりしたのでメモ。 STL11: Magic && Secrets | GoingNative 2012 | Channel 9のスライド24枚目。 map<string, int> m; for(const auto& p1 : m) for(const pair<string, int>& p2 : m) このfor文、どっちが速い?って問い。 答えは上の方。 下が遅いのは、mのvalue_typeはpair<const string, int>だから一時オブジェクトpairが発生してstringがコピーされるから、だそうで。 とりあえず型を指定したい時以外はautoを使えばいいみたい。