Subject: [Boost-bugs] [Boost C++ Libraries] #10028: erasing in a container::vector of move only type calls the destructor after the object has been moved
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-05-09 09:10:41
#10028: erasing in a container::vector of move only type calls the destructor after
the object has been moved
------------------------------+------------------------
Reporter: maynuki@⦠| Owner: igaztanaga
Type: Bugs | Status: new
Milestone: To Be Determined | Component: container
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
------------------------------+------------------------
The following snippet shows the issue. This issues affects also flat
associative containers
{{{
#include <iostream>
#include "boost\container\vector.hpp"
#include "boost\noncopyable.hpp"
struct movable : boost::noncopyable {
int value_;
~movable() {
if( value_ != 0 ) {
std::cout << "release resource : " << value_ << std::endl;
}
}
movable(int value) : value_(value) {}
movable(movable&& rhs) : value_(rhs.value_) { rhs.value_ = 0; }
movable& operator=(movable&& rhs) {
value_ = rhs.value_;
rhs.value_ = 0;
return *this;
}
};
int main() {
boost::container::vector<movable> my_vector;
for( int i = 1; i <= 10; ++i) {
my_vector.emplace_back(i);
}
my_vector.erase(my_vector.begin());
my_vector.erase(my_vector.begin(), my_vector.begin() + 3);
return 0;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10028> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC