libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::LIBJMMCG_VER_NAMESPACE::checked_dynamic_cast< To, Excpt > Struct Template Reference

#include <dynamic_cast.hpp>

Classes

struct  exception_type
 

Public Types

typedef To result_type
 

Public Member Functions

template<typename From >
result_typeoperator() (From &obj, const unsigned long l, const char *fun_name, const char *file) noexcept(false)
 

Detailed Description

template<typename To, class Excpt = crt_exception<ppd::platform_api, ppd::heavyweight_threading>>
struct jmmcg::LIBJMMCG_VER_NAMESPACE::checked_dynamic_cast< To, Excpt >

The purpose of this class is to give an opportunity to programmers to replace the useless "std::bad_cast" thrown when performing a "dynamic_cast<To &>(obj)". This class will catch the exception, wrap it up with lots more info, then re-throw an exception_type derived from Excpt and std::bad_cast. For example it will give:

  1. The class types cast from and to.
  2. The address of the object on which the cast was attempted.
  3. The file and line of where the check was done. (So you can more easily track down the errors!)
  4. Extra potentially handy info.

Definition at line 37 of file dynamic_cast.hpp.

Member Typedef Documentation

◆ result_type

template<typename To , class Excpt = crt_exception<ppd::platform_api, ppd::heavyweight_threading>>
typedef To jmmcg::LIBJMMCG_VER_NAMESPACE::checked_dynamic_cast< To, Excpt >::result_type

Definition at line 38 of file dynamic_cast.hpp.

Member Function Documentation

◆ operator()()

template<typename To , class Excpt = crt_exception<ppd::platform_api, ppd::heavyweight_threading>>
template<typename From >
result_type& jmmcg::LIBJMMCG_VER_NAMESPACE::checked_dynamic_cast< To, Excpt >::operator() ( From &  obj,
const unsigned long  l,
const char *  fun_name,
const char *  file 
)
inlinenoexcept

The documentation for this struct was generated from the following file: