mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
Merge branch 'refactoring' of github.com:mutouyun/cpp-ipc into refactoring
This commit is contained in:
commit
bbe1bb3fb7
@ -283,7 +283,7 @@ class holder<void, true> : public holder_base {
|
|||||||
public:
|
public:
|
||||||
template <typename Value>
|
template <typename Value>
|
||||||
static std::size_t full_sizeof(std::size_t count) noexcept {
|
static std::size_t full_sizeof(std::size_t count) noexcept {
|
||||||
return offsetof(holder, info_) + detail::full_sizeof<Value>(count);
|
return sizeof(holder) - sizeof(info_) + detail::full_sizeof<Value>(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder() noexcept
|
holder() noexcept
|
||||||
|
|||||||
@ -74,17 +74,24 @@ TEST(small_storage, holder_copy_move) {
|
|||||||
h5.destroy(alc);
|
h5.destroy(alc);
|
||||||
h6.destroy(alc);
|
h6.destroy(alc);
|
||||||
|
|
||||||
pmr::holder<void, true> h7(alc, ::LIBIMP::types<int>{}, 10);
|
void *ph1 = std::malloc(pmr::holder<void, true>::full_sizeof<int>(10));
|
||||||
pmr::holder<void, true> h8, h9;
|
void *ph2 = std::malloc(pmr::holder<void, true>::full_sizeof<int>(10));
|
||||||
h7.copy_to(alc, &h8);
|
void *ph3 = std::malloc(pmr::holder<void, true>::full_sizeof<int>(10));
|
||||||
EXPECT_EQ(h7.count(), 10);
|
auto *h7 = ::new (ph1) pmr::holder<void, true>(alc, ::LIBIMP::types<int>{}, 10);
|
||||||
EXPECT_EQ(h8.count(), 10);
|
auto *h8 = ::new (ph2) pmr::holder<void, true>;
|
||||||
h7.move_to(alc, &h9);
|
auto *h9 = ::new (ph2) pmr::holder<void, true>;
|
||||||
EXPECT_EQ(h7.count(), 0);
|
h7->copy_to(alc, h8);
|
||||||
EXPECT_EQ(h9.count(), 10);
|
EXPECT_EQ(h7->count(), 10);
|
||||||
h7.destroy(alc);
|
EXPECT_EQ(h8->count(), 10);
|
||||||
h8.destroy(alc);
|
h7->move_to(alc, h9);
|
||||||
h9.destroy(alc);
|
EXPECT_EQ(h7->count(), 0);
|
||||||
|
EXPECT_EQ(h9->count(), 10);
|
||||||
|
h7->destroy(alc);
|
||||||
|
h8->destroy(alc);
|
||||||
|
h9->destroy(alc);
|
||||||
|
std::free(ph1);
|
||||||
|
std::free(ph2);
|
||||||
|
std::free(ph3);
|
||||||
|
|
||||||
pmr::holder<void, false> h10(alc, ::LIBIMP::types<int>{}, 10);
|
pmr::holder<void, false> h10(alc, ::LIBIMP::types<int>{}, 10);
|
||||||
pmr::holder<void, false> h11, h12;
|
pmr::holder<void, false> h11, h12;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user