I have been running some time comparisons between the abovementioned versions:
function[0] = 42;
function.insert(std::map::value_type(0, 42));
function.insert(std::pair(0, 42));
function.insert(std::make_pair(0, 42));
Turns out that time differences between the insert versions are tiny.
#include
This gives respectively for the versions (I ran the file 3 times, hence the 3 consecutive time differences for each):
map_W.insert(std::pair(it,Widget(2.0)));
2198 ms, 2078 ms, 2072 ms
map_W_2.insert(std::make_pair(it,Widget(2.0)));
2290 ms, 2037 ms, 2046 ms
map_W_3[it] = Widget(2.0);
2592 ms, 2278 ms, 2296 ms
map_W_0.insert(std::map::value_type(it,Widget(2.0)));
2234 ms, 2031 ms, 2027 ms
Hence, results between different insert versions can be neglected (didn't perform a hypothesis test though)!
The map_W_3[it] = Widget(2.0); version takes about 10-15 % more time for this example due to an initialization with the default constructor for Widget.