- 805 名前:デフォルトの名無しさん mailto:sage [2008/12/10(水) 06:50:05 ]
- g++ 4.4にautoの実装と新しい関数宣言の構文来てるね。
あまり使い方わかってないけど、適当に4.4の新機能を使ってみた。 #include <iostream> #include <vector> template <typename T> auto f(T x) -> decltype(x*x) { return x*x; } int main () { std::vector<int> x{1, 2, 3, 4, 5, 6, 7, 8, 9}; for (auto i = x.begin(); i != x.end(); ++i) std::cout << f(*i) << std::endl; return 0; } 出力 1 4 9 16 25 36 49 64 81
|

|