From 447ae56fd5b809b6c796c6739dbb1502bdfef284 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 17 Jul 2016 18:17:49 +0200 Subject: [PATCH] [DEBUG] correct pb on the 'void& operator*()' --- ememory/SharedPtr.h | 58 +++++++++++++++++++++++------------ ememory/details/SharedPtr.hxx | 15 +++------ 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/ememory/SharedPtr.h b/ememory/SharedPtr.h index 1fdc23e..7138e5d 100644 --- a/ememory/SharedPtr.h +++ b/ememory/SharedPtr.h @@ -53,36 +53,54 @@ namespace ememory { public: void reset(); int64_t useCount() const; - bool operator == (std::nullptr_t) const; + bool operator==(std::nullptr_t) const; bool operator==(const SharedPtr& _obj) const; - bool operator != (std::nullptr_t) const; + bool operator!=(std::nullptr_t) const; bool operator!=(const SharedPtr& _obj) const; const EMEMORY_TYPE* get() const; EMEMORY_TYPE* get(); - template::value - && !std::is_same::value - , int>::type = 0> const EMEMORY_TYPE* operator->() const; - template::value - && !std::is_same::value - , int>::type = 0> EMEMORY_TYPE* operator->(); - template::value - && !std::is_same::value - , int>::type = 0> - const EMEMORY_TYPE& operator*() const; - template::value - && !std::is_same::value - , int>::type = 0> - EMEMORY_TYPE& operator*(); + #if 0 + template<> + const typename std::enable_if::value, EMEMORY_TYPE>::type& operator*() const { + return *m_element; + } + template<> + typename std::enable_if::value, EMEMORY_TYPE&>::type operator*() { + return *m_element; + } + #else + #if 1 + template::value + && !std::is_void::value + , int>::type> + const EMEMORY_TYPE2& operator*() const { + return *m_element; + } + template::value + && !std::is_void::value + , int>::type> + EMEMORY_TYPE2& operator*() { + return *m_element; + } + #else + const EMEMORY_TYPE& operator*() const { + return *m_element; + } + EMEMORY_TYPE& operator*() { + return *m_element; + } + #endif + #endif void swap(SharedPtr& _obj); ememory::Counter* getCounter() const { return m_counter; } + // TODO: unique + // TODO: bool }; } diff --git a/ememory/details/SharedPtr.hxx b/ememory/details/SharedPtr.hxx index f47bec9..e18d85e 100644 --- a/ememory/details/SharedPtr.hxx +++ b/ememory/details/SharedPtr.hxx @@ -235,27 +235,19 @@ EMEMORY_TYPE* ememory::SharedPtr::get() { } template -template::value - && !std::is_same::value - , int>::type> const EMEMORY_TYPE* ememory::SharedPtr::operator->() const { return m_element; } template -template::value - && !std::is_same::value - , int>::type> EMEMORY_TYPE* ememory::SharedPtr::operator->() { return m_element; } - +/* template template::value - && !std::is_same::value + && !std::is_void::value , int>::type> const EMEMORY_TYPE& ememory::SharedPtr::operator*() const { return *m_element; @@ -264,11 +256,12 @@ const EMEMORY_TYPE& ememory::SharedPtr::operator*() const { template template::value - && !std::is_same::value + && !std::is_void::value , int>::type> EMEMORY_TYPE& ememory::SharedPtr::operator*() { return *m_element; } +*/ template void ememory::SharedPtr::swap(SharedPtr& _obj) {