you could write a C++ function to marshal a Sequence (or any Container IIRC, maybe Forward Container) to a vector (or whatever you wanted -- there are choices), and then

okay let's see if I remember C++ well enough

This design has extra copying. but anyway

template<typename Container>
std::vector<typename Container::value_type> container_to_vector(Container const& c) {
  return std::vector<typename Container::value_type>(c.begin(), c.end());
}

and

template<typename Container>
Container vector_to_sequence(std::vector<typename Container::value_type> const& c) {
  return Container(c.begin(), c.end());
}

extern "C" {
/* the temporary returned variable doesn't last long enough here */
(char*, int)/*I know C++ doesn't have this syntax of tuples*/ string_to_array(std::string const& s) {
  return (&*container_to_vector(s).begin())
}
}


In other words I suspect that it's possible with a minimum of boilerplate per type, (possibly including the use of macros), but I'm not sure exactly what you need to do, and I got tired of being a C++-fu expert a few years ago

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to