folly::dynamic: comment about std::vector const-iter erase issue
authorAndrew Gallagher <agallagher@fb.com>
Thu, 9 Aug 2012 01:11:40 +0000 (18:11 -0700)
committerTudor Bosman <tudorb@fb.com>
Sun, 26 Aug 2012 18:12:09 +0000 (11:12 -0700)
Test Plan: none

Reviewed By: delong.j@fb.com

FB internal diff: D543196

folly/dynamic-inl.h

index 94ddea4c36cdea72b2c56125bbd7ebc64e7b2584..58f89710d956fc8200eaa1c9174216ffa5cdf9cd 100644 (file)
@@ -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<Array>();
+  // 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<Array>().erase(arr.begin() + (it - arr.begin()));
 }