re: 使用lambda,远离bind FireEmissary 2013-03-16 13:35
@wingfire
lambda不支持模板是遗憾而不是败笔,因为它并非将来不可改进.
至于和模板的合作,从最新的书籍来看也是建议用lambda.诚如<<The C++ Standard Library>>Second Edition所说(10.2.4):
std::find_if (coll.begin(), coll.end(),
std::bind(std::logical_not<bool>(),
std::bind(std::modulus<int>(),
std::placeholder::_1,
2)));
Being able to use a lambda is really an improvement here:
std::find_if (coll.begin(), coll.end(),
[](int elem){
return elem%2==0;
});
我试着运行了asio自带的http例子,有调用async_read_until直到独到"\r\n\r\n"的,结果你懂的