From c2d1773b4190c8165ad1001da361dbe127e57813 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 28 Jan 2015 15:46:14 +0100 Subject: [PATCH] (ObjectRef) Added implicit conversion constructor/operator Former-commit-id: c633956130731e84c6d15d09961cd80c8d24877a --- include/Nazara/Core/ObjectRef.hpp | 2 ++ include/Nazara/Core/ObjectRef.inl | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/Nazara/Core/ObjectRef.hpp b/include/Nazara/Core/ObjectRef.hpp index 715b56fdd..35d016f90 100644 --- a/include/Nazara/Core/ObjectRef.hpp +++ b/include/Nazara/Core/ObjectRef.hpp @@ -20,6 +20,7 @@ class NzObjectRef NzObjectRef(); NzObjectRef(T* object); NzObjectRef(const NzObjectRef& ref); + template NzObjectRef(const NzObjectRef& ref); NzObjectRef(NzObjectRef&& ref) noexcept; ~NzObjectRef(); @@ -35,6 +36,7 @@ class NzObjectRef NzObjectRef& operator=(T* object); NzObjectRef& operator=(const NzObjectRef& ref); + template NzObjectRef& operator=(const NzObjectRef& ref); NzObjectRef& operator=(NzObjectRef&& ref) noexcept; private: diff --git a/include/Nazara/Core/ObjectRef.inl b/include/Nazara/Core/ObjectRef.inl index fed88a6fb..febc2d528 100644 --- a/include/Nazara/Core/ObjectRef.inl +++ b/include/Nazara/Core/ObjectRef.inl @@ -27,6 +27,13 @@ m_object(ref.m_object) m_object->AddReference(); } +template +template +NzObjectRef::NzObjectRef(const NzObjectRef& ref) : +NzObjectRef(ref.Get()) +{ +} + template NzObjectRef::NzObjectRef(NzObjectRef&& ref) noexcept : m_object(ref.m_object) @@ -124,6 +131,15 @@ NzObjectRef& NzObjectRef::operator=(const NzObjectRef& ref) return *this; } +template +template +NzObjectRef& NzObjectRef::operator=(const NzObjectRef& ref) +{ + Reset(ref.Get()); + + return *this; +} + template NzObjectRef& NzObjectRef::operator=(NzObjectRef&& ref) noexcept {