10
I was pretty surprised when I found that the following code actually works:
std::vector<int> list /*= ...*/;
std::tr1::function<void(int)> func = ^(int i) {
return i + 1;
};
std::for_each(list.begin(), list.end(), func);
Seems like std::tr1::function is capable of being constructed from an Objective-C block, but I'm not sure quite how, since (last I checked), its implementation doesn't specifically handle blocks. Is it somehow implicitly sucking out the underlying function pointer? Also, is this behavior undefined and likely to change?