Commit 278a1f7d authored by Nicholas Ormrod's avatar Nicholas Ormrod Committed by Dave Watson

small_vector exception safety, part 2

Summary:
small_vector is now object-exception safe for all container
functions, except for input-iterators.

That's a bold claim; probably incorrect. At the very least, it passes
the same test suite as std::vector and fbvector.

Aside: Clearly, no one uses erase(q1, q2) in the wild.

Facebook: Nothing special.

Test Plan:
fbconfig -r folly && fbmake runtests
fbconfig -r experimental/njormrod/stltest && fbmake runtests

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D1319787
parent 9a51965b
......@@ -737,8 +737,9 @@ public:
}
iterator erase(const_iterator q1, const_iterator q2) {
if (q1 == q2) return unconst(q1);
std::move(unconst(q2), end(), unconst(q1));
for (auto it = q1; it != end(); ++it) {
for (auto it = (end() - std::distance(q1, q2)); it != end(); ++it) {
it->~value_type();
}
this->setSize(size() - (q2 - q1));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment