Fix infinite recursion in sorted_vector_{set|map}::insert(const value_type&)
authorChristopher Dykes <cdykes@fb.com>
Fri, 17 Jun 2016 01:12:47 +0000 (18:12 -0700)
committerFacebook Github Bot 9 <facebook-github-bot-9-bot@fb.com>
Fri, 17 Jun 2016 01:23:22 +0000 (18:23 -0700)
Summary:
We were calling ourself, which MSVC correctly identified:
```
warning C4717: 'folly::sorted_vector_set<int,`anonymous namespace'::less_invert<int>,std::allocator<int>,void>::insert': recursive on all control paths, function will cause runtime stack overflow
```

Just add an explicit `std::move` in to solve the problem.

Reviewed By: yfeldblum

Differential Revision: D3447922

fbshipit-source-id: 803f79510b3dbfeea32a9629238448f69f5b78dc

folly/sorted_vector_types.h

index b9354b10cbb9bdd7e4ae49e7f4b1336c9dfa8b00..e9f77d3a5eb13a2a5f592ff1097686687973a507 100644 (file)
@@ -244,7 +244,7 @@ public:
   size_type capacity() const    { return m_.cont_.capacity(); }
 
   std::pair<iterator,bool> insert(const value_type& value) {
-    return insert(value_type(value));
+    return insert(std::move(value_type(value)));
   }
 
   std::pair<iterator,bool> insert(value_type&& value) {
@@ -257,7 +257,7 @@ public:
   }
 
   iterator insert(iterator hint, const value_type& value) {
-    return insert(hint, value_type(value));
+    return insert(hint, std::move(value_type(value)));
   }
 
   iterator insert(iterator hint, value_type&& value) {
@@ -488,7 +488,7 @@ public:
   size_type capacity() const    { return m_.cont_.capacity(); }
 
   std::pair<iterator,bool> insert(const value_type& value) {
-    return insert(value_type(value));
+    return insert(std::move(value_type(value)));
   }
 
   std::pair<iterator,bool> insert(value_type&& value) {
@@ -501,7 +501,7 @@ public:
   }
 
   iterator insert(iterator hint, const value_type& value) {
-    return insert(hint, value_type(value));
+    return insert(hint, std::move(value_type(value)));
   }
 
   iterator insert(iterator hint, value_type&& value) {