Have a look at this piece of code:
class Profiler{
    const std::string id;
public:
    Profiler(const std::string id);
    Profiler(const Profiler &t);
//...
}
then somewhere in the code:
std::map<const std::string, Profiler> profilers;
and somewhere else I populate the container as:
profilers.insert(std::pair<const std::string, Profiler>(id, Profiler(id)));
The above line just invoked constructor and copy constructor 3 times in total. one for creating the temporary Profiler, one for creating a pair and one for insert right?
profilers[id] = Profiler(id); also has same number of invocations.
- is there any way to reduce this number?
- isn't it cheaper(in any terms) to change the signatures properly
to create a Profilerin the heap and store its address in themap? (Profilerobjects are small)
thanks
 
    