12 #if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
15 #ifndef OPTIONAL_ENUM_CLASS
16 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
17 #define OPTIONAL_ENUM_CLASS enum class
19 #define OPTIONAL_ENUM_CLASS enum
25 OPTIONAL_ENUM_CLASS RefCountReleaseStatus { kDroppedLastRef, kOtherRefsRemained };
33 virtual void AddRef()
const = 0;
34 virtual RefCountReleaseStatus Release()
const = 0;
35 virtual bool HasOneRef()
const = 0;
49 if (ptr_) ptr_->AddRef();
54 if (ptr_) ptr_->AddRef();
58 if (ptr_) ptr_->AddRef();
63 if (ptr_) ptr_->AddRef();
66 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
77 T* get()
const {
return ptr_; }
78 operator bool()
const {
return (ptr_ != NULL); }
80 T* operator->()
const {
return ptr_; }
81 T& operator*()
const {
return *ptr_; }
95 if (ptr_ == p)
return *
this;
98 if (ptr_) ptr_->Release();
104 return *
this = r.get();
107 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
113 template <
typename U>
121 bool operator==(
const agora_refptr<T>& r)
const {
return ptr_ == r.ptr_; }
124 bool operator<(
const agora_refptr<T>& r)
const {
return ptr_ < r.ptr_; }
147 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
149 template <
typename T>
150 struct hash<agora::agora_refptr<T>> {
152 return reinterpret_cast<size_t>(k.get());