libcopp  1.1.0
Data Structures | Macros | Functions
intrusive_ptr.h File Reference

侵入式智能指针 More...

#include <assert.h>
#include <cstddef>
#include <ostream>
#include <libcopp/utils/config/build_feature.h>
#include <libcopp/utils/config/compiler_features.h>
Include dependency graph for intrusive_ptr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  std::intrusive_ptr< T >
 

Macros

#define UTIL_INTRUSIVE_PTR_ATOMIC_TYPE   ::util::lock::atomic_int_type<size_t>
 
#define UTIL_INTRUSIVE_PTR_REF_MEMBER_DECL(T)
 
#define UTIL_INTRUSIVE_PTR_REF_FN_DECL(T)
 
#define UTIL_INTRUSIVE_PTR_REF_MEMBER_INIT()   this->intrusive_ref_counter_.store(0)
 
#define UTIL_INTRUSIVE_PTR_REF_FN_DEFI(T)
 

Functions

template<typename T , typename U >
bool std::operator== (intrusive_ptr< T > const &a, intrusive_ptr< U > const &b)
 
template<typename T , typename U >
bool std::operator!= (intrusive_ptr< T > const &a, intrusive_ptr< U > const &b)
 
template<typename T , typename U >
bool std::operator== (intrusive_ptr< T > const &a, U *b)
 
template<typename T , typename U >
bool std::operator!= (intrusive_ptr< T > const &a, U *b)
 
template<typename T , typename U >
bool std::operator== (T *a, intrusive_ptr< U > const &b)
 
template<typename T , typename U >
bool std::operator!= (T *a, intrusive_ptr< U > const &b)
 
template<typename T >
bool std::operator< (intrusive_ptr< T > const &a, intrusive_ptr< T > const &b)
 
template<typename T >
void std::swap (intrusive_ptr< T > &lhs, intrusive_ptr< T > &rhs)
 
template<typename T >
T * std::get_pointer (intrusive_ptr< T > const &p)
 
template<typename T , typename U >
intrusive_ptr< T > std::static_pointer_cast (intrusive_ptr< U > const &p)
 
template<typename T , typename U >
intrusive_ptr< T > std::const_pointer_cast (intrusive_ptr< U > const &p)
 
template<typename T , typename U >
intrusive_ptr< T > std::dynamic_pointer_cast (intrusive_ptr< U > const &p)
 
template<typename E , typename T , typename Y >
std::basic_ostream< E, T > & std::operator<< (std::basic_ostream< E, T > &os, intrusive_ptr< Y > const &p)
 

Detailed Description

侵入式智能指针

Note
这不是std标准中的一部分,但是这是对smart_ptr.h的补充 Licensed under the MIT licenses.
Version
1.0
Author
OWenT, owt50[email protected]0813[email protected][email protected][email protected]e.co[email protected]m
Date
2017.05.18

Definition in file intrusive_ptr.h.

Macro Definition Documentation

#define UTIL_INTRUSIVE_PTR_ATOMIC_TYPE   ::util::lock::atomic_int_type<size_t>

Definition at line 250 of file intrusive_ptr.h.

#define UTIL_INTRUSIVE_PTR_REF_FN_DECL (   T)
Value:
void intrusive_ptr_add_ref(T *p); \
void intrusive_ptr_release(T *p);

Definition at line 263 of file intrusive_ptr.h.

#define UTIL_INTRUSIVE_PTR_REF_FN_DEFI (   T)
Value:
void intrusive_ptr_add_ref(T *p) { \
if (nullptr != p) { \
++p->intrusive_ref_counter_; \
} \
} \
void intrusive_ptr_release(T *p) { \
if (nullptr == p) { \
return; \
} \
assert(p->intrusive_ref_counter_.load() > 0); \
size_t ref = --p->intrusive_ref_counter_; \
if (0 == ref) { \
delete p; \
} \
}
libcopp if(LIBCOTASK_MACRO_ENABLED) add_subdirectory("$
Definition: CMakeLists.txt:8

Definition at line 269 of file intrusive_ptr.h.

#define UTIL_INTRUSIVE_PTR_REF_MEMBER_DECL (   T)
Value:
\
private: \
UTIL_INTRUSIVE_PTR_ATOMIC_TYPE intrusive_ref_counter_; \
friend void intrusive_ptr_add_ref(T *p); \
friend void intrusive_ptr_release(T *p); \
\
public: \
const size_t use_count() const { return intrusive_ref_counter_.load(); }
#define UTIL_INTRUSIVE_PTR_ATOMIC_TYPE

Definition at line 253 of file intrusive_ptr.h.

#define UTIL_INTRUSIVE_PTR_REF_MEMBER_INIT ( )    this->intrusive_ref_counter_.store(0)

Definition at line 267 of file intrusive_ptr.h.

Function Documentation

template<typename T , typename U >
intrusive_ptr<T> std::const_pointer_cast ( intrusive_ptr< U > const &  p)

Definition at line 229 of file intrusive_ptr.h.

References std::const_pointer_cast(), and std::intrusive_ptr< T >::get().

Referenced by std::const_pointer_cast().

template<typename T , typename U >
intrusive_ptr<T> std::dynamic_pointer_cast ( intrusive_ptr< U > const &  p)
template<typename T >
T* std::get_pointer ( intrusive_ptr< T > const &  p)

Definition at line 219 of file intrusive_ptr.h.

References std::intrusive_ptr< T >::get(), and std::get_pointer().

Referenced by std::get_pointer().

template<typename T , typename U >
bool std::operator!= ( intrusive_ptr< T > const &  a,
intrusive_ptr< U > const &  b 
)
inline

Definition at line 158 of file intrusive_ptr.h.

References std::intrusive_ptr< T >::get(), and std::operator!=().

Referenced by std::operator!=().

template<typename T , typename U >
bool std::operator!= ( intrusive_ptr< T > const &  a,
U *  b 
)
inline

Definition at line 168 of file intrusive_ptr.h.

References std::intrusive_ptr< T >::get(), and std::operator!=().

template<typename T , typename U >
bool std::operator!= ( T *  a,
intrusive_ptr< U > const &  b 
)
inline
template<typename T >
bool std::operator< ( intrusive_ptr< T > const &  a,
intrusive_ptr< T > const &  b 
)
inline

Definition at line 207 of file intrusive_ptr.h.

template<typename E , typename T , typename Y >
std::basic_ostream<E, T>& std::operator<< ( std::basic_ostream< E, T > &  os,
intrusive_ptr< Y > const &  p 
)

Definition at line 240 of file intrusive_ptr.h.

References std::intrusive_ptr< T >::get().

template<typename T , typename U >
bool std::operator== ( intrusive_ptr< T > const &  a,
intrusive_ptr< U > const &  b 
)
inline

Definition at line 153 of file intrusive_ptr.h.

References std::intrusive_ptr< T >::get(), and std::operator==().

Referenced by std::operator!=(), and std::operator==().

template<typename T , typename U >
bool std::operator== ( intrusive_ptr< T > const &  a,
U *  b 
)
inline

Definition at line 163 of file intrusive_ptr.h.

References std::intrusive_ptr< T >::get(), and std::operator==().

template<typename T , typename U >
bool std::operator== ( T *  a,
intrusive_ptr< U > const &  b 
)
inline

Definition at line 173 of file intrusive_ptr.h.

References std::intrusive_ptr< T >::get(), and std::operator==().

template<typename T , typename U >
intrusive_ptr<T> std::static_pointer_cast ( intrusive_ptr< U > const &  p)
template<typename T >
void std::swap ( intrusive_ptr< T > &  lhs,
intrusive_ptr< T > &  rhs 
)

Definition at line 212 of file intrusive_ptr.h.

References std::intrusive_ptr< T >::swap().