Commit f793d7ed authored by Dominik Charousset's avatar Dominik Charousset

Enable intrusive_ptr<const T>

parent eb1cc7b1
......@@ -32,7 +32,7 @@ public:
/// reference of this object before calling this member
/// function. This information is important when
/// implementing a type with support for weak pointers.
virtual void request_deletion(bool decremented_rc) noexcept;
virtual void request_deletion(bool decremented_rc) const noexcept;
protected:
virtual ~memory_managed();
......
......@@ -38,13 +38,13 @@ public:
ref_counted& operator=(const ref_counted&);
/// Increases reference count by one.
inline void ref() noexcept {
inline void ref() const noexcept {
rc_.fetch_add(1, std::memory_order_relaxed);
}
/// Decreases reference count by one and calls `request_deletion`
/// when it drops to zero.
void deref() noexcept;
void deref() const noexcept;
/// Queries whether there is exactly one reference.
inline bool unique() const noexcept {
......@@ -56,16 +56,16 @@ public:
}
protected:
std::atomic<size_t> rc_;
mutable std::atomic<size_t> rc_;
};
/// @relates ref_counted
inline void intrusive_ptr_add_ref(ref_counted* p) {
inline void intrusive_ptr_add_ref(const ref_counted* p) {
p->ref();
}
/// @relates ref_counted
inline void intrusive_ptr_release(ref_counted* p) {
inline void intrusive_ptr_release(const ref_counted* p) {
p->deref();
}
......
......@@ -24,7 +24,7 @@ memory_managed::~memory_managed() {
// nop
}
void memory_managed::request_deletion(bool) noexcept {
void memory_managed::request_deletion(bool) const noexcept {
delete this;
}
......
......@@ -37,7 +37,7 @@ ref_counted& ref_counted::operator=(const ref_counted&) {
return *this;
}
void ref_counted::deref() noexcept {
void ref_counted::deref() const noexcept {
if (unique()) {
request_deletion(false);
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment