To detect whether a mapping has changed:
int n = m_generation (the_mapping);
...
if (m_generation (the_mapping) != n) { n = m_generation (the_mapping); do_stuff (the_mapping); } else werror ("we're still fine\n");
This is in most cases possible to implement with a wrapper object instead.