19 #ifndef GEOS_DATAREPOSITORY_REFERENCEWRAPPER_HPP_
20 #define GEOS_DATAREPOSITORY_REFERENCEWRAPPER_HPP_
23 #include <type_traits>
47 template<
typename T >
90 source.m_ref =
nullptr;
100 m_ref = source.m_ref;
115 template<
typename T_RHS,
typename U=T >
117 typename std::enable_if< !std::is_const< U >::value,
ReferenceWrapper & >::type
133 *m_ref = std::move( source );
140 inline operator T & ()
148 inline operator T
const & ()
const
157 inline void set( T & source )
166 inline void set( T * source )
184 inline T
const &
get()
const
220 template<
typename INDEX_TYPE,
typename U = T >
221 inline decltype( std::declval< U >()[1] )
222 operator[]( INDEX_TYPE const i )
233 template<
typename INDEX_TYPE,
typename U = T >
234 inline decltype( std::declval< U const >()[1] )
235 operator[]( INDEX_TYPE const i )
const
248 template<
typename ... ARGS >
249 inline typename std::result_of< T & (ARGS&&...) >::type
252 return m_ref->operator()( std::forward< ARGS >(args)... );
261 template<
typename ... ARGS >
262 inline typename std::result_of< T
const&(ARGS&&...) >::type
265 return m_ref->operator()( std::forward< ARGS >(args)... );
T const * getPtr() const
Const accessor for m_ref.
std::enable_if< !std::is_const< U >::value, ReferenceWrapper & >::type operator=(T_RHS const &rhs)
Assignment operator.
ReferenceWrapper(ReferenceWrapper &&source)
Move constructor copies the source m_ref to the new m_ref.
bool isValid() const
Check if reference is initialized.
std::result_of< T &(ARGS &&...) >::type operator()(ARGS &&... args)
A pass thru parenthesis operator which calls underlying T::operator().
ReferenceWrapper & operator=(ReferenceWrapper const &source)
Copy assignment operator.
std::result_of< T const &(ARGS &&...) >::type operator()(ARGS &&... args) const
A pass thru parenthesis operator which calls underlying T::operator().
void set(T &source)
Set the address that m_ref points to.
~ReferenceWrapper()=default
Default destructor.
T & get()
Accessor for m_ref.
ReferenceWrapper(T &source) noexcept
Constructor that sets m_ref to address of input.
T const & get() const
Const accessor for m_ref.
void set(T *source)
Set the address that m_ref points to.
ReferenceWrapper & operator=(T &&source)
Move assignment operator.
ReferenceWrapper()
Default constructor sets m_ref to nullptr.
ReferenceWrapper(ReferenceWrapper const &source)
Copy constructor copies the source m_ref to the new m_ref.