Template Class shared¶
Defined in File shared.hpp
Class Documentation¶
-
template<class T>
class util::shared¶ Public Functions
-
constexpr shared() = default¶
-
constexpr shared(std::nullptr_t) noexcept¶
Constructs a shared object from a nullpointer.
-
shared(shared &&other) noexcept¶
Constructs a shared instance from another moved shared instance. The moved instance’s pointer and reference counter are unassigned.
- Parameters
other – another shared instance
-
shared(const shared &other)¶
Constructs a shared instance from another shared instance.
- Parameters
other – another shared instance
-
~shared()¶
Destroys a shared object instance and decreases the reference counter. If the reference counter reaches zero (i.e. this is the last reference to the managed instance) then the managed instance will be deleted.
-
auto operator=(shared &&other) noexcept -> shared&¶
Assigns a moved shared instance. The moved instance’s pointer and reference counter are unassigned.
- Returns
a reference to this instance
-
auto operator=(const shared &other) -> shared&¶
Assigns a shared instance.
- Returns
a reference to this instance
-
auto operator->() const noexcept -> T*¶
Returns the stored pointer.
- Returns
the stored pointer, i.e.,
get()
-
auto operator*() const noexcept -> T&¶
Returns the dereferenced managed object.
- Returns
the dereferenced stored pointer, i.e.,
*get()
-
explicit operator bool() const noexcept¶
Checks if the stored pointer is not null.
- Returns
true if the stored pointer is null or false if not
-
auto use_count() const noexcept -> std::size_t¶
Returns the number of different shared_ptr instances (this included) managing the current object. If there is no managed object, 0 is returned.
- Returns
the number of util::shared instances managing the current object or 0 if there is no managed object
-
constexpr shared() = default¶