About RefPtr Cast Avoidance Modification

About RefPtr Cast Avoidance Modification
0
#1

Hi,
My name is Yukio Murakai (m-yukio).

Commits on Jun 26, 2016 “Improve RefPtr to avoid casting when possible”,
changed the type of _ptr from Ref to a pointer of T,
T is forward declaration (incomplete type),
If called by an inline function defined in a header file, a build error will occur.

The error is the following code:

const_cast<Ref*>(static_cast<const Ref*>(ptr))->release();

static_assert(std::is_base_of<Ref, typename std::remove_const<T>::type>::value, "T must be derived from Ref");

I understand the reason for reducing the cast, but
Since RefPtr is a class that manages instances of Ref, the previous implementation seems to be straightforward.

0 Likes