7#ifndef BOOST_LOCALE_HOLD_PTR_H
8#define BOOST_LOCALE_HOLD_PTR_H
10#include <boost/locale/config.hpp>
11#include <boost/core/exchange.hpp>
13namespace boost {
namespace locale {
40 T
const*
get()
const {
return ptr_; }
42 T*
get() {
return ptr_; }
45 explicit operator bool()
const {
return ptr_ !=
nullptr; }
58 T*
release() {
return exchange(ptr_,
nullptr); }
69 void swap(
hold_ptr& other)
noexcept { ptr_ = exchange(other.ptr_, ptr_); }
a smart pointer similar to std::unique_ptr but the underlying object has the same constness as the po...
Definition: hold_ptr.hpp:17
hold_ptr(T *v)
Create a pointer that holds v, ownership is transferred to smart pointer.
Definition: hold_ptr.hpp:23
T const & operator*() const
Get a const reference to the object.
Definition: hold_ptr.hpp:48
void swap(hold_ptr &other) noexcept
Swap two pointers.
Definition: hold_ptr.hpp:69
T * operator->()
Get a mutable pointer to the object.
Definition: hold_ptr.hpp:55
T const * operator->() const
Get a const pointer to the object.
Definition: hold_ptr.hpp:53
hold_ptr()
Create new empty pointer.
Definition: hold_ptr.hpp:20
void reset(T *p=nullptr)
Set new value to pointer, previous object is destroyed, ownership of new object is transferred.
Definition: hold_ptr.hpp:61
T * release()
Transfer ownership of the pointer to user.
Definition: hold_ptr.hpp:58
T * get()
Get a mutable pointer to the object.
Definition: hold_ptr.hpp:42
~hold_ptr()
Destroy smart pointer and the object it owns.
Definition: hold_ptr.hpp:26
T & operator*()
Get a mutable reference to the object.
Definition: hold_ptr.hpp:50
T const * get() const
Get a const pointer to the object.
Definition: hold_ptr.hpp:40