6 # define down_cast static_cast
7 # define down_pointer_cast std::static_pointer_cast
14 ::vcsn::detail::down_caster(__FILE__, __LINE__).cast
15 #define down_pointer_cast down_cast
31 template <
typename T,
typename U>
36 << file <<
':' << line <<
": " << msg
37 <<
" from " <<
typeid(U).name() <<
" to " <<
typeid(T).name()
42 template <
typename T,
typename U>
48 error<T, U>(
"down_casting nullptr");
49 T res =
dynamic_cast<const T
>(t);
51 error<T, U>(
"failed down_cast");
56 template <
typename T,
typename U>
62 error<std::shared_ptr<T>, std::shared_ptr<U>>(
"down_casting nullptr");
63 std::shared_ptr<T> res = std::dynamic_pointer_cast<T>(t);
65 error<std::shared_ptr<T>, std::shared_ptr<U>>(
"failed down_cast");
std::shared_ptr< T > cast(std::shared_ptr< U > t)
Special case for shared_ptr.
A functor that captures the current location (to report errors), and provides "cast".
down_caster(const char *f, int l)
void error(const char *msg)