Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dynamic_pointer_cast snippet
for( auto& element : elements )
{
if( auto c = std::dynamic_pointer_cast<C>( element ) )
{
c->BehaveLikeC();
}
if( auto d = std::dynamic_pointer_cast<D>( element ) )
{
DoSomething(d);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment