You cannot do this. However, in some cases, you can use boost::bind or boost::lambda libraries to create functors without declaring an external structure. Also, if you have a recent compiler (e.g. gcc version 4.5), you can include new C ++ 0x functions that allow you to use lambda expressions, allowing this syntax:
transform(a, a+5, b, [](int x) -> int { return x*x; });
neodelphi
source share