return bytesUsed_;
}
- private:
// not copyable
Arena(const Arena&) = delete;
Arena& operator=(const Arena&) = delete;
Arena(Arena&&) = default;
Arena& operator=(Arena&&) = default;
+ private:
struct Block;
typedef boost::intrusive::slist_member_hook<
boost::intrusive::tag<Arena>> BlockLink;
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);