libcopp  1.3.0
Data Structures | Namespaces | Macros | Functions
intrusive_ptr.h File Reference

侵入式智能指针 More...

#include <assert.h>
#include <cstddef>
#include <memory>
#include <ostream>
#include <libcopp/utils/config/compiler_features.h>
#include <libcopp/utils/config/libcopp_build_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  libcopp::util::intrusive_ptr< T >
 

Namespaces

 libcopp
 
 libcopp::util
 

Macros

#define LIBCOPP_UTIL_INTRUSIVE_PTR_ATOMIC_TYPE   ::libcopp::util::lock::atomic_int_type<size_t>
 
#define LIBCOPP_UTIL_INTRUSIVE_PTR_REF_MEMBER_DECL(T)
 
#define LIBCOPP_UTIL_INTRUSIVE_PTR_REF_FN_DECL(T)
 
#define LIBCOPP_UTIL_INTRUSIVE_PTR_REF_MEMBER_INIT()   this->intrusive_ref_counter_.store(0)
 
#define LIBCOPP_UTIL_INTRUSIVE_PTR_REF_FN_DEFI(T)
 

Functions

template<typename T , typename U >
bool libcopp::util::operator== (intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator== (intrusive_ptr< T > const &a, U *b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator== (T *a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator!= (intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator!= (intrusive_ptr< T > const &a, U *b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator!= (T *a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator< (intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator< (intrusive_ptr< T > const &a, U *b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator< (T *a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator<= (intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator<= (intrusive_ptr< T > const &a, U *b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator<= (T *a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator> (intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator> (intrusive_ptr< T > const &a, U *b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator> (T *a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator>= (intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator>= (intrusive_ptr< T > const &a, U *b) UTIL_CONFIG_NOEXCEPT
 
template<typename T , typename U >
bool libcopp::util::operator>= (T *a, intrusive_ptr< U > const &b) UTIL_CONFIG_NOEXCEPT
 
template<typename T >
void libcopp::util::swap (intrusive_ptr< T > &lhs, intrusive_ptr< T > &rhs)
 
template<typename T >
T * libcopp::util::get_pointer (intrusive_ptr< T > const &p)
 
template<typename T , typename U >
intrusive_ptr< T > libcopp::util::static_pointer_cast (intrusive_ptr< U > const &p)
 
template<typename T , typename U >
intrusive_ptr< T > libcopp::util::const_pointer_cast (intrusive_ptr< U > const &p)
 
template<typename E , typename T , typename Y >
std::basic_ostream< E, T > & libcopp::util::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 LIBCOPP_UTIL_INTRUSIVE_PTR_ATOMIC_TYPE   ::libcopp::util::lock::atomic_int_type<size_t>

Definition at line 386 of file intrusive_ptr.h.

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

Definition at line 399 of file intrusive_ptr.h.

#define LIBCOPP_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 405 of file intrusive_ptr.h.

#define LIBCOPP_UTIL_INTRUSIVE_PTR_REF_MEMBER_DECL (   T)
Value:
\
private: \
LIBCOPP_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 LIBCOPP_UTIL_INTRUSIVE_PTR_ATOMIC_TYPE

Definition at line 389 of file intrusive_ptr.h.

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

Definition at line 403 of file intrusive_ptr.h.