C++0xのautoの紹介 autoキーワードを使って変数を定義すると,コンパイラが初期化値を基に変数の型を推論してくれる. int f(); auto x1 = 1; // x1 : int auto x2 = f(); // x2 : int auto x3 = 3.14; // x3 : double auto &x4 = x1; // x4 : int& const auto *x5 = &x1; // x5 : const int* イテレータのように長い名前の型もautoを使えば簡単に書ける. // before for (std::vector<int>iterator it = v.begin(), end = v.end(); it != end; ++it) { ... } // after for (auto it = v.begin(), end = v.end()