+2021-04-24  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * observable.h (class observable) <struct observer>: New.
+       <detach, notify>: Update.
+       <m_observers>: Change type to vector of observers.
+
 2021-04-23  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * observable.h (observer_debug): Change to bool.
 
 class observable
 {
 public:
-
   typedef std::function<void (T...)> func_type;
 
+private:
+  struct observer
+  {
+    observer (const struct token *token, func_type func)
+      : token (token), func (func)
+    {}
+
+    const struct token *token;
+    func_type func;
+  };
+
+public:
   explicit observable (const char *name)
     : m_name (name)
   {
   {
     auto iter = std::remove_if (m_observers.begin (),
                                m_observers.end (),
-                               [&] (const std::pair<const token *,
-                                    func_type> &e)
+                               [&] (const observer &o)
                                {
-                                 return e.first == &t;
+                                 return o.token == &t;
                                });
 
     m_observers.erase (iter, m_observers.end ());
       fprintf_unfiltered (gdb_stdlog, "observable %s notify() called\n",
                          m_name);
     for (auto &&e : m_observers)
-      e.second (args...);
+      e.func (args...);
   }
 
 private:
 
-  std::vector<std::pair<const token *, func_type>> m_observers;
+  std::vector<observer> m_observers;
   const char *m_name;
 };