a flexible C++ observer pattern with type safety in mind