carb::extras::ConstHandleRef
Defined in carb/extras/HandleDatabase.h
- 
template<class Mapped, class Handle, class Allocator = std::allocator<Mapped>>
 struct ConstHandleRef
- A smart-reference class for a Handle associated with a HandleDatabase. - When HandleRef is destroyed, the associated handle is released with the HandleDatabase. - Subclassed by carb::extras::HandleRef< Mapped, Handle, Allocator > - Public Types - 
using Database = HandleDatabase<Mapped, Handle, Allocator>
- The type specification for the associated HandleDatabase. 
 - 
using element_type = MappedType
- Deprecated: Use MappedType instead. 
 - 
using handle_type = HandleType
- Deprecated: Use HandleType instead. 
 - Public Functions - 
ConstHandleRef() = default
- Default constructor. - Produces an empty HandleRef. 
 - 
inline ConstHandleRef(Database &database, Handle handle) noexcept
- Attempts to atomically reference a Handle from the given - database.- Parameters
- database – The HandleDatabase containing - handle.
- handle – The handle previously returned from HandleDatabase::createHandle(). Providing an invalid or previously-valid handle results in an empty HandleRef. 
 
 
 - 
inline ~ConstHandleRef() noexcept
- Destructor. - If - *thisis non-empty, releases the associated Handle with the associated HandleDatabase.
 - 
inline ConstHandleRef(ConstHandleRef &&other) noexcept
- Move-constructor. - Post-condition: - otheris an empty HandleRef.- Parameters
- other – The other HandleRef to move a reference from. 
 
 - 
inline ConstHandleRef &operator=(ConstHandleRef &&other) noexcept
- Move-assign operator. - Swaps state with - other.- Parameters
- other – The other HandleRef to move a reference from. 
 
 - 
inline ConstHandleRef clone() const noexcept
- Explicitly adds a reference to any referenced handle and returns a HandleRef. - Returns
- A HandleRef holding its own reference for the contained handle. May be empty if - *thisis empty.
 
 - 
inline PointerType operator->() noexcept
- Dereferences and returns a pointer to the mapped type. - Warning - Undefined behavior if - *thisis empty.- Returns
- A pointer to the mapped type. 
 
 - 
inline PointerType operator->() const noexcept
- Dereferences and returns a const pointer to the mapped type. - Warning - Undefined behavior if - *thisis empty.- Returns
- A const pointer to the mapped type. 
 
 - 
inline ReferenceType operator*() noexcept
- Dereferences and returns a reference to the mapped type. - Warning - Undefined behavior if - *thisis empty.- Returns
- A reference to the mapped type. 
 
 - 
inline ReferenceType operator*() const noexcept
- Dereferences and returns a const reference to the mapped type. - Warning - Undefined behavior if - *thisis empty.- Returns
- A const reference to the mapped type. 
 
 - 
inline PointerType get() noexcept
- Returns a pointer to the mapped type, or - nullptrif empty.- Returns
- A pointer to the mapped type or - nullptrif empty.
 
 - 
inline PointerType get() const noexcept
- Returns a const pointer to the mapped type, or - nullptrif empty.- Returns
- A const pointer to the mapped type or - nullptrif empty.
 
 - 
inline Handle handle() const noexcept
- Returns the Handle referenced by - *this.- Returns
- The Handle referenced by - *this.
 
 - 
inline explicit operator bool() const noexcept
- Tests if - *thiscontains a valid reference.- Returns
- trueif- *thismaintains a valid reference;- falseif- *thisis empty.
 
 - 
inline void reset()
- Releases any associated reference and resets - *thisto empty.
 - 
inline void swap(ConstHandleRef &rhs)
- Swaps state with another HandleRef. 
 - Protected Functions 
- 
using Database = HandleDatabase<Mapped, Handle, Allocator>