From 2e72fde0ba1f8689bcd537549d678109c3da1bd4 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 29 Apr 2015 13:39:57 -0600 Subject: [PATCH] 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. --- include/chaiscript/dispatchkit/type_conversions.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/chaiscript/dispatchkit/type_conversions.hpp b/include/chaiscript/dispatchkit/type_conversions.hpp index dc29efe..4b2cbe8 100644 --- a/include/chaiscript/dispatchkit/type_conversions.hpp +++ b/include/chaiscript/dispatchkit/type_conversions.hpp @@ -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 >::cast(t_from, nullptr); + if (std::string(typeid(*from).name()).find("Assignable_Proxy_Function_Impl") != std::string::npos) { + return std::static_pointer_cast(from); + } + } +#endif throw std::bad_cast(); } }()