Skip to content

Instantly share code, notes, and snippets.

@PureAbstract
Last active December 18, 2015 22:09
Show Gist options
  • Save PureAbstract/5852655 to your computer and use it in GitHub Desktop.
Save PureAbstract/5852655 to your computer and use it in GitHub Desktop.
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