7 # define down_cast static_cast
8 # define down_pointer_cast std::static_pointer_cast
15 ::vcsn::detail::down_caster(__FILE__, __LINE__).cast
16 #define down_pointer_cast down_cast
32 template <
typename T,
typename U>
37 << file <<
':' << line <<
": " << msg
38 <<
" from " <<
typeid(U).name() <<
" to " <<
typeid(T).name()
43 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>
61 error<std::shared_ptr<T>, std::shared_ptr<U>>(
"down_casting nullptr");
62 std::shared_ptr<T>
res = std::dynamic_pointer_cast<T>(t);
64 error<std::shared_ptr<T>, std::shared_ptr<U>>(
"failed down_cast");
82 std::istringstream iss;
85 raise(
"invalid value: ", str);
87 ": invalid value: ", str,
T lexical_cast(const std::string &str)
String to templated type T conversion.
down_caster(const char *f, int l)
A functor that captures the current location (to report errors), and provides "cast".
void error(const char *msg)
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
std::shared_ptr< T > cast(std::shared_ptr< U > t)
Special case for shared_ptr.
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.