The following compiles and runs. typedef string Colour; struct edge_properties { vector < set< Colour > > eColours; } //get a reference to the vector of the sets of colours of some edge. vector < set<Colour> > & v_colour_outset = get(m_eColours_map,*out_iter); // Here *out_iter is some edge. //Add a set<Colour> to v_colour_outset ie. to get(m_eColours_map,*out_iter) . set<Colour> colour_set; v_colour_outset.push_back(colour_set); // get a reference to one of the set<colour> in get(m_eColours_map,*out_iter) . set<Colour> & outcset = v_colour_outset[1]; //or [0], or any elt. But when I try to add a new colour to this set outcset.insert("Blue"); I get segfault. My guess is that there is a predetermined size for colour_set, and when it is push_backed into v_colour_outset, a new colour cannot be added into it. I tried to create a vector of set<Colour> references as follows. struct edge_properties { vector < set< Colour > & > eColours; } But it did not compile. ( shouldn't it? ) Whats the best solution to this problem. Thanks - JR |