Opened 5 years ago

Closed 4 years ago

#13299 closed Bugs (fixed)

small_vector<..>::emplace_back does not return the new element's reference

Reported by: falko.loebner@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: container
Version: Boost 1.63.0 Severity: Problem
Keywords: small_vector, emplace_back Cc:

Description

I want to emplace a new item at the back of a small_vector and use the reference to the new item:

boost::container::small_vector<int,16> myVec;
auto& newItem = myVec.emplace_back(10);
assert(newItem == 10); /* this fails */

It seems like the returned reference points to the last element of the internal array (like myVec[15]). This element is uninitialized.

Change History (1)

comment:1 by Ion Gaztañaga, 4 years ago

Resolution: fixed
Status: newclosed

Seems to be the same problem as explained in:

https://github.com/boostorg/container/pull/45

which was fixed for Boost 1.64. Many thanks for the report.

Note: See TracTickets for help on using tickets.