add 'makeRef' for easier making a RefPtr (#17302)

This commit is contained in:
Jeff Wang 2017-02-08 10:00:08 +08:00 committed by minggo
parent 9381152ef1
commit ae60397472
1 changed files with 7 additions and 1 deletions

View File

@ -269,7 +269,13 @@ private:
// NOTE: We can ensure T is derived from cocos2d::Ref at compile time here. // NOTE: We can ensure T is derived from cocos2d::Ref at compile time here.
static_assert(std::is_base_of<Ref, typename std::remove_const<T>::type>::value, "T must be derived from Ref"); static_assert(std::is_base_of<Ref, typename std::remove_const<T>::type>::value, "T must be derived from Ref");
}; };
template <class T> inline
RefPtr<T> makeRef(T *ptr)
{
return RefPtr<T>(ptr);
}
template<class T> inline template<class T> inline
bool operator<(const RefPtr<T>& r, std::nullptr_t) bool operator<(const RefPtr<T>& r, std::nullptr_t)
{ {