Skip to content

Commit 7d41577

Browse files
author
Pankaj Raghav
authored
Corrected the func definition for vector emplace
The emplace member function of std::vector should take const_iterator and variadic list of arguments as their input for perfect forwarding (https://en.cppreference.com/w/cpp/container/vector/emplace). This document had rvalue reference instead of variadic list of arguments. I also checked the std::vector implementation MSVC, it is now according to the changes proposed. Probably why it still had rvalue reference is explained in this link (https://stackoverflow.com/questions/4303513/push-back-vs-emplace-back).
1 parent 2c85088 commit 7d41577

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/standard-library/vector-class.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,18 +794,19 @@ The number '30' is in c1 collection 3 times.
794794
Inserts an element constructed in place into the vector at a specified position.
795795

796796
```cpp
797+
template <class... Types>
797798
iterator emplace(
798799
const_iterator _Where,
799-
Type&& val);
800+
Types&&... _Args);
800801
```
801802
802803
### Parameters
803804
804805
*_Where*\
805806
The position in the [vector](../standard-library/vector-class.md) where the first element is inserted.
806807
807-
*val*\
808-
The value of the element being inserted into the `vector`.
808+
*_Args*\
809+
Constructor arguments. The function infers which constructor overload to invoke based on the arguments provided.
809810
810811
### Return Value
811812

0 commit comments

Comments
 (0)