From: Andrew Gallagher Date: Thu, 9 Aug 2012 01:11:40 +0000 (-0700) Subject: folly::dynamic: comment about std::vector const-iter erase issue X-Git-Tag: v0.22.0~1219 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=5d3f05bdb60f074eae1301e2ccb9b2a9a4e2a2b3;p=folly.git folly::dynamic: comment about std::vector const-iter erase issue Test Plan: none Reviewed By: delong.j@fb.com FB internal diff: D543196 --- 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())); }