qxLib
Functions
rtti_cast.h File Reference
#include <qx/rtti/rtti.h>
#include <qx/smart_ptr/link.h>
#include <memory>

Go to the source code of this file.

Functions

template<class to_t , class from_t >
requires std::derived_from< from_t, rtti_pure_base > &&std::derived_from< to_t, rtti_pure_base > to_t * qx::rtti_cast (from_t *pointer)
 Returns to_t* if from_t is inherited from Y, otherwise nullptr. More...
 
template<class to_t , class from_t >
requires std::derived_from< from_t, rtti_pure_base > &&std::derived_from< to_t, rtti_pure_base > to_t * qx::rtti_cast (const std::shared_ptr< from_t > &pValue)
 Returns to_t* if from_t is inherited from Y, otherwise nullptr. More...
 
template<class to_t , class from_t >
requires std::derived_from< from_t, rtti_pure_base > &&std::derived_from< to_t, rtti_pure_base > to_t * qx::rtti_cast (const std::unique_ptr< from_t > &pValue)
 Returns to_t* if from_t is inherited from Y, otherwise nullptr. More...
 
template<class to_t , class from_t >
requires std::derived_from< from_t, rtti_pure_base > &&std::derived_from< to_t, rtti_pure_base > to_t * qx::rtti_cast (const link< from_t > &pValueLink)
 Returns to_t* if from_t is inherited from Y, otherwise nullptr. More...
 
template<class to_t , class from_t >
requires std::derived_from< from_t, rtti_pure_base > &&std::derived_from< to_t, rtti_pure_base > to_t * qx::rtti_cast (from_t &value)
 Returns to_t* if from_t is inherited from Y, otherwise nullptr. More...
 

Detailed Description

Author
Khrapov
Date
9.09.2021

Definition in file rtti_cast.h.

Function Documentation

◆ rtti_cast() [1/5]

template<class to_t , class from_t >
requires std::derived_from<from_t, rtti_pure_base>&& std::derived_from<to_t, rtti_pure_base> to_t* qx::rtti_cast ( const link< from_t > &  pValueLink)

Returns to_t* if from_t is inherited from Y, otherwise nullptr.

Template Parameters
to_t- type to cast to
from_t- type to cast from
Parameters
pValueLink- a pointer to test
Return values
-to_t* if from_t is inherited from Y, otherwise nullptr

Definition at line 79 of file rtti_cast.h.

◆ rtti_cast() [2/5]

template<class to_t , class from_t >
requires std::derived_from<from_t, rtti_pure_base>&& std::derived_from<to_t, rtti_pure_base> to_t* qx::rtti_cast ( const std::shared_ptr< from_t > &  pValue)

Returns to_t* if from_t is inherited from Y, otherwise nullptr.

Template Parameters
to_t- type to cast to
from_t- type to cast from
Parameters
pValue- a pointer to test
Return values
-to_t* if from_t is inherited from Y, otherwise nullptr

Definition at line 45 of file rtti_cast.h.

◆ rtti_cast() [3/5]

template<class to_t , class from_t >
requires std::derived_from<from_t, rtti_pure_base>&& std::derived_from<to_t, rtti_pure_base> to_t* qx::rtti_cast ( const std::unique_ptr< from_t > &  pValue)

Returns to_t* if from_t is inherited from Y, otherwise nullptr.

Template Parameters
to_t- type to cast to
from_t- type to cast from
Parameters
pValue- a pointer to test
Return values
-to_t* if from_t is inherited from Y, otherwise nullptr

Definition at line 62 of file rtti_cast.h.

◆ rtti_cast() [4/5]

template<class to_t , class from_t >
requires std::derived_from<from_t, rtti_pure_base>&& std::derived_from<to_t, rtti_pure_base> to_t* qx::rtti_cast ( from_t &  value)

Returns to_t* if from_t is inherited from Y, otherwise nullptr.

Pointer class should contain QX_RTTI_CLASS

Template Parameters
to_t- type to cast to
from_t- type to cast from
Parameters
value- a value to test
Return values
-to_t* if from_t is inherited from Y, otherwise nullptr

Definition at line 98 of file rtti_cast.h.

◆ rtti_cast() [5/5]

template<class to_t , class from_t >
requires std::derived_from<from_t, rtti_pure_base>&& std::derived_from<to_t, rtti_pure_base> to_t* qx::rtti_cast ( from_t *  pointer)

Returns to_t* if from_t is inherited from Y, otherwise nullptr.

Template Parameters
to_t- type to cast to
from_t- type to cast from
Parameters
pointer- a pointer to test
Return values
-to_t* if from_t is inherited from pointer class, otherwise nullptr

Definition at line 28 of file rtti_cast.h.