Data Access Library (DAL)
 All Classes Functions Variables Typedefs Friends
Public Member Functions
dal::ImplicitDowncast< B > Class Template Reference

#include <implicitdowncast.h>

List of all members.

Public Member Functions

 ImplicitDowncast (B &base)
template<typename D >
 operator D & ()

Detailed Description

template<typename B>
class dal::ImplicitDowncast< B >

ImplicitDowncast< B > returns an object that can implictly be cast to classes derived from B. For example:

 class base {};
 class derived: public base {};

 int main() {
    derived d;
    base *b = &d;

    base    &b2 = ImplicitDowncast<base>(*b);
    derived &d2 = ImplicitDowncast<base>(*b);

    // Without ImplicitDowncast, C++ would require this instead:
    base    &b3 = dynamic_cast<base&>(*b);
    derived &d3 = dynamic_cast<derived&>(*b);
 }

Note that no check is performed whether the cast will be succesful.


The documentation for this class was generated from the following file:
 All Classes Functions Variables Typedefs Friends