Adding assert() before critical code
static_pointer_cast and dynamic_pointer_cast prerequisites