4 #ifndef DUNE_TO_UNIQUE_PTR_HH
5 #define DUNE_TO_UNIQUE_PTR_HH
36 :
public std::unique_ptr<T>
38 using Super = std::unique_ptr<T>;
71 DUNE_DEPRECATED_MSG(
"Cast to raw pointer is deprecated. Use std::unique_ptr or std::shared_ptr instead.")
72 operator
pointer() noexcept {
return Super::release(); }
75 operator std::unique_ptr<T>() noexcept {
return std::move(
static_cast<Super&
>(*
this)); }
78 operator std::shared_ptr<T>() noexcept {
return std::move(
static_cast<Super&
>(*
this)); }
81 explicit operator bool() noexcept {
return bool(
static_cast<Super&
>(*
this)); }
84 explicit operator bool() const noexcept {
return bool(
static_cast<Super const&
>(*
this)); }
91 template <
class T,
class... Args>
94 return {
new T(std::forward<Args>(args)...)};
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
Dune namespace.
Definition: alignedallocator.hh:14
An owning pointer wrapper that can be assigned to (smart) pointers. Cannot be copied....
Definition: to_unique_ptr.hh:37
ToUniquePtr< T > makeToUnique(Args &&... args)
Constructs an object of type T and wraps it in a ToUniquePtr,.
Definition: to_unique_ptr.hh:92
typename Super::pointer pointer
Definition: to_unique_ptr.hh:44
ToUniquePtr(pointer ptr=pointer()) noexcept
Constructor, stores the pointer.
Definition: to_unique_ptr.hh:54
ToUniquePtr(std::nullptr_t) noexcept
Constructor, creates a nullptr
Definition: to_unique_ptr.hh:59