I am using an external library which provides a function with the following interface:
void foo(const std::vector<int>& data);
I am receiving a very large C-style array from another library which has already been allocated:
int* data = bar();
Is there any way for me to pass on data
to foo
without allocating and copying each element? data
is very large and therefore I want to avoid a copy and allocation if possible.
I could have used allocators, but foo
is not templated for an allocator, so I don't believe this is possible.
I understand I may be asking for magic, but if it is possible that would be great. Of course if foo
rather took an std::span
this would not be a problem.