Making StlAllocator<Alloc, void> usable when rebinding.
[folly.git] / folly / test / MemoryTest.cpp
index 82f1a50b118fbb7882a35a3866536a584451ae80..c9409d2206148247e31b0cc08258da1b1dbb6861 100644 (file)
@@ -43,6 +43,21 @@ TEST(as_stl_allocator, sanity_check) {
   >::value));
 }
 
+TEST(StlAllocator, void_allocator) {
+  typedef StlAllocator<SysArena, void> void_allocator;
+  SysArena arena;
+  void_allocator valloc(&arena);
+
+  typedef void_allocator::rebind<int>::other int_allocator;
+  int_allocator ialloc(valloc);
+
+  auto i = std::allocate_shared<int>(ialloc, 10);
+  ASSERT_NE(nullptr, i.get());
+  EXPECT_EQ(10, *i);
+  i.reset();
+  ASSERT_EQ(nullptr, i.get());
+}
+
 int main(int argc, char **argv) {
   FLAGS_logtostderr = true;
   google::InitGoogleLogging(argv[0]);