Trying to implement a very simple observer pattern. The observers are not copyable.
Problem: The compiler reports error that the copy constructor of the observer class is deleted and needed here: function(std::forward<_Functor>(__f)).swap(*this);
class subject {
template <typename T>
void registerObserver(T&& observer) {
mNotifyTarget = std::forward<T>(observer);
}
std::function<void()> mNotifyTarget;
};
class observer {
void operator()() { ... }
}
Not having experience with std::function I tried to remove the std::forward<T>()
in the assignment, the problem remained.
Aucun commentaire:
Enregistrer un commentaire