map inserts by reference or via copy ctor

P

puzzlecracker

Does map copy the object, both key and value during the insert?


is this example correct:

std::map<std::string T> my_map;

template<typename T>
void foo(const std::string str, const T & t){
my_map.insert(make_pair(str, t));
}

template<typename T>
void bar()
{
foo(std::string("Key1"),T(param1, param2));
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top