Does std::bind work with move-only types in general, and std::unique_ptr in particular?

std::bind works fine with move-only types. However it creates a move-only functor in the process. std::function requires a copy constructible functor. It sounds like boost::asio does too.

When you call the move-only bind functor, it will pass its bound arguments as lvalues to the target operator(). So if one of your bound arguments is move-only, the target operator() must take that argument by (possibly const) lvalue reference.

Leave a Comment