Replaced deprecated function

When compiling from source on Debian got errors about ```boost::shared_static_cast()``` function not being member of boost. Doing some research found that it is deprecated since boost 1.53 http://goo.gl/xh0NwP.

Replacing this function with ```boost::dynamic_pointer_cast()``` solved the compilation issue for me.