denz
8 posts


@kryptnaught Except the emplaced object isn't a member of v when v is destroyed. When v is destroyed, it's empty.
English

This C++ code:
#include <vector>
struct V : std::vector<V> {} ;
int main()
{
V v;
v.emplace_back();
v.swap(v.front());
}
English

@kryptnaught It definitely leaks memory. How do you think the emplaced object gets destroyed? It is not contained by v when v goes out of scope.
English