vector::emplace_back
Adds an element constructed in place to the end of the vector.
template <class... Types>
void emplace_back(
Types&&... _Args);
Parameters
Parameter |
Description |
---|---|
_Args |
Constructor arguments. The function infers which constructor overload to invoke based on the arguments provided. |
Example
#include <vector>
struct obj
{
obj(int, double) {}
};
int main()
{
std::vector<obj> v;
v.emplace_back(1, 3.14); // obj in created in place in the vector
}
Requirements
Header: <vector>
Namespace: std