C++0x から新たに C++ に追加された要素に、ラムダ式というものがあります。 これは、ちょっとした関数を、その場で定義して使えるようにしたもので、 #include <vector> #include <numeric> #include <iostream> int main() { std::vector<double> v = { -1, 2, 1.5, -4 }; double prod = std::accumulate( v.begin(), v.end(), 1, []( double x, double y ){ return x * y; } ); std::cout << prod << std::endl; // 12 } のように使います。具体的には Faith and Brave のラムダ式解説などを参照してください。 さて、そんな便利なラムダ式ですが、その