git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: add cast to const char* (convenience)
commit43aeba7b4fe7e7a655b9d9436aae34b1c4e10ec6 authorAndy Arvanitis <andyarvanitis@gmail.com> dateThu 15 Oct 2015, 12:53 (11 years ago) parent36da272
2 files changed+9
pcc/include/purescript.cc+6 pcc/include/purescript.hh+3
pcc/include/purescript.cc+6
@@ -117,6 +117,12 @@ any::~any() {
117117 }
118118 template auto any::cast<string>() const -> const string&;
119119
120+ template <typename T>
121+ auto any::cast() const -> typename std::enable_if<std::is_same<T, const char*>::value, const T>::type {
122+ RETURN_VALUE(Type::String, s->c_str(),)
123+ }
124+ template auto any::cast<const char*>() const -> const char* const;
125+
120126 template <typename T>
121127 auto any::cast() const -> typename std::enable_if<std::is_same<T, map>::value, const T&>::type {
122128 RETURN_VALUE(Type::Map, m, *)
pcc/include/purescript.hh+3
@@ -214,6 +214,9 @@ class any {
214214 template <typename T>
215215 auto cast() const -> typename std::enable_if<std::is_same<T, string>::value, const T&>::type;
216216
217+ template <typename T>
218+ auto cast() const -> typename std::enable_if<std::is_same<T, const char*>::value, const T>::type;
219+
217220 template <typename T>
218221 auto cast() const -> typename std::enable_if<std::is_same<T, map>::value, const T&>::type;
219222