Skip to content

Commit

Permalink
Fix for boost 1.86.0 flat_map::extract_sequence
Browse files Browse the repository at this point in the history
Summary:
Boost 1.86.0 has a bug with flat_map::extract_sequence.
Let's use a workaround for now.

See boostorg/container#288 for upstream report.

Reviewed By: arnaudvenet

Differential Revision: D62103078

fbshipit-source-id: c54777faff875635ed025b16e78a99aaf555453f
  • Loading branch information
arthaud authored and facebook-github-bot committed Sep 4, 2024
1 parent 07d0632 commit 507430f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/sparta/FlatMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,18 @@ class FlatMap final
break;
}
default: {
#if (BOOST_VERSION / 100) >= 1086
// TODO(T200541423): Boost 1.86.0 has a bug with `extract_sequence()` and
// `adopt_sequence`. Let's disable the optimization for now. See
// https://github.com/boostorg/container/issues/288
for (auto it = m_map.begin(); it != m_map.end();) {
if (!predicate(it->first, it->second)) {
it = m_map.erase(it);
} else {
++it;
}
}
#else
// Use boost `flat_map` API to get the underlying container and
// apply a remove_if + erase. This allows to perform a filter in O(n).
auto container = m_map.extract_sequence();
Expand All @@ -293,6 +305,7 @@ class FlatMap final
container.end());
m_map.adopt_sequence(boost::container::ordered_unique_range,
std::move(container));
#endif
break;
}
}
Expand Down

0 comments on commit 507430f

Please sign in to comment.