ngraph icon indicating copy to clipboard operation
ngraph copied to clipboard

WTF is up with emplace_back

Open rkimballn1 opened this issue 9 years ago • 1 comments

Why does the vector.emplace_back we are using require that objects emplaced need a copy/move constructor. The object is supposed to be placement newed into the vector so a copy/move is not required.

http://en.cppreference.com/w/cpp/container/vector/emplace_back

The element is constructed through std::allocator_traits::construct, which typically uses placement-new to construct the element in-place at the location provided by the container.

rkimballn1 avatar Sep 14 '17 16:09 rkimballn1

vector requires a copy constructor in order to grow the size of the vector. emplace_back does not inherently require copy but vector does.

https://stackoverflow.com/a/34543871

rkimballn1 avatar Sep 15 '17 16:09 rkimballn1