A proof of concept of a semistable vector container

#include <semistable/vector.hpp>
#include <iostream>

int main()
{
semistable::vector<int> x = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

auto it = x.begin() + 5;
std::cout << *it << "\n"; // prints 5

x.erase(x.begin());       // erases first element

std::cout << *it << "\n"; // prints 5 again!
}

std::vector stores its contents in a contiguous block of memory, so mid insertions and erasures invalidate references and iterators to previous elements. semistable::vector is called semistable in the sense that, while references are still unstable, its iterators correctly track elements in situations like the above.

semistable::vector stores elements contiguously and provides the same API as std::vector with the extra guarante…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help