Here is my problem. I have a function that takes struct as input, allocates a new struct and then returns it. The struct has the following contents
struct Data {
std::vector<custom_type> vector_vars;
std::string key;
std::map<std::string, Data*> index;
};
vector_vars is of size 500-1000. custom_type if relevant is this class. The index helps me access different Data struct by key. This is the function.
Data func(Data inputData) {
 Data outputData;
//compare values with inputData
//change some values in Data struct
 return outputData
}
- Do I use stack allocation and return it so that it is copied to RHS. Is this advisable since copying may create a lot of overhead? 
- Can I return a reference/pointer to struct allocated on the stack within a function? 
- Is it advisable to use dynamic allocation instead here (may be with - std::shared_ptr) for efficiency?
 
     
     
     
     
    