17#ifndef BIFROSTGRAPH_EXECUTOR_OWNER_H
18#define BIFROSTGRAPH_EXECUTOR_OWNER_H
20#include <BifrostGraph/Executor/internal/OwnerRep.h>
21#include <BifrostGraph/Executor/internal/PointeeTraits.h>
38class Owner :
private Internal::OwnerRep<T> {
45 using if_convertible_from =
46 typename std::enable_if<std::is_convertible<P*, T*>::value>::type;
53 using if_compliant_and_convertible_from =
54 typename std::enable_if<std::is_convertible<P*, T*>::value &&
55 Internal::PointeeTraits::is_compliant<P>::value>::type;
58 using OwnerRep = Internal::OwnerRep<T>;
62 static_assert(Internal::PointeeTraits::is_compliant<T>::value,
63 "Owner class template requires an object type T, "
64 "and T cannot be a pointer or a reference or an array (e.g. int[]), "
65 "and T must not include `const` nor `volatile` qualifiers.");
68 Owner() noexcept : OwnerRep() {}
86 template <
typename P,
typename = if_compliant_and_convertible_from<P>>
88 OwnerRep::template init<P>(p);
119 template <
typename P,
typename = if_compliant_and_convertible_from<P>>
121 OwnerRep::template init<P>(p, d);
142 template <typename P, typename = if_convertible_from<P>>
155 explicit constexpr operator bool() const noexcept {
return OwnerRep::operator bool(); }
160 const T&
operator*() const noexcept {
return OwnerRep::operator*(); }
165 T&
operator*() noexcept {
return OwnerRep::operator*(); }
170 const T*
operator->() const noexcept {
return OwnerRep::operator->(); }
179 const T*
get() const noexcept {
return OwnerRep::get(); }
183 T*
get() noexcept {
return OwnerRep::get(); }
void swap(Any &lhs, Any &rhs) noexcept
Swap the payloads of two instances of Any.
The Owner<T> class template represents ownership of an object pointer. It indicates that the pointed ...
Owner & operator=(Owner &&rhs) noexcept=default
Move assignment operator Move assign the Owner rhs to *this.
Owner(P *p, DeleterFunc< P > d) noexcept
Construct an Owner that owns the object pointed by p, with a custom pointer deleter set to d....
T & operator*() noexcept
Indirection operator.
friend class Owner
Friendship to allow conversion between Owners of different types.
Owner & reset() noexcept
Reset this Owner object to its uninitialized state, deleting the currently owned object (if any).
T * operator->() noexcept
Indirection operator.
Owner() noexcept
Construct an empty Owner.
void swap(Owner &other) noexcept
Swap the content of this Owner with another one.
Owner(P *p) noexcept
Construct an Owner that owns the object pointed by p. The owned object will be destructed using the e...
void(*)(P *p) DeleterFunc
The signature for the custom pointer deleter of a pointee p. This is the custom deleter type to use w...
const T & operator*() const noexcept
Indirection operator.
T * get() noexcept
Accessor.
~Owner() noexcept=default
Destruct this Owner. If no custom deleter was provided, the owned object is disposed using a delete p...
const T * operator->() const noexcept
Indirection operator.
const T * get() const noexcept
Accessor.