|
DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
|
A utility class that simplifies declaring function attributes that need to be stored without requiring the user to create a shared pointer. More...
#include <ref_or_owned.h>
Public Member Functions | |
| ref_or_owned (ref_or_owned< T > &&other) noexcept | |
| ref_or_owned (const ref_or_owned< T > &other) | |
| template<ref_or_owned_compatible< T > U> | |
| ref_or_owned (U &value) | |
| Constructs a ref_or_owned object from a reference to an object. More... | |
| template<ref_or_owned_compatible< T > U> | |
| ref_or_owned (U &&value) | |
| Constructs a ref_or_owned object from a temporary object. More... | |
| template<ref_or_owned_compatible< T > U> | |
| ref_or_owned (std::shared_ptr< U > ptr) | |
| const T & | get () const |
| Returns a const reference to the stored object, regardless of whether it is stored as a reference or a shared pointer. More... | |
| T & | get () |
| Returns a non-const reference to the stored object, regardless of whether it is stored as a reference or a shared pointer. More... | |
| std::shared_ptr< T > | to_shared_ptr () const |
A utility class that simplifies declaring function attributes that need to be stored without requiring the user to create a shared pointer.
The ref_or_owned class is designed to make it easy to declare function parameters that need to store a value, without requiring the user to manually manage the memory. It acts as a "sink" that can accept either a reference or a temporary object, and will automatically manage the memory for the user.
| T | The type of the object being stored. |
Definition at line 33 of file ref_or_owned.h.
|
inline |
Constructs a ref_or_owned object from a reference to an object.
The object is stored as a reference, and the ref_or_owned object will not manage its memory.
| value | The object to be stored. |
Definition at line 55 of file ref_or_owned.h.
|
inline |
Constructs a ref_or_owned object from a temporary object.
The object is stored as a shared pointer, and the ref_or_owned object will manage its memory.
| value | The object to be stored. |
Definition at line 67 of file ref_or_owned.h.
|
inline |
Returns a non-const reference to the stored object, regardless of whether it is stored as a reference or a shared pointer.
Definition at line 90 of file ref_or_owned.h.
|
inline |
Returns a const reference to the stored object, regardless of whether it is stored as a reference or a shared pointer.
Definition at line 81 of file ref_or_owned.h.