Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C++ Language/Std/Stl/CollectionClasses/SequenceCollections/Vector/InsertingItems

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

An inserted item does not need to have the exact same item-type as the vector, as long as it can be coerced into the vector's item-type. If there will be coercion, then insertion by emplace() will be faster than insert() because emplace() directly uses a single-parameter-cast-constructor instead of copy-constructing from a compiler-temporary that holds the coerced-value. To insert as the vector's last item, use emplace_back() or push_back(). Additional information about inserting items into a vector (includes interactive examples)