diff --git a/modules/beast_asio/async/ComposedAsyncOperation.h b/modules/beast_asio/async/ComposedAsyncOperation.h index 54fffe055..a5884ccb1 100644 --- a/modules/beast_asio/async/ComposedAsyncOperation.h +++ b/modules/beast_asio/async/ComposedAsyncOperation.h @@ -87,7 +87,7 @@ protected: #endif } - void destroy () + void destroy () const { delete this; } diff --git a/modules/beast_asio/async/SharedHandlerType.h b/modules/beast_asio/async/SharedHandlerType.h index 40de9f326..89d9f3c4d 100644 --- a/modules/beast_asio/async/SharedHandlerType.h +++ b/modules/beast_asio/async/SharedHandlerType.h @@ -85,11 +85,13 @@ protected: // the size from the original allocation, which we saved at // the time of construction. // - void destroy () + void destroy () const { Handler local (BOOST_ASIO_MOVE_CAST(Handler)(m_handler)); std::size_t const size (m_size); - SharedHandler* const shared (static_cast (this)); + SharedHandler* const shared ( + const_cast ( + static_cast (this))); shared->~SharedHandler (); boost_asio_handler_alloc_helpers:: deallocate (shared, size, local); @@ -109,7 +111,7 @@ protected: protected: std::size_t const m_size; - Handler m_handler; + Handler mutable m_handler; }; //-------------------------------------------------------------------------- diff --git a/modules/beast_core/memory/SharedObject.h b/modules/beast_core/memory/SharedObject.h index c2853db0a..8efd00aeb 100644 --- a/modules/beast_core/memory/SharedObject.h +++ b/modules/beast_core/memory/SharedObject.h @@ -65,7 +65,7 @@ public: This is done automatically by the smart pointer, but is public just in case it's needed for nefarious purposes. */ - inline void incReferenceCount() noexcept + inline void incReferenceCount() const noexcept { ++refCount; } @@ -79,7 +79,7 @@ public: The return value indicates if the reference count dropped to zero, so callers who know the derived type can use the ContainerDeletePolicy. */ - void decReferenceCount () + void decReferenceCount () const { bassert (getReferenceCount() > 0); if (--refCount == 0) @@ -109,7 +109,7 @@ protected: /** Destroy the object. Derived classes can override this for different behaviors. */ - virtual void destroy () + virtual void destroy () const { delete this; } @@ -124,7 +124,7 @@ protected: private: //============================================================================== - Atomic refCount; + Atomic mutable refCount; }; //============================================================================== @@ -184,7 +184,7 @@ protected: bassert (getReferenceCount() == 0); } - virtual void destroy () + virtual void destroy () const { delete this; }