Archived
This forum has been archived. Please start a new discussion on GitHub.
slice array type mapping to c++
in Help Center
Hello. After read slice data type mapping, it is pointed out that array type is mapping to std::vector in c++. But std::vector seems limited in many cases.
For example, if I have an image to transfer from the client to server.
So my image is already in memory, if use std::vector, because it is value based, I have to do a data copy, and more inconveniently, std::vector(in microsoft's implementi) can only copy a element every time. So I have to write a cycle logic to copy the data.
Is there any more convenient type for array mapping in c++?
For example, if I have an image to transfer from the client to server.
So my image is already in memory, if use std::vector, because it is value based, I have to do a data copy, and more inconveniently, std::vector(in microsoft's implementi) can only copy a element every time. So I have to write a cycle logic to copy the data.
Is there any more convenient type for array mapping in c++?
0
Comments
-
No, we only support std::vector. (We could support other mappings with metadata, but at present, we don't have any such other mappings.)
Why can you only copy one element at a time? You can use std::copy(), or even memcpy() to copy several elements. For example:int* p = ... // Pointer to ints. size_t sz = ... // Number of ints. std::vector<int> v; v.resize(sz); // With std::copy(): std::copy(p, p + sz, v.begin()); // With memcpy(): memcpy(&v[0], p, sz);
0 -
Thanks.0