From: Sara Golemon Date: Wed, 24 Jun 2015 16:32:24 +0000 (-0700) Subject: Change visibility of folly::Arena constructors to public X-Git-Tag: v0.48.0~17 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4514c06cdfe7038b74ab99916824f203a65da446;p=folly.git Change visibility of folly::Arena constructors to public 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 --- diff --git a/folly/Arena.h b/folly/Arena.h index 5121e380..00caa947 100644 --- a/folly/Arena.h +++ b/folly/Arena.h @@ -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> BlockLink; diff --git a/folly/test/ArenaTest.cpp b/folly/test/ArenaTest.cpp index e8699c0f..34211be3 100644 --- a/folly/test/ArenaTest.cpp +++ b/folly/test/ArenaTest.cpp @@ -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);