summaryrefslogtreecommitdiffhomepage
path: root/compat/borrowed-ptr.cpp
blob: 04919df07d359ab5092caa53e09f7abae9b28636 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "borrowed-ptr.inl"
#include "compat/assert.hpp"

namespace floormat::detail_bptr {

void control_block::decrement(control_block*& blk) noexcept
{
    auto c = --blk->_count;
    fm_bptr_assert(c != (uint32_t)-1);
    if (c == 0)
    {
        delete blk->_ptr;
        delete blk;
    }
    blk = nullptr;
    //blk = (control_block*)-1;
}

} // namespace floormat::detail_bptr

namespace floormat {

bptr_base::~bptr_base() noexcept = default;
bptr_base::bptr_base() noexcept = default;
bptr_base::bptr_base(const bptr_base&) noexcept = default;
bptr_base::bptr_base(bptr_base&&) noexcept = default;
bptr_base& bptr_base::operator=(const bptr_base&) noexcept = default;
bptr_base& bptr_base::operator=(bptr_base&&) noexcept = default;

} // namespace floormat