mardi 7 novembre 2023

Is there a way to convert std::vector

The problem is I have a big vector contains big string contents fetched from local cache wrapped by shared_ptr:

std::vector<std::shared_ptr<std::string>>

but one of my library API requires:

void forExample(std::vector<std::string>& data);

In this library, the data will only be read, there is no modification, no memory operations, just read.

So how can I pass the data correctly without copying the big strings, or any other better recommendations? It's ok to change the library API signature if necessary.

Aucun commentaire:

Enregistrer un commentaire