Skip to content

Commit 880e512

Browse files
committed
Use int instead of std::size_t for ref count (like GCC's shared_ptr)
1 parent c9d616a commit 880e512

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/oup/observable_unique_ptr.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class observer_ptr;
1212

1313
namespace details {
1414
struct control_block {
15-
std::size_t refcount = 1u;
15+
int refcount = 1;
1616
bool placement_allocated = false;
1717
bool expired = false;
1818
};
@@ -60,7 +60,7 @@ class observable_unique_ptr {
6060

6161
static void pop_ref_(control_block* block) noexcept {
6262
--block->refcount;
63-
if (block->refcount == 0u) {
63+
if (block->refcount == 0) {
6464
if constexpr (std::is_same_v<Deleter, std::default_delete<T>>) {
6565
if (block->placement_allocated) {
6666
block->~control_block();
@@ -401,7 +401,7 @@ observable_unique_ptr<T> make_observable_unique(Args&& ... args) {
401401

402402
try {
403403
// Construct control block and object
404-
block_type* block = new (buffer) details::control_block{1u, true, false};
404+
block_type* block = new (buffer) details::control_block{1, true, false};
405405
T* ptr = new (buffer + block_size) T(std::forward<Args>(args)...);
406406

407407
// Make owner pointer
@@ -463,7 +463,7 @@ class observer_ptr {
463463

464464
void pop_ref_() noexcept {
465465
--block->refcount;
466-
if (block->refcount == 0u) {
466+
if (block->refcount == 0) {
467467
if (block->placement_allocated) {
468468
block->~control_block();
469469
delete[] reinterpret_cast<std::byte*>(block);

0 commit comments

Comments
 (0)