git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: handle cast<string> in FFI
commit22078795476cbee86326bf0a1fbeba329103683f authorAndy Arvanitis <andyarvanitis@gmail.com> dateThu 19 Jan 2017, 15:03 (10 years ago) parent922d50c
1 file changed+7−4
pcc/runtime/purescript.hh+7−4
pcc/runtime/purescript.hh+7−4
@@ -449,13 +449,16 @@ inline auto cast(const any& a) ->
449449
450450template <typename T>
451451inline auto cast(const any& a) ->
452− typename std::enable_if<std::is_same<T, any::array>::value, const T&>::type {
452+ typename std::enable_if<std::is_same<T, string>::value ||
453+ std::is_same<T, any::array>::value, const T&>::type {
453454 return a;
454455}
455456
456−template <typename T, typename = typename std::enable_if<std::is_class<T>::value>::type>
457−inline auto cast(const any& a) ->
458− typename std::enable_if<!std::is_same<T, any::array>::value, T&>::type {
457+template <typename T,
458+ typename = typename std::enable_if<std::is_class<T>::value &&
459+ !std::is_same<T,string>::value &&
460+ !std::is_same<T,any::array>::value>::type>
461+inline auto cast(const any& a) -> T& {
459462 return *static_cast<T*>(a.extractPointer(IF_DEBUG(Private::TagHelper<T>::tag)));
460463}
461464