std::map and std::set are not relocatable
authorTudor Bosman <tudorb@fb.com>
Thu, 22 Aug 2013 14:26:48 +0000 (07:26 -0700)
committerSara Golemon <sgolemon@fb.com>
Wed, 28 Aug 2013 21:30:12 +0000 (14:30 -0700)
Summary: https://github.com/facebook/folly/issues/35

@override-unit-failures
hphp tests independently broken

Test Plan: test added

Reviewed By: delong.j@fb.com

FB internal diff: D939323

folly/Traits.h
folly/test/FBVectorTest.cpp
folly/test/TraitsTest.cpp

index e5f6b38cfcc024a42fd168858fd4f1e2a1e0af3e..37bd58d389f4114b079be3324a95d1303c2633aa 100644 (file)
@@ -422,8 +422,6 @@ FOLLY_ASSUME_FBVECTOR_COMPATIBLE_3(std::basic_string);
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(std::vector);
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(std::list);
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(std::deque);
-FOLLY_ASSUME_FBVECTOR_COMPATIBLE_4(std::map);
-FOLLY_ASSUME_FBVECTOR_COMPATIBLE_3(std::set);
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(std::unique_ptr);
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(std::shared_ptr);
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(std::function);
index a8a1b2ac4632c25a2f71885d045b94887a93f0b4..d3747fcd39f6a70e1ac7233534cf49316b32ae57 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <gtest/gtest.h>
 #include <list>
+#include <map>
 #include <memory>
 #include <boost/random.hpp>
 
@@ -256,6 +257,23 @@ TEST(FBVector, reserve_consistency) {
   }
 }
 
+TEST(FBVector, vector_of_maps) {
+  fbvector<std::map<std::string, std::string>> v;
+
+  v.push_back(std::map<std::string, std::string>());
+  v.push_back(std::map<std::string, std::string>());
+
+  EXPECT_EQ(2, v.size());
+
+  v[1]["hello"] = "world";
+  EXPECT_EQ(0, v[0].size());
+  EXPECT_EQ(1, v[1].size());
+
+  v[0]["foo"] = "bar";
+  EXPECT_EQ(1, v[0].size());
+  EXPECT_EQ(1, v[1].size());
+}
+
 int main(int argc, char** argv) {
   testing::InitGoogleTest(&argc, argv);
   google::ParseCommandLineFlags(&argc, &argv, true);
index 784524e13822080466eb6d5a78315f98ce8bc18d..8e7b5d7ae76bd813dede74619ae03fc516dad1e2 100644 (file)
@@ -50,7 +50,6 @@ TEST(Traits, containers) {
   EXPECT_TRUE  (IsRelocatable<vector<F1>>::value);
   EXPECT_FALSE((IsRelocatable<pair<F1, F1>>::value));
   EXPECT_TRUE ((IsRelocatable<pair<T1, T2>>::value));
-  EXPECT_TRUE  (IsRelocatable<set<F1>>::value);
 }
 
 TEST(Traits, original) {