Here's one way.
std::vector
to hold the data items (to ensure that the addresses don't change when the vector resizes) and then containers holding reference_wrappers (copyable references) to make the indexes.
compilable example:
#include
expected output:
{ bob : 8 }
{ bob : 6 }