
AMDG Dominique Devienne wrote:
Given for example
<snip>
I'd like to be able to have a "view" of VehicleIndex, for example compatible with unordered_set in this case since using a hashed index, for a given vehicle type ("Audi" for example), and going further have this view allow inserts which would go into the "master" vehicle index under the cover, validated by its unique indexes.
In pseudo-code, something a bit like this:
struct VehicleMake { VehicleByType::EqualRangeView& models_;
VehicleMake(const string& name) : models_(get<ByType>(get_vehicle_index()).equal_range_view(name)) {} };
With models_ behaving has a normal container one can iterate on (begin, end), query (empty, find, count), modify (insert, erase, clear, etc...), those operations only affecting the VehicleIndex elements matching the VehicleByType given range, and possibly asserting all inserts are valid for the range (the vehicles added via the "range view" have the type matching the range's type).
Can this be done? Has it been considered as a possible extension, and is it even feasible given the current B.MI design?
Any input on how to achieve or emulate the above would be appreciated. Thanks, --DD
Because of the way multi_index implements hashed_nonunique,
there is no sequence of equal elements. If you try to store a pair
of iterators, they may be invalidated or cease to delimit the
equal_range.
You could try looking up the iterators on demand,
if you don't mind the extra overhead.
template