我正在使用 boost 1.48.0,我没有升级选项。
我已经构建了一个 multi_index_container,其中的索引具有重叠标准。共享相同索引标准的索引是如何产生影响的,如下例所示?示例代码的最后一行暗示了我的要求。
struct street_address_key : composite_key<
t_postal_address
, const_mem_fun<const_mem_fun<t_postal_address, string, &t_postal_address::street_name>>
, const_mem_fun<const_mem_fun<t_postal_address, long, &t_postal_address::house_number>>
, const_mem_fun<const_mem_fun<t_postal_address, string, &t_postal_address::city>>
, const_mem_fun<const_mem_fun<t_postal_address, string, &t_postal_address::state>>
, const_mem_fun<const_mem_fun<t_postal_address, long, &t_postal_address::zip_code>>
> {};
multi_index<
t_postal_address
indexed_by<
ordered_unique<street_address_key>
, ordered_non_unique<const_mem_fun<t_postal_address, string, &t_postal_address::name>>
, ordered_non_unique<const_mem_fun<const_mem_fun<t_postal_address, string, &t_postal_address::street_name>>
, ordered_non_unique<const_mem_fun<const_mem_fun<t_postal_address, long, &t_postal_address::house_number>>
, ordered_non_unique<const_mem_fun<const_mem_fun<t_postal_address, string, &t_postal_address::city>>
, ordered_non_unique<const_mem_fun<const_mem_fun<t_postal_address, string, &t_postal_address::state>>
, ordered_non_unique<const_mem_fun<const_mem_fun<t_postal_address, long, &t_postal_address::zip_code>>
>
> t_address_book;
...
t_address_book::nth_element<0>::type::iterator address_iter = book.find(some_address_tuple);
book.modify(address_iter, modify_city_method);
auto city_range = book.get<4>().equal_range( \*???*\ );
城市索引与 street_address_key 共享相同的标准。据我了解,通过 street_address_key 进行修改将确保索引得到适当更新。但“城市”指数的状态如何?是否更新以反映城市名称的变化?还是处于破损状态?我还能找到与旧城区相同的地址索引吗?我必须单独更新这个索引吗?我可以调用无操作修饰符来更新索引吗?
// Presume I have the city element from the index.
// Is this supposed to update the city index after it was modified above?
book.get<4>().modify(city_iter, [](t_postal_address &) {});