Horrible workaround for libc++

Libc++ appears to have a problem with dynamic_casting between types
where one of them is a template that has been forward declared. This is
the only case that I see this problem coming up.

Due to the existing interdependencies between header files, I *must*
forward declare the Assignable_Proxy_Function_Impl. I don't see any
other way around this than to work around the standard library bug.
This commit is contained in:
Jason Turner
2015-04-29 13:39:57 -06:00
parent 8bbcceed88
commit 2e72fde0ba

View File

@@ -136,6 +136,14 @@ namespace chaiscript
{
return data;
} else {
#ifdef CHAISCRIPT_LIBCPP
if (std::string(typeid(To).name()).find("Assignable_Proxy_Function") != std::string::npos) {
auto from = detail::Cast_Helper<std::shared_ptr<From> >::cast(t_from, nullptr);
if (std::string(typeid(*from).name()).find("Assignable_Proxy_Function_Impl") != std::string::npos) {
return std::static_pointer_cast<To>(from);
}
}
#endif
throw std::bad_cast();
}
}()