Change visibility of folly::Arena constructors to public
authorSara Golemon <sgolemon@fb.com>
Wed, 24 Jun 2015 16:32:24 +0000 (09:32 -0700)
committerSara Golemon <sgolemon@fb.com>
Wed, 24 Jun 2015 16:41:06 +0000 (09:41 -0700)
Summary: In the case of the copy constructor, this change
doesn't really matter, since it's deleted anyway.

In the case of the move constructor, it fixes what was probably
an unintentional hiding.  The class certainly looks like
it supports moving.

Closes #121

Reviewed By: @yfeldblum

Differential Revision: D2184131

folly/Arena.h
folly/test/ArenaTest.cpp

index 5121e380098d9c556ab0922514a5216aec636bf3..00caa947abba291e2bdc07e1e3b7318ed7ff1bba 100644 (file)
@@ -119,7 +119,6 @@ class Arena {
     return bytesUsed_;
   }
 
- private:
   // not copyable
   Arena(const Arena&) = delete;
   Arena& operator=(const Arena&) = delete;
@@ -128,6 +127,7 @@ class Arena {
   Arena(Arena&&) = default;
   Arena& operator=(Arena&&) = default;
 
+ private:
   struct Block;
   typedef boost::intrusive::slist_member_hook<
     boost::intrusive::tag<Arena>> BlockLink;
index e8699c0fb5e7a13a34938b5c979d370059a868da..34211be39bb696d9ebbe760891dc487ff5b00988 100644 (file)
@@ -157,6 +157,17 @@ TEST(Arena, SizeLimit) {
   EXPECT_THROW(arena.allocate(maxSize + 1), std::bad_alloc);
 }
 
+TEST(Arena, MoveArena) {
+  SysArena arena(sizeof(size_t) * 2);
+  arena.allocate(sizeof(size_t));
+  auto totalSize = arena.totalSize();
+  auto bytesUsed = arena.bytesUsed();
+
+  SysArena moved(std::move(arena));
+  EXPECT_EQ(totalSize, moved.totalSize());
+  EXPECT_EQ(bytesUsed, moved.bytesUsed());
+}
+
 int main(int argc, char *argv[]) {
   testing::InitGoogleTest(&argc, argv);
   gflags::ParseCommandLineFlags(&argc, &argv, true);