| Version: 3.2.8

wxWeakRefDynamic< T > Class Template Reference
Class List by Category » Smart Pointers

`#include <wx/weakref.h>`

## Detailed Description

### template<typename T>
class wxWeakRefDynamic< T >

wxWeakRefDynamic<T> is a template class for weak references that is used in the same way as wxWeakRef<T>.

The only difference is that wxWeakRefDynamic defaults to using `dynamic_cast` for establishing the object reference (while wxWeakRef defaults to `static_cast`).

So, wxWeakRef will detect a type mismatch during compile time and will have a little better run-time performance. The role of wxWeakRefDynamic is to handle objects which derived type one does not know.

Note
  wxWeakRef<T> selects an implementation based on the static type of T. If T does not have wxTrackable statically, it defaults to a mixed- mode operation, where it uses `dynamic_cast` as the last measure (if available from the compiler and enabled when building wxWidgets).

For general cases, wxWeakRef<T> is the better choice.

For API documentation, see: wxWeakRef<T>.

Template Parameters

  T | The type to which the smart pointer points to.

##

Library: None; this class implementation is entirely header-based.
Category: Smart Pointers