Unexpected behavior after assignment of function object to function wrapper
Object slicing happens here. The point is given f = *p;, p is of type std::shared_ptr<Foo>, then the type of *p is Foo& (instead of Bar&). Even the assignment operator of std::function takes argument by reference, but 4) Sets the target of *this to the callable f, as if by executing function(std::forward<F>(f)).swap(*this);. Note that the … Read more