GEOSX
|
#include <ReferenceWrapper.hpp>
Public Member Functions | |
ReferenceWrapper () | |
Default constructor sets m_ref to nullptr. | |
ReferenceWrapper (T &source) noexcept | |
Constructor that sets m_ref to address of input. More... | |
~ReferenceWrapper ()=default | |
Default destructor. | |
ReferenceWrapper (ReferenceWrapper const &source) | |
Copy constructor copies the source m_ref to the new m_ref. More... | |
ReferenceWrapper (ReferenceWrapper &&source) | |
Move constructor copies the source m_ref to the new m_ref. More... | |
ReferenceWrapper & | operator= (ReferenceWrapper const &source) |
Copy assignment operator. More... | |
template<typename T_RHS , typename U = T> | |
std::enable_if< !std::is_const< U >::value, ReferenceWrapper &>::type | operator= (T_RHS const &rhs) |
Assignment operator. More... | |
ReferenceWrapper & | operator= (T &&source) |
Move assignment operator. More... | |
operator T& () | |
User defined conversion to T & . | |
operator T const & () const | |
User defined conversion to T const & | |
void | set (T &source) |
Set the address that m_ref points to. More... | |
void | set (T *source) |
Set the address that m_ref points to. More... | |
T & | get () |
Accessor for m_ref. More... | |
T const & | get () const |
Const accessor for m_ref. More... | |
bool | isValid () const |
Check if reference is initialized. More... | |
T const * | getPtr () const |
Const accessor for m_ref. More... | |
template<typename ... ARGS> | |
std::result_of< T &(ARGS &&...) >::type | operator() (ARGS &&... args) |
A pass thru parenthesis operator which calls underlying T::operator() . More... | |
template<typename ... ARGS> | |
std::result_of< T const &(ARGS &&...) >::type | operator() (ARGS &&... args) const |
A pass thru parenthesis operator which calls underlying T::operator() . More... | |
Type | that is wrapped |
This class manages a pointer to the templated type, but provides a reference-like interface, thus negating the requirement to dereference the object. The primary use for this is for nested arrays that hold pointers at the last level, but allows for reference-like usage. For instance, consider a collection of object that you would like to refer to thought an array of pointers.
array1d< ReferenceWrapper< array1d< double > > > arr;
where the array::operator[]
exists. The ReferenceWrapper allows
arr[index1][index2]
note: this is really only useful for heavy array that hold their own data. For light arrays that hold pointers to their data, then this is unnecessary as a copy of the array does not trigger a deep copy.
Definition at line 48 of file ReferenceWrapper.hpp.
|
inlinenoexcept |
Constructor that sets m_ref to address of input.
[in] | source | object to wrap |
Definition at line 64 of file ReferenceWrapper.hpp.
|
inline |
Copy constructor copies the source m_ref to the new m_ref.
[in] | source | object to copy |
Definition at line 78 of file ReferenceWrapper.hpp.
|
inline |
Move constructor copies the source m_ref to the new m_ref.
[in,out] | source | object to move from |
Definition at line 87 of file ReferenceWrapper.hpp.
|
inline |
Accessor for m_ref.
Definition at line 175 of file ReferenceWrapper.hpp.
|
inline |
Const accessor for m_ref.
Definition at line 184 of file ReferenceWrapper.hpp.
|
inline |
Const accessor for m_ref.
Definition at line 202 of file ReferenceWrapper.hpp.
|
inline |
Check if reference is initialized.
true
if the object has been initialized with a value, false
otherwise Definition at line 193 of file ReferenceWrapper.hpp.
|
inline |
A pass thru parenthesis operator which calls underlying T::operator()
.
variadic | types to pass through to T::operator() |
args | variadic params to pass through to T::operator() |
T::operator()
Definition at line 250 of file ReferenceWrapper.hpp.
|
inline |
A pass thru parenthesis operator which calls underlying T::operator()
.
variadic | types to pass through to T::operator() |
args | variadic params to pass through to T::operator() |
T::operator()
const Definition at line 263 of file ReferenceWrapper.hpp.
|
inline |
Copy assignment operator.
[in] | source | object to copy |
Definition at line 98 of file ReferenceWrapper.hpp.
|
inline |
Assignment operator.
T_RHS | type of the rhs |
U | dummy template parameter to enable SFINAE stuff |
[in] | rhs | value to be copied |
Calls m_ref->operator=() to allow for any type on the rhs if m_ref->operator=() has a valid overload for T_RHS.
Definition at line 118 of file ReferenceWrapper.hpp.
|
inline |
Move assignment operator.
[in,out] | source | the rhs value to be moved |
Sets the value that m_ref refers to to the value of the rhs.
Definition at line 131 of file ReferenceWrapper.hpp.
|
inline |
Set the address that m_ref points to.
[in] | source | reference to object that wrapper will refer to |
Definition at line 157 of file ReferenceWrapper.hpp.
|
inline |
Set the address that m_ref points to.
[in] | source | pointer to object that wrapper will refer to |
Definition at line 166 of file ReferenceWrapper.hpp.