libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
|
A unique pointer-type that has threading specified as a trait. More...
#include <unique_ptr.hpp>
Public Types | |
using | value_type = V |
A convenience typedef to the type to be controlled. More... | |
using | element_type = value_type |
A convenience typedef to the type to be controlled. More... | |
using | lock_traits = LkT |
using | atomic_ptr_t = typename lock_traits::template atomic< value_type * > |
The (potentially) lock-free pointer type. More... | |
using | deleter_t = typename value_type::deleter_t |
Make sure the correct object-deletion mechanism is used. More... | |
using | no_deletion = noop_dtor< typename value_type::deleter_t::element_type > |
Public Member Functions | |
atomic_ptr_t __fastcall | release () noexcept(true) FORCE_INLINE |
constexpr __stdcall | unique_ptr () noexcept(true) FORCE_INLINE |
constexpr __stdcall | unique_ptr (value_type *ptr) noexcept(true) FORCE_INLINE |
template<class V1 > | |
__stdcall FORCE_INLINE | unique_ptr (V1 *ptr) noexcept(true) |
__stdcall | unique_ptr (atomic_ptr_t &&ptr) noexcept(true) FORCE_INLINE |
template<class V1 , template< class > class At> | |
__stdcall FORCE_INLINE | unique_ptr (At< V1 * > &&ptr) noexcept(true) |
constexpr __stdcall | unique_ptr (std::unique_ptr< value_type, deleter_t > &&ptr) noexcept(true) FORCE_INLINE |
template<class V1 > | |
__stdcall | unique_ptr (std::unique_ptr< V1, typename V1::deleter_t > &&ptr) noexcept(true) FORCE_INLINE |
template<class V2 , class LkT2 > | |
__stdcall FORCE_INLINE | unique_ptr (unique_ptr< V2, LkT2 > &&s) noexcept(true) |
constexpr | unique_ptr (unique_ptr &&s) noexcept(true) FORCE_INLINE |
__stdcall | ~unique_ptr () noexcept(true) FORCE_INLINE |
template<class V2 , class LkT2 > | |
void | operator= (unique_ptr< V2, LkT2 > &&s) noexcept(true) FORCE_INLINE |
void | operator= (unique_ptr &&s) noexcept(true) FORCE_INLINE |
void __fastcall | reset () noexcept(true) FORCE_INLINE |
constexpr bool __fastcall | operator== (const unique_ptr &s) const noexcept(true) FORCE_INLINE |
constexpr bool __fastcall | operator!= (const unique_ptr &s) const noexcept(true) FORCE_INLINE |
constexpr bool __fastcall | operator< (const unique_ptr &s) const noexcept(true) FORCE_INLINE |
constexpr bool __fastcall | operator> (const unique_ptr &s) const noexcept(true) FORCE_INLINE |
constexpr | operator bool () const noexcept(true) FORCE_INLINE |
constexpr const atomic_ptr_t &__fastcall | get () const noexcept(true) FORCE_INLINE |
atomic_ptr_t &__fastcall | get () noexcept(true) FORCE_INLINE |
constexpr const value_type &__fastcall | operator* () const noexcept(true) FORCE_INLINE |
value_type &__fastcall | operator* () noexcept(true) FORCE_INLINE |
constexpr value_type const *__fastcall | operator-> () const noexcept(true) FORCE_INLINE |
value_type *__fastcall | operator-> () noexcept(true) FORCE_INLINE |
void | swap (unique_ptr &s) noexcept(true) FORCE_INLINE |
template<class V1 > | |
__fastcall void FORCE_INLINE | swap (unique_ptr< V1, LkT > &s) noexcept(true) |
template<class V2 , class LkT2 > | |
__fastcall void FORCE_INLINE | swap (unique_ptr< V2, LkT2 > &s) noexcept(true) |
tstring | to_string () const noexcept(false) |
template<class V1 > | |
void | swap (unique_ptr< V1, LkT > &s) noexcept(true) |
template<class V2 , class LkT2 > | |
void | swap (unique_ptr< V2, LkT2 > &s) noexcept(true) |
template<class V1 > | |
unique_ptr (V1 *ptr) noexcept(true) | |
template<class V1 , template< class > class At> | |
unique_ptr (At< V1 * > &&ptr) noexcept(true) | |
template<class V1 > | |
unique_ptr (std::unique_ptr< V1, typename V1::deleter_t > &&d) noexcept(true) | |
template<typename V2 , class LkT2 > | |
unique_ptr (unique_ptr< V2, LkT2 > &&s) noexcept(true) | |
Static Public Attributes | |
static constexpr ppd::generic_traits::memory_access_modes | memory_access_mode =atomic_ptr_t::memory_access_mode |
Friends | |
template<class , class > | |
class | unique_ptr |
tostream &__fastcall | operator<< (tostream &os, unique_ptr const &ptr) noexcept(false) FORCE_INLINE |
A unique pointer-type that has threading specified as a trait.
I don't use boost::scoped_ptr nor std::unique_ptr as they are insufficiently flexible for my purposes: the multi-threading model they use is not a trait, and the deleter is part of the type, which won't work in a container in the way I need. This class uses a lock-free implementation ultimately based upon std::atomic.
Definition at line 38 of file unique_ptr.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::atomic_ptr_t = typename lock_traits::template atomic<value_type *> |
The (potentially) lock-free pointer type.
We need the operations on the contained pointer (to the managed object) to be atomic because the move operations might occur on more than one thread, and therefore there is a race condition on non-SMP architectures, which is avoided if (in the implementation) the operations on the contained pointer are atomic.
Definition at line 47 of file unique_ptr.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::deleter_t = typename value_type::deleter_t |
Make sure the correct object-deletion mechanism is used.
Definition at line 49 of file unique_ptr.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::element_type = value_type |
A convenience typedef to the type to be controlled.
Definition at line 41 of file unique_ptr.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::lock_traits = LkT |
This does not have to be the same as the element_type, as it may not contain any lock_traits, or we may want the flexibility to deal with the type differently in this case.
Definition at line 42 of file unique_ptr.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::no_deletion = noop_dtor<typename value_type::deleter_t::element_type> |
If you get a compilation issue here, check you aren't using std::default_delete, but libjmmcg::default_delete instead.
Definition at line 55 of file unique_ptr.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::value_type = V |
A convenience typedef to the type to be controlled.
Definition at line 40 of file unique_ptr.hpp.
|
inlineconstexprnoexcept |
Definition at line 67 of file unique_ptr.hpp.
|
inlineexplicitconstexprnoexcept |
ptr | Note that this ptr could have a non-zero reference count, and this ctor will take ownership of the ptr, respecting that reference count, only deleting the ptr if it reaches zero. |
Definition at line 56 of file unique_ptr_impl.hpp.
|
explicitnoexcept |
ptr | Note that this ptr could have a non-zero reference count, and this ctor will take ownership of the ptr, respecting that reference count, only deleting the ptr if it reaches zero. The type of the parameter must be the same type or a class non-privately derived from value_type. |
|
inlineexplicitnoexcept |
ptr | Note that this ptr could have a non-zero reference count, and this ctor will take ownership of the ptr, respecting that reference count, only deleting the ptr if it reaches zero. |
Definition at line 69 of file unique_ptr_impl.hpp.
|
noexcept |
ptr | Note that this ptr could have a non-zero reference count, and this ctor will take ownership of the ptr, respecting that reference count, only deleting the ptr if it reaches zero. |
|
inlineexplicitconstexprnoexcept |
ptr | Note that this ptr could have a non-zero reference count, and this ctor will take ownership of the ptr, respecting that reference count, only deleting the ptr if it reaches zero. |
Definition at line 89 of file unique_ptr_impl.hpp.
|
explicitnoexcept |
ptr | Note that this ptr could have a non-zero reference count, and this ctor will take ownership of the ptr, respecting that reference count, only deleting the ptr if it reaches zero. The type of the parameter must be the same type or a class non-privately derived from value_type. |
|
explicitnoexcept |
Note that the same deleter and threading model must be specified.
s | The type of the parameter must be the same type or a class non-privately derived from value_type. |
|
inlineconstexprnoexcept |
Definition at line 105 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 117 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 63 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 78 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 96 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 111 of file unique_ptr_impl.hpp.
|
inlineconstexprnoexcept |
Definition at line 161 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 165 of file unique_ptr_impl.hpp.
|
inlineexplicitconstexprnoexcept |
Definition at line 152 of file unique_ptr_impl.hpp.
|
inlineconstexprnoexcept |
Definition at line 148 of file unique_ptr_impl.hpp.
|
inlineconstexprnoexcept |
Definition at line 169 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 174 of file unique_ptr_impl.hpp.
|
inlineconstexprnoexcept |
Definition at line 179 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 183 of file unique_ptr_impl.hpp.
|
inlineconstexprnoexcept |
Definition at line 139 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 134 of file unique_ptr_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::reset().
|
inlinenoexcept |
Note that the same deleter and threading model must be specified.
s | The type of the parameter must be the same type or a class non-privately derived from value_type. |
Definition at line 127 of file unique_ptr_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::reset().
|
inlineconstexprnoexcept |
Definition at line 144 of file unique_ptr_impl.hpp.
|
inlineconstexprnoexcept |
Definition at line 156 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Release the contained object from control.
Definition at line 24 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 31 of file unique_ptr_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::unique_ptr.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::operator=().
|
inlinenoexcept |
Definition at line 37 of file unique_ptr_impl.hpp.
|
noexcept |
|
inlinenoexcept |
Definition at line 43 of file unique_ptr_impl.hpp.
|
noexcept |
|
inlinenoexcept |
Definition at line 50 of file unique_ptr_impl.hpp.
|
inlinenoexcept |
Definition at line 188 of file unique_ptr_impl.hpp.
|
friend |
Definition at line 164 of file unique_ptr.hpp.
Definition at line 170 of file unique_ptr.hpp.
Referenced by BOOST_AUTO_TEST_CASE_TEMPLATE(), and jmmcg::LIBJMMCG_VER_NAMESPACE::unique_ptr< V, LkT >::reset().
|
staticconstexpr |
To assist in allowing compile-time computation of the algorithmic order of the threading model.
Definition at line 59 of file unique_ptr.hpp.