Gamedev Framework (gf)  0.17.0
A C++14 framework for 2D games
Public Member Functions | Related Functions | List of all members
gf::Ref< T > Class Template Reference

A reference wrapper. More...

#include <gf/Ref.h>

Public Member Functions

 Ref (T &ref) noexcept
 Constructor with a lvalue reference. More...
 
 Ref (T &&)=delete
 Deleted constructor with rvalue reference. More...
 
 Ref (const Ref &other) noexcept=default
 Copy constructor. More...
 
template<typename U , typename = std::enable_if_t<std::is_base_of<T, U>::value>>
 Ref (const Ref< U > &other) noexcept
 Copy constructor. More...
 
Refoperator= (const Ref &other) noexcept=default
 Copy assignment. More...
 
template<typename U , typename = std::enable_if_t<std::is_base_of<T, U>::value>>
Refoperator= (const Ref< U > &other) noexcept
 Copy assignment. More...
 
Tget () const noexcept
 Get the reference. More...
 
 operator T & () const noexcept
 Conversion to a reference. More...
 

Related Functions

(Note that these are not member functions.)

template<typename T >
constexpr bool operator== (Ref< T > lhs, Ref< T > rhs) noexcept
 Referece comparison. More...
 
template<typename T >
constexpr bool operator== (Ref< T > lhs, const T &rhs) noexcept
 Referece comparison. More...
 
template<typename T >
constexpr bool operator== (const T &lhs, Ref< T > rhs) noexcept
 Referece comparison. More...
 
template<typename T >
Ref< Tref (T &object)
 Reference creation. More...
 

Detailed Description

template<typename T>
class gf::Ref< T >

A reference wrapper.

This class is similar to std::reference_wrapper.

Constructor & Destructor Documentation

◆ Ref() [1/4]

template<typename T>
gf::Ref< T >::Ref ( T ref)
inlinenoexcept

Constructor with a lvalue reference.

Parameters
refA reference

◆ Ref() [2/4]

template<typename T>
gf::Ref< T >::Ref ( T &&  )
delete

Deleted constructor with rvalue reference.

◆ Ref() [3/4]

template<typename T>
gf::Ref< T >::Ref ( const Ref< T > &  other)
defaultnoexcept

Copy constructor.

◆ Ref() [4/4]

template<typename T>
template<typename U , typename = std::enable_if_t<std::is_base_of<T, U>::value>>
gf::Ref< T >::Ref ( const Ref< U > &  other)
inlinenoexcept

Copy constructor.

Member Function Documentation

◆ get()

template<typename T>
T& gf::Ref< T >::get ( ) const
inlinenoexcept

Get the reference.

Returns
A reference to the object

◆ operator T &()

template<typename T>
gf::Ref< T >::operator T& ( ) const
inlinenoexcept

Conversion to a reference.

Returns
A reference to the object

◆ operator=() [1/2]

template<typename T>
Ref& gf::Ref< T >::operator= ( const Ref< T > &  other)
defaultnoexcept

Copy assignment.

◆ operator=() [2/2]

template<typename T>
template<typename U , typename = std::enable_if_t<std::is_base_of<T, U>::value>>
Ref& gf::Ref< T >::operator= ( const Ref< U > &  other)
inlinenoexcept

Copy assignment.

Friends And Related Function Documentation

◆ operator==() [1/3]

template<typename T >
constexpr bool operator== ( Ref< T lhs,
Ref< T rhs 
)
related

Referece comparison.

The reference are compared by address, not by value.

◆ operator==() [2/3]

template<typename T >
constexpr bool operator== ( Ref< T lhs,
const T rhs 
)
related

Referece comparison.

The reference are compared by address, not by value.

◆ operator==() [3/3]

template<typename T >
constexpr bool operator== ( const T lhs,
Ref< T rhs 
)
related

Referece comparison.

The reference are compared by address, not by value.

◆ ref()

template<typename T >
Ref< T > ref ( T object)
related

Reference creation.