c++ - A "strong" iterator pointer/reference -
is there such thing "strong" iterator. mean iterator sticks value referencing rather address in, such if value gets swapped different address, iterator continue pointing in new address; regardless of gets moved in data structure?
yes , no. why? , want std::iter_swap(strong_a, strong_b);
do?
as karoly horvath points out, implement own container has own iterators (iterator concept, not 1 type).
as way "implement 1 work standard library nicely", depends part of standard library have in mind. can't go adding things containers (unless can figure out way implement want allocators or something). if created own somehow, you'd have level of compatibility standard algorithms.
finally, implement special wrapper class, let std::vector<strong_pointable<int>>
strong_pointable<int>
act int let provide way special "strong pointer" or whatever want call keep track of things move-constructed.
but odd thing ask for. suspect doing wrong if want functionality.
Comments
Post a Comment