You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the max length of string is known in advance, I can write code like:
std::vector<std::string> v = {"1", "23", "456"};
using S8 = char[8];
py::array_t<S8> arr(v.size());
auto pdest = static_cast<S8*>(arr.request().ptr);
for (std::size_t i = 0; i < v.size(); ++i) {
std::strncpy(pdest[i], v[i].data(), 8);
}
But what if the vector is created dynamically and the longest string is unknown? Please advise.