std::move
mutable
:The
[obj = ...]
capture syntax we used here is new to C++14. This is the main reason why Seastar requires C++14, and does not support older C++11 compilers.The extra
() mutable
syntax was needed here because by default when C++ captures a value (in this case, the value of std::move(obj)) into a lambda, it makes this value read-only, so our lambda cannot, in this example, move it again. Addingmutable
removes this artificial restriction.
异常和fail
抛出异常会导致整个 f()
执行失败,不建议抛出异常,应该返回fail future:
或者使用futurize_apply
:
最后更新于
这有帮助吗?