Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename T>
- class Observable
- {
- T underlying;
- public:
- Observable<T>& operator=(const T &rhs) {
- underlying = rhs;
- fireObservers();
- return *this;
- }
- operator T() { return underlying; }
- void addObserver(ObsType obs) { ... }
- void fireObservers() { /* Pass every event handler a const & to this instance /* }
- };
- Observable<int> x;
- x.registerObserver(...);
- x = 5;
- int y = x;
Add Comment
Please, Sign In to add comment