Here is my problem. I have a function that takes structas input, selects a new one structand then returns it. structhas the following content
struct Data {
std::vector<custom_type> vector_vars;
std::string key;
std::map<std::string, Data*> index;
};
vector_varshas a size of 500-1000. custom_type, if relevant, this class . indexhelps me access another structure Dataon key. This is a function.
Data func(Data inputData) {
Data outputData;
return outputData
}
I use stack distribution and return it so that it is copied to RHS. Is this advisable since copying can create a lot of overhead?
Is it possible to return a link / pointer to the structure allocated on the stack inside the function?
( std::shared_ptr) ?