From b57cfc00ce7e280fb89a421fc2402cfcc14337b7 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Thu, 16 Jun 2016 18:12:47 -0700 Subject: [PATCH] Fix infinite recursion in sorted_vector_{set|map}::insert(const value_type&) Summary: We were calling ourself, which MSVC correctly identified: ``` warning C4717: 'folly::sorted_vector_set,std::allocator,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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/folly/sorted_vector_types.h b/folly/sorted_vector_types.h index b9354b10..e9f77d3a 100644 --- a/folly/sorted_vector_types.h +++ b/folly/sorted_vector_types.h @@ -244,7 +244,7 @@ public: size_type capacity() const { return m_.cont_.capacity(); } std::pair insert(const value_type& value) { - return insert(value_type(value)); + return insert(std::move(value_type(value))); } std::pair 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 insert(const value_type& value) { - return insert(value_type(value)); + return insert(std::move(value_type(value))); } std::pair 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) { -- 2.34.1