|
Boost Users : |
From: bert hubert (bert.hubert_at_[hidden])
Date: 2006-04-03 08:19:26
Hi People,
Does anybody know if the code below, which relocates an interator to the
end() of an index, is legal? I tried delving into the multi_index code but
it is over my head.
I ask this because begin() is typically valid as an iterator, but end()
never is. The code does appear to work.
Also, would it be expensive? I think relocating in a sequenced index is
about as expensive as swapping pointers, but I'm not sure.
The code:
typedef multi_index_container<
CacheEntry,
indexed_by <
ordered_unique<
composite_key<
CacheEntry,
member<CacheEntry,string,&CacheEntry::d_qname>,
member<CacheEntry,uint16_t,&CacheEntry::d_qtype>
>
>,
ordered_non_unique<const_mem_fun<CacheEntry,uint32_t,&CacheEntry::getTTD> >,
sequenced<>
>
> cache_t;
cache_t d_cache;
// i is given and a valid iterator to the composite key
typedef cache_t::nth_index<2>::type sequence_t;
sequence_t& sidx=d_cache.get<2>();
sequence_t::iterator si=d_cache.project<2>(i);
sidx.relocate(sidx.end(), si); // does this work?
-- http://www.PowerDNS.com Open source, database driven DNS Software http://netherlabs.nl Open and Closed source services
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net