Top "Emplace" questions

For questions that concern constructing objects directly within some container object, as opposed to copying/moving the object into the container.

insert vs emplace vs operator[] in c++ map

I'm using maps for the first time and I realized that there are many ways to insert an element. You …

c++ dictionary insert operators emplace
Why emplace_back is faster than push_back?

I thought that emplace_back would be the winner, when doing something like this: v.push_back(myClass(arg1, arg2)); …

c++ performance stl push-back emplace
Efficiency of C++11 push_back() with std::move versus emplace_back() for already constructed objects

In C++11 emplace_back() is generally preferred (in terms of efficiency) to push_back() as it allows in-place construction, but …

c++11 move-semantics push-back emplace
What is the difference between unordered_map::emplace and unordered_map::insert in C++?

What is the difference between std::unordered_map::emplace and std::unordered_map::insert in C++?

c++ c++11 insert unordered-map emplace
std::map emplace without copying value

The C++11 std::map<K,V> type has an emplace function, as do many other containers. std::map&…

c++ c++11 dictionary stl emplace
Insert into vector having objects without copy constructor

I have a class whose copy constructors are explicitly deleted (because A uses pointers internally and I don't want to …

c++ c++11 vector emplace
Emplacing in vector using default constructor

I want to use vector::emplace to default construct a non-copyable and non-assignable object and then use specific methods on …

c++ c++11 vector emplace
Difference between <queue>'s emplace and push

What are the differences between <queue>'s emplace and push? here's explanation about the std::queue::emplace and …

c++ queue push emplace
Emplacement of a vector with initializer list

i have a std::vector<std::vector<double>> and would like to add some elements at …

c++ emplace
why do i need to use piecewise_construct in map::emplace for single arg constructors of noncopyable objects?

The following code will not compile on gcc 4.8.2. The problem is that this code will attempt to copy construct an …

c++ c++11 map std-pair emplace