49 #ifndef Foam_autoPtr_H 50 #define Foam_autoPtr_H 53 #define Foam_autoPtr_copyConstruct 54 #define Foam_autoPtr_castOperator 130 #ifdef Foam_autoPtr_copyConstruct 155 template<
class... Args>
167 template<
class U,
class... Args>
190 const T*
get()
const noexcept {
return ptr_; }
195 T&
ref() {
return *ptr_; }
221 template<class... Args>
233 template<class... Args>
241 inline
T& operator*();
245 inline const
T& operator*() const;
249 inline
T* operator->();
253 inline const
T* operator->() const;
257 inline
T& operator()();
261 inline const
T& operator()() const;
267 explicit operator
bool() const
noexcept {
return bool(ptr_); }
272 operator const T*()
const noexcept {
return ptr_; }
279 #ifdef Foam_autoPtr_castOperator 280 operator const T&()
const {
return operator*(); }
282 operator const T&()
const =
delete;
293 void operator=(
const autoPtr<T>&) =
delete;
303 reset(other.release());
307 void operator=(std::unique_ptr<T>&& other) {
reset(other.release()); }
329 #ifndef Foam_autoPtr_nodeprecate_setMethod T element_type
Type of object being managed.
void swap(autoPtr< T > &other) noexcept
Swaps the managed object with other autoPtr.
T & operator*()
Return reference to the managed object.
bool empty() const noexcept
Deprecated(2020-07) True if the managed pointer is null.
static autoPtr< T > NewFrom(Args &&... args)
Construct autoPtr from derived type with forwarding arguments.
void clear() noexcept
Same as reset(nullptr)
autoPtr(std::unique_ptr< T > &&rhs) noexcept
Move construct from unique_ptr, transferring ownership.
T * pointer
Pointer to type of object being managed.
T & emplace(Args &&... args)
Reset with emplace construction. Return reference to the new content.
~autoPtr() noexcept
Destructor: deletes managed pointer.
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
constexpr autoPtr() noexcept
Construct with no managed pointer.
bool good() const noexcept
True if the managed pointer is non-null.
T * release() noexcept
Release ownership and return the pointer.
bool valid() const noexcept
Identical to good(), or bool operator.
autoPtr(autoPtr< T > &&rhs) noexcept
Move construct, transferring ownership.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
T & ref()
Return reference to the managed object without nullptr checking.
T * ptr() noexcept
Same as release().
autoPtr< T > clone(Args &&... args) const
Copy construct by invoking clone on underlying managed object.
Includes some standard C++ headers, defines global macros and templates used in multiple places by Op...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
void operator=(T *p)=delete
No copy assignment from plain pointer (uncontrolled access)
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Foam::argList args(argc, argv)