diff --git a/ctl/shared_ptr.h b/ctl/shared_ptr.h index 619e7b283..1744a26a7 100644 --- a/ctl/shared_ptr.h +++ b/ctl/shared_ptr.h @@ -3,14 +3,14 @@ #ifndef CTL_SHARED_PTR_H_ #define CTL_SHARED_PTR_H_ -#include "conditional.h" #include "exception.h" #include "is_convertible.h" -#include "is_void.h" -#include "new.h" #include "remove_extent.h" #include "unique_ptr.h" +// XXX currently needed to use placement-new syntax (move to cxx.inc?) +void* operator new(size_t, void*) noexcept; + namespace ctl { class bad_weak_ptr : public exception @@ -24,6 +24,18 @@ class bad_weak_ptr : public exception namespace __ { +template +struct ptr_ref +{ + using type = T&; +}; + +template <> +struct ptr_ref +{ + using type = void; +}; + static inline __attribute__((always_inline)) void incref(size_t* r) noexcept { @@ -302,8 +314,7 @@ class shared_ptr return p; } - conditional_t, void, add_lvalue_reference_t> operator*() - const noexcept + typename __::ptr_ref::type operator*() const noexcept { if (!p) __builtin_trap();