From 5d3f05bdb60f074eae1301e2ccb9b2a9a4e2a2b3 Mon Sep 17 00:00:00 2001 From: Andrew Gallagher Date: Wed, 8 Aug 2012 18:11:40 -0700 Subject: [PATCH] folly::dynamic: comment about std::vector const-iter erase issue Test Plan: none Reviewed By: delong.j@fb.com FB internal diff: D543196 --- folly/dynamic-inl.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/folly/dynamic-inl.h b/folly/dynamic-inl.h index 94ddea4c..58f89710 100644 --- a/folly/dynamic-inl.h +++ b/folly/dynamic-inl.h @@ -587,6 +587,9 @@ inline std::size_t dynamic::erase(dynamic const& key) { inline dynamic::const_iterator dynamic::erase(const_iterator it) { auto& arr = get(); + // std::vector doesn't have an erase method that works on const iterators, + // even though the standard says it should, so this hack converts to a + // non-const iterator before calling erase. return get().erase(arr.begin() + (it - arr.begin())); } -- 2.34.1