36 template<
typename T,
typename U>
39 template<
typename T,
typename U>
42 template<
typename T,
typename U>
45 template<
typename T,
typename U>
48 template<
typename T,
typename U>
51 template<
typename T,
typename U>
54 template<
typename T,
typename U>
57 template<
typename T,
typename U>
100 template<
typename U,
typename V>
103 template<
typename U,
typename V>
106 template<
typename U,
typename V>
109 template<
typename U,
typename V>
112 template<
typename U,
typename V>
115 template<
typename U,
typename V>
126 auto lock = std::unique_lock<std::mutex>(
ctl.
mutex);
131 bool deleteobj =
false;
132 bool deletectl =
false;
135 auto lock = std::unique_lock<std::mutex>(
ctl.
mutex);
164 if (
ctl !=
nullptr) {
170 if (
ctl !=
nullptr) {
193 auto lock = std::unique_lock<std::mutex>(other.
mutex);
195 if (other.
ctl !=
nullptr) {
196 this->ctl = other.
ctl;
197 this->ptr = other.
ptr;
204 auto lock = std::unique_lock<std::mutex>(other.
mutex);
206 if (other.
ctl !=
nullptr) {
207 this->ctl = other.
ctl;
208 this->ptr = other.
ptr;
214 auto lock = std::unique_lock<std::mutex>(other.mutex);
216 if (other.ctl !=
nullptr) {
217 this->ctl = std::exchange(other.ctl,
nullptr);
218 this->ptr = std::exchange(other.ptr,
nullptr);
223 auto lock = std::unique_lock<std::mutex>(
mutex);
225 if (
ctl !=
nullptr) {
233 if (&other ==
this) {
237 using l = std::unique_lock<std::mutex>;
238 using p = std::pair<l, l>;
245 if (
ctl !=
nullptr) {
254 if (
ctl !=
nullptr) {
262 if (&other ==
this) {
266 using l = std::unique_lock<std::mutex>;
267 using p = std::pair<l, l>;
268 p lockpair = (&
mutex < &other.mutex) ? p({l(
mutex), l(other.mutex)}) : p({l(other.mutex), l(
mutex)});
270 if (other.ctl ==
ctl) {
271 if (
ctl !=
nullptr) {
280 if (
ctl !=
nullptr) {
286 ctl = std::exchange(other.ctl,
nullptr);
287 ptr = std::exchange(other.ptr,
nullptr);
293 auto lock = std::unique_lock<std::mutex>(
mutex);
295 if (
ctl !=
nullptr) {
307 auto lock = std::unique_lock<std::mutex>(
mutex);
309 if (
ctl ==
nullptr) {
313 if (
ptr ==
nullptr) {
321 using l = std::unique_lock<std::mutex>;
322 using p = std::pair<l, l>;
325 if ((
ctl ==
nullptr) and other.
ctl ==
nullptr) {
329 return (
ptr == other.
ptr);
335 using l = std::unique_lock<std::mutex>;
336 using p = std::pair<l, l>;
343 if (
ctl !=
nullptr) {
349 if (other.
ctl !=
nullptr) {
350 if (
auto recast = dynamic_cast<T*>(other.
ptr)) {
367 if (&other ==
this) {
371 using l = std::unique_lock<std::mutex>;
372 using p = std::pair<l, l>;
379 this->ctl = std::exchange(other.
ctl,
ctl);
380 this->ptr = std::exchange(other.
ptr,
ptr);
392 auto lock = std::unique_lock<std::mutex>(
mutex);
394 if (
ctl !=
nullptr) {
405 auto lock = std::unique_lock<std::mutex>(
mutex);
407 if (
ctl !=
nullptr) {
418 auto lock = std::unique_lock<std::mutex>(
mutex);
420 if (
ctl !=
nullptr) {
429 explicit operator bool()
const {
430 auto lock = std::unique_lock<std::mutex>(
mutex);
435 auto lock = std::unique_lock<std::mutex>(
mutex);
437 if (
ctl !=
nullptr) {
464 template<
typename U,
typename V>
467 template<
typename U,
typename V>
495 if (
ctl !=
nullptr) {
505 auto lock = std::unique_lock<std::mutex>(sharedPtr.
mutex);
510 if (
ctl !=
nullptr) {
516 auto lock = std::unique_lock<std::mutex>(other.
mutex);
521 if (
ctl !=
nullptr) {
527 auto lock = std::unique_lock<std::mutex>(other.mutex);
529 ctl = std::exchange(other.ctl,
nullptr);
530 ptr = std::exchange(other.ptr,
nullptr);
534 if (&other ==
this) {
538 using l = std::unique_lock<std::mutex>;
539 using p = std::pair<l, l>;
546 if (
ctl !=
nullptr) {
552 if (other.
ctl !=
nullptr) {
553 this->ctl = other.
ctl;
554 this->ptr = other.
ptr;
562 if (&other ==
this) {
566 using l = std::unique_lock<std::mutex>;
567 using p = std::pair<l, l>;
568 p lockpair = (&
mutex < &other.mutex) ? p({l(
mutex), l(other.mutex)}) : p({l(other.mutex), l(
mutex)});
570 if (other.ctl ==
ctl) {
571 if (
ctl !=
nullptr) {
580 if (
ctl !=
nullptr) {
586 if (other.ctl !=
nullptr) {
587 this->ctl = std::exchange(other.ctl,
nullptr);
588 this->ptr = std::exchange(other.ptr,
nullptr);
595 auto lock = std::unique_lock<std::mutex>(
mutex);
597 if (
ctl !=
nullptr) {
605 auto lock = std::unique_lock<std::mutex>(
mutex);
607 if (
ctl !=
nullptr) {
609 auto lock = std::unique_lock<std::mutex>(c.mutex);
617 auto lock = std::unique_lock<std::mutex>(
mutex);
619 if (
ctl !=
nullptr) {
621 auto lock = std::unique_lock<std::mutex>(c.mutex);
630 auto lock = std::unique_lock<std::mutex>(
mutex);
632 if (
ctl !=
nullptr) {
634 auto lock = std::unique_lock<std::mutex>(c.mutex);
636 if (
auto recast = dynamic_cast<U*>(
ptr)) {
646 auto lock = std::unique_lock<std::mutex>(
mutex);
648 if (
ctl !=
nullptr) {
650 auto lock = std::unique_lock<std::mutex>(c.mutex);
654 if (
auto recast = dynamic_cast<U*>(cptr)) {
663 auto lock = std::unique_lock<std::mutex>(
mutex);
665 if (
ctl !=
nullptr) {
667 auto lock = std::unique_lock<std::mutex>(c.mutex);
675 template<
typename T,
typename U>
678 auto lock = std::unique_lock<std::mutex>(other.
mutex);
680 if (other.
ctl !=
nullptr) {
681 auto recast =
dynamic_cast<T*
>(other.
ptr);
683 if (recast !=
nullptr) {
692 template<
typename T,
typename U>
695 auto lock = std::unique_lock<std::mutex>(other.mutex);
697 if (other.ctl !=
nullptr) {
698 auto recast =
dynamic_cast<T*
>(other.ptr);
700 if (recast !=
nullptr) {
702 result.
ctl = std::exchange(other.ctl,
nullptr);
713 template<
typename T,
typename U>
716 auto lock = std::unique_lock<std::mutex>(other.
mutex);
718 if (other.
ctl !=
nullptr) {
719 auto recast =
dynamic_cast<T*
>(other.
ptr);
721 if (recast !=
nullptr) {
730 template<
typename T,
typename U>
733 auto lock = std::unique_lock<std::mutex>(other.
mutex);
735 if (other.
ctl !=
nullptr) {
736 auto recast =
static_cast<T*
>(other.
ptr);
744 template<
typename T,
typename U>
747 auto lock = std::unique_lock<std::mutex>(other.
mutex);
749 if (other.
ctl !=
nullptr) {
750 auto recast =
static_cast<T*
>(other.
ptr);
758 template<
typename T,
typename U>
761 auto lock = std::unique_lock<std::mutex>(other.mutex);
763 if (other.ctl !=
nullptr) {
764 auto recast =
static_cast<T*
>(other.ptr);
766 result.
ctl = std::exchange(other.ctl,
nullptr);
776 template<
typename T,
typename U>
779 auto lock = std::unique_lock<std::mutex>(other.
mutex);
781 if (other.
ctl !=
nullptr) {
782 auto recast =
const_cast<T*
>(other.
ptr);
804 template<
typename T,
typename U>
807 auto lock = std::unique_lock<std::mutex>(other.mutex);
809 if (other.ctl !=
nullptr) {
810 auto recast =
const_cast<T*
>(other.ptr);
812 result.
ctl = std::exchange(other.ctl,
nullptr);
ptr< const ebmlMasterElement > c_ebmlMasterElement_sp
Definition: ptrs.h:855
bool valid
Definition: ptrs.h:23
friend ebml_shared_ptr< U > ebml_static_pointer_cast(const ebml_shared_ptr< V > &)
ebml_shared_ptr(const ebml_shared_ptr< U > &other)
Definition: ptrs.h:203
ebml_shared_ptr< U > lock() const
Definition: ptrs.h:629
ebml_shared_ptr< T > ebml_dynamic_pointer_cast(const ebml_shared_ptr< U > &)
Definition: ptrs.h:676
ebml_shared_ptr< const T > c_lock() const
Definition: ptrs.h:616
T * operator->() const
Definition: ptrs.h:417
friend ebml_weak_ptr< U > ebml_dynamic_pointer_cast(const ebml_weak_ptr< V > &)
bool expired() const
Definition: ptrs.h:662
wptr< const ebmlMasterElement > c_ebmlMasterElement_wp
Definition: ptrs.h:904
wptr< ebmlMasterElement > ebmlMasterElement_wp
Definition: ptrs.h:898
ebml_shared_ptr(control_block *ctl, T *ptr)
Definition: ptrs.h:163
ptr< ebmlElement > ebmlElement_sp
Definition: ptrs.h:837
friend ebml_shared_ptr< U > ebml_const_pointer_cast(const ebml_shared_ptr< V > &)
ebml_weak_ptr(const ebml_shared_ptr< T > &sharedPtr)
Definition: ptrs.h:504
std::weak_ptr< ebmlDocument > ebmlDocument_wp
Definition: ptrs.h:915
T * ptr
Definition: ptrs.h:121
bool operator==(const std::nullptr_t &) const
Definition: ptrs.h:306
ebml_shared_ptr< T > & operator=(ebml_shared_ptr< T > &&other)
Definition: ptrs.h:261
friend ebml_shared_ptr< U > ebml_dynamic_pointer_cast(const ebml_shared_ptr< V > &)
ebml_shared_ptr(const std::nullptr_t &)
Definition: ptrs.h:177
ebml_shared_ptr(control_block *ctl, T *ptr, const std::unique_lock< std::mutex > &)
Definition: ptrs.h:169
ptr< ebmlMasterElement > ebmlMasterElement_sp
Definition: ptrs.h:849
T & operator*() const
Definition: ptrs.h:402
A drop-in replacement for std::weak_ptr tailored for EBML objects.
Definition: ptrs.h:30
Definition: basictypes.h:40
A drop-in replacement for std::shared_ptr tailored for EBML objects.
Definition: ptrs.h:27
ebml_weak_ptr(const std::nullptr_t &)
Definition: ptrs.h:502
ebml_shared_ptr< T > lock() const
Definition: ptrs.h:604
wptr< const ebmlElement > c_ebmlElement_wp
Definition: ptrs.h:892
control_block * ctl
Definition: ptrs.h:472
long long weakcount
Definition: ptrs.h:22
ebml_shared_ptr()
Definition: ptrs.h:176
ebml_shared_ptr< T > & operator=(const ebml_shared_ptr< T > &other)
Definition: ptrs.h:232
T * ptr
Definition: ptrs.h:473
ebml_shared_ptr(T *ptr)
Constructs an ebml_shared_ptr that takes ownership of ptr.
Definition: ptrs.h:188
void swap(ebml_shared_ptr< T > &other)
Definition: ptrs.h:366
std::mutex mutex
Definition: ptrs.h:119
ebml_shared_ptr< T > & operator=(const std::nullptr_t &)
Definition: ptrs.h:292
int use_count() const
Definition: ptrs.h:434
std::shared_ptr< ebmlDocument > ebmlDocument_sp
Definition: ptrs.h:909
ebml_weak_ptr(ebml_weak_ptr< T > &&other)
Definition: ptrs.h:526
ptr< const ebmlElement > c_ebmlElement_sp
Definition: ptrs.h:843
ebml_weak_ptr< T > & operator=(ebml_weak_ptr< T > &&other)
Definition: ptrs.h:561
ebml_weak_ptr(const ebml_weak_ptr< T > &other)
Definition: ptrs.h:515
ptr< ebmlLazyLoad > ebmlLazyLoad_sp
Definition: ptrs.h:874
~ebml_shared_ptr()
Definition: ptrs.h:222
ptr< ioBase > ioBase_sp
Definition: ptrs.h:921
ebml_shared_ptr< T > ebml_static_pointer_cast(const ebml_shared_ptr< U > &)
Definition: ptrs.h:731
std::mutex mutex
Definition: ptrs.h:471
ebml_weak_ptr< T > & operator=(const ebml_weak_ptr< T > &other)
Definition: ptrs.h:533
~ebml_weak_ptr()
Definition: ptrs.h:594
std::mutex mutex
Definition: ptrs.h:20
control_block * ctl
Definition: ptrs.h:120
ebml_shared_ptr(ebml_shared_ptr< T > &&other)
Definition: ptrs.h:213
ebml_weak_ptr()
Definition: ptrs.h:501
ptr< const ebmlList > c_ebmlList_sp
Definition: ptrs.h:868
friend ebml_weak_ptr< U > ebml_static_pointer_cast(const ebml_weak_ptr< V > &)
ptr< const ebmlLazyLoad > c_ebmlLazyLoad_sp
Definition: ptrs.h:880
std::enable_if_t<!std::is_same< T, U >::value, ebml_shared_ptr< T > & > operator=(const ebml_shared_ptr< U > &other)
Definition: ptrs.h:334
wptr< ebmlElement > ebmlElement_wp
Definition: ptrs.h:886
std::enable_if_t<!std::is_same< T, U >::value, ebml_shared_ptr< U > > c_lock() const
Definition: ptrs.h:645
long long strongcount
Definition: ptrs.h:21
ebml_shared_ptr< T > ebml_const_pointer_cast(const ebml_shared_ptr< U > &)
Definition: ptrs.h:777
ptr< ebmlList > ebmlList_sp
Definition: ptrs.h:862
bool operator==(const ebml_shared_ptr< T > &other) const
Definition: ptrs.h:320
ebml_weak_ptr(control_block *ctl, T *ptr)
Definition: ptrs.h:494
ebml_shared_ptr(const ebml_shared_ptr< T > &other)
Definition: ptrs.h:192